void QXmppTransferIncomingJob::_q_candidateReady() { bool check; Q_UNUSED(check); if (!m_candidateClient) return; setState(QXmppTransferJob::TransferState); d->socksSocket = m_candidateClient; m_candidateClient = 0; check = connect(d->socksSocket, SIGNAL(readyRead()), this, SLOT(_q_receiveData())); Q_ASSERT(check); check = connect(d->socksSocket, SIGNAL(disconnected()), this, SLOT(_q_disconnected())); Q_ASSERT(check); QXmppByteStreamIq ackIq; ackIq.setId(m_streamOfferId); ackIq.setTo(m_streamOfferFrom); ackIq.setType(QXmppIq::Result); ackIq.setSid(d->sid); ackIq.setStreamHostUsed(m_candidateHost.jid()); d->client->sendPacket(ackIq); }
void QXmppTransferOutgoingJob::connectToProxy() { bool check; Q_UNUSED(check); info(QString("Connecting to proxy: %1 (%2:%3)").arg( d->socksProxy.jid(), d->socksProxy.host().toString(), QString::number(d->socksProxy.port()))); const QString hostName = streamHash(d->sid, d->client->configuration().jid(), d->jid); QXmppSocksClient *socksClient = new QXmppSocksClient(d->socksProxy.host(), d->socksProxy.port(), this); check = connect(socksClient, SIGNAL(disconnected()), this, SLOT(_q_disconnected())); Q_ASSERT(check); check = connect(socksClient, SIGNAL(ready()), this, SLOT(_q_proxyReady())); Q_ASSERT(check); d->socksSocket = socksClient; socksClient->connectToHost(hostName, 0); }
void QXmppTransferIncomingJob::_q_candidateReady() { bool check; Q_UNUSED(check); if (!m_candidateClient) return; info(QString("Connected to streamhost: %1 (%2 %3)").arg( m_candidateHost.jid(), m_candidateHost.host(), QString::number(m_candidateHost.port()))); setState(QXmppTransferJob::TransferState); d->socksSocket = m_candidateClient; m_candidateClient = 0; m_candidateTimer->deleteLater(); m_candidateTimer = 0; check = connect(d->socksSocket, SIGNAL(readyRead()), this, SLOT(_q_receiveData())); Q_ASSERT(check); check = connect(d->socksSocket, SIGNAL(disconnected()), this, SLOT(_q_disconnected())); Q_ASSERT(check); QXmppByteStreamIq ackIq; ackIq.setId(m_streamOfferId); ackIq.setTo(m_streamOfferFrom); ackIq.setType(QXmppIq::Result); ackIq.setSid(d->sid); ackIq.setStreamHostUsed(m_candidateHost.jid()); d->client->sendPacket(ackIq); }
QXmppRosterManager::QXmppRosterManager(QXmppClient* client) { bool check; Q_UNUSED(check); d = new QXmppRosterManagerPrivate(this); check = connect(client, SIGNAL(connected()), this, SLOT(_q_connected())); Q_ASSERT(check); check = connect(client, SIGNAL(disconnected()), this, SLOT(_q_disconnected())); Q_ASSERT(check); check = connect(client, SIGNAL(presenceReceived(QXmppPresence)), this, SLOT(_q_presenceReceived(QXmppPresence))); Q_ASSERT(check); check = connect(client, SIGNAL(streamManagementEnabled(bool)), this, SLOT(_q_streamResumeEnabled(bool))); Q_ASSERT(check); check = connect(client, SIGNAL(streamManagementResumed(bool)), this, SLOT(_q_streamResumed(bool))); Q_ASSERT(check); }
QT_BEGIN_NAMESPACE // TODO: Put channel specific stuff here so it does not polute qhttpnetworkconnection.cpp void QHttpNetworkConnectionChannel::init() { #ifndef QT_NO_OPENSSL if (connection->d_func()->encrypt) socket = new QSslSocket; else socket = new QTcpSocket; #else socket = new QTcpSocket; #endif // limit the socket read buffer size. we will read everything into // the QHttpNetworkReply anyway, so let's grow only that and not // here and there. socket->setReadBufferSize(64*1024); QObject::connect(socket, SIGNAL(bytesWritten(qint64)), this, SLOT(_q_bytesWritten(qint64)), Qt::DirectConnection); QObject::connect(socket, SIGNAL(connected()), this, SLOT(_q_connected()), Qt::DirectConnection); QObject::connect(socket, SIGNAL(readyRead()), this, SLOT(_q_readyRead()), Qt::DirectConnection); QObject::connect(socket, SIGNAL(disconnected()), this, SLOT(_q_disconnected()), Qt::DirectConnection); QObject::connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(_q_error(QAbstractSocket::SocketError)), Qt::DirectConnection); #ifndef QT_NO_NETWORKPROXY QObject::connect(socket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), this, SLOT(_q_proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), Qt::DirectConnection); #endif #ifndef QT_NO_OPENSSL QSslSocket *sslSocket = qobject_cast<QSslSocket*>(socket); if (sslSocket) { // won't be a sslSocket if encrypt is false QObject::connect(sslSocket, SIGNAL(encrypted()), this, SLOT(_q_encrypted()), Qt::DirectConnection); QObject::connect(sslSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(_q_sslErrors(QList<QSslError>)), Qt::DirectConnection); QObject::connect(sslSocket, SIGNAL(encryptedBytesWritten(qint64)), this, SLOT(_q_encryptedBytesWritten(qint64)), Qt::DirectConnection); } #endif }
void IrcSession::setSocket(QAbstractSocket* socket) { Q_D(IrcSession); if (d->socket != socket) { if (d->socket) { d->socket->disconnect(this); if (d->socket->parent() == this) d->socket->deleteLater(); } d->socket = socket; if (socket) { connect(socket, SIGNAL(connected()), this, SLOT(_q_connected())); connect(socket, SIGNAL(disconnected()), this, SLOT(_q_disconnected())); connect(socket, SIGNAL(readyRead()), this, SLOT(_q_readData())); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(_q_error(QAbstractSocket::SocketError))); connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(_q_state(QAbstractSocket::SocketState))); } } }
void QHttpNetworkConnectionChannel::init() { #ifndef QT_NO_SSL if (connection->d_func()->encrypt) socket = new QSslSocket; else socket = new QTcpSocket; #else socket = new QTcpSocket; #endif #ifndef QT_NO_BEARERMANAGEMENT //push session down to socket if (networkSession) socket->setProperty("_q_networksession", QVariant::fromValue(networkSession)); #endif #ifndef QT_NO_NETWORKPROXY // Set by QNAM anyway, but let's be safe here socket->setProxy(QNetworkProxy::NoProxy); #endif // After some back and forth in all the last years, this is now a DirectConnection because otherwise // the state inside the *Socket classes gets messed up, also in conjunction with the socket notifiers // which behave slightly differently on Windows vs Linux QObject::connect(socket, SIGNAL(bytesWritten(qint64)), this, SLOT(_q_bytesWritten(qint64)), Qt::DirectConnection); QObject::connect(socket, SIGNAL(connected()), this, SLOT(_q_connected()), Qt::DirectConnection); QObject::connect(socket, SIGNAL(readyRead()), this, SLOT(_q_readyRead()), Qt::DirectConnection); // The disconnected() and error() signals may already come // while calling connectToHost(). // In case of a cached hostname or an IP this // will then emit a signal to the user of QNetworkReply // but cannot be caught because the user did not have a chance yet // to connect to QNetworkReply's signals. qRegisterMetaType<QAbstractSocket::SocketError>(); QObject::connect(socket, SIGNAL(disconnected()), this, SLOT(_q_disconnected()), Qt::DirectConnection); QObject::connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(_q_error(QAbstractSocket::SocketError)), Qt::DirectConnection); #ifndef QT_NO_NETWORKPROXY QObject::connect(socket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), this, SLOT(_q_proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), Qt::DirectConnection); #endif #ifndef QT_NO_SSL QSslSocket *sslSocket = qobject_cast<QSslSocket*>(socket); if (sslSocket) { // won't be a sslSocket if encrypt is false QObject::connect(sslSocket, SIGNAL(encrypted()), this, SLOT(_q_encrypted()), Qt::DirectConnection); QObject::connect(sslSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(_q_sslErrors(QList<QSslError>)), Qt::DirectConnection); QObject::connect(sslSocket, SIGNAL(preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)), this, SLOT(_q_preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)), Qt::DirectConnection); QObject::connect(sslSocket, SIGNAL(encryptedBytesWritten(qint64)), this, SLOT(_q_encryptedBytesWritten(qint64)), Qt::DirectConnection); if (ignoreAllSslErrors) sslSocket->ignoreSslErrors(); if (!ignoreSslErrorsList.isEmpty()) sslSocket->ignoreSslErrors(ignoreSslErrorsList); if (!sslConfiguration.isNull()) sslSocket->setSslConfiguration(sslConfiguration); } else {
void QHttpNetworkConnectionChannel::init() { #ifndef QT_NO_OPENSSL if (connection->d_func()->encrypt) socket = new QSslSocket; else socket = new QTcpSocket; #else socket = new QTcpSocket; #endif #ifndef QT_NO_BEARERMANAGEMENT //push session down to socket if (networkSession) socket->setProperty("_q_networksession", QVariant::fromValue(networkSession)); #endif #ifndef QT_NO_NETWORKPROXY // Set by QNAM anyway, but let's be safe here socket->setProxy(QNetworkProxy::NoProxy); #endif QObject::connect(socket, SIGNAL(bytesWritten(qint64)), this, SLOT(_q_bytesWritten(qint64)), Qt::DirectConnection); QObject::connect(socket, SIGNAL(connected()), this, SLOT(_q_connected()), Qt::DirectConnection); QObject::connect(socket, SIGNAL(readyRead()), this, SLOT(_q_readyRead()), Qt::DirectConnection); // The disconnected() and error() signals may already come // while calling connectToHost(). // In case of a cached hostname or an IP this // will then emit a signal to the user of QNetworkReply // but cannot be caught because the user did not have a chance yet // to connect to QNetworkReply's signals. qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError"); QObject::connect(socket, SIGNAL(disconnected()), this, SLOT(_q_disconnected()), Qt::QueuedConnection); QObject::connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(_q_error(QAbstractSocket::SocketError)), Qt::QueuedConnection); #ifndef QT_NO_NETWORKPROXY QObject::connect(socket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), this, SLOT(_q_proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), Qt::DirectConnection); #endif #ifndef QT_NO_OPENSSL QSslSocket *sslSocket = qobject_cast<QSslSocket*>(socket); if (sslSocket) { // won't be a sslSocket if encrypt is false QObject::connect(sslSocket, SIGNAL(encrypted()), this, SLOT(_q_encrypted()), Qt::DirectConnection); QObject::connect(sslSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(_q_sslErrors(QList<QSslError>)), Qt::DirectConnection); QObject::connect(sslSocket, SIGNAL(encryptedBytesWritten(qint64)), this, SLOT(_q_encryptedBytesWritten(qint64)), Qt::DirectConnection); } #endif }
bool QRfcommServer::listen(const QBluetoothAddress &address, quint16 port) { Q_D(QRfcommServer); // listen has already been called before if(d->socket) return true; d->socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket,this); if(!d->socket) { return false; } d->ds = d->socket->d_ptr; if(!d->ds) { delete d->socket; d->socket = 0; return false; } d->ds->ensureNativeSocket(QBluetoothSocket::RfcommSocket); TRfcommSockAddr addr; if(!address.isNull()) { // TBTDevAddr constructor may panic TRAPD(err,addr.SetBTAddr(TBTDevAddr(address.toUInt64()))); if(err != KErrNone) { delete d->socket; d->socket = 0; return false; } } if (port == 0) addr.SetPort(KRfcommPassiveAutoBind); else addr.SetPort(port); TBTServiceSecurity security; switch (d->securityFlags) { case QBluetooth::Authentication: security.SetAuthentication(EMitmDesired); break; case QBluetooth::Authorization: security.SetAuthorisation(ETrue); break; case QBluetooth::Encryption: // "Secure" is BlueZ specific we just make sure the code remain compatible case QBluetooth::Secure: // authentication required security.SetAuthentication(EMitmDesired); security.SetEncryption(ETrue); break; case QBluetooth::NoSecurity: default: break; } if(d->ds->iSocket->Bind(addr) == KErrNone) { d->socket->setSocketState(QBluetoothSocket::BoundState); } else { delete d->socket; d->socket = 0; return false; } if(d->ds->iSocket->Listen(d->maxPendingConnections) != KErrNone) { delete d->socket; d->socket = 0; return false; } QBluetoothSocket *pendingSocket = new QBluetoothSocket(QBluetoothSocket::UnknownSocketType, this); if(!pendingSocket) { delete d->socket; d->socket = 0; return false; } QBluetoothSocketPrivate *pd = pendingSocket->d_ptr; pd->ensureBlankNativeSocket(QBluetoothSocket::RfcommSocket); connect(d->socket, SIGNAL(disconnected()), this, SLOT(_q_disconnected())); connect(d->socket, SIGNAL(connected()), this, SLOT(_q_connected())); connect(d->socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(_q_socketError(QBluetoothSocket::SocketError))); if (d->ds->iSocket->Accept(*pd->iSocket) == KErrNone) { d->socket->setSocketState(QBluetoothSocket::ListeningState); d->activeSockets.append(pendingSocket); return true; } else { delete d->socket, pendingSocket; d->socket = 0; return false; } }
JAccount::JAccount(const QString &id) : Account(id, JProtocol::instance()), d_ptr(new JAccountPrivate(this)) { Q_D(JAccount); d->client.reset(new Client(id)); connect(d->client.data(), SIGNAL(disconnected(Jreen::Client::DisconnectReason)), this, SLOT(_q_disconnected(Jreen::Client::DisconnectReason))); connect(d->client.data(), SIGNAL(serverFeaturesReceived(QSet<QString>)), this ,SLOT(_q_init_extensions(QSet<QString>))); Account::setStatus(Status::instance(Status::Offline, "jabber")); d->loadedModules = 0; d->privacyManager = new PrivacyManager(d->client.data()); d->pubSubManager = new Jreen::PubSub::Manager(d->client.data()); d->privateXml = new Jreen::PrivateXml(d->client.data()); d->roster = new JRoster(this); Jreen::Capabilities::Ptr caps = d->client->presence().payload<Jreen::Capabilities>(); caps->setNode(QLatin1String("http://qutim.org/")); d->conferenceManager = new JMUCManager(this, this); d->messageSessionManager = new JMessageSessionManager(this); connect(d->messageSessionManager, SIGNAL(messageEcnrypted(quint64)), SIGNAL(messageEcnrypted(quint64))); d->softwareDetection = new JSoftwareDetection(this); d->client->presence().addExtension(new VCardUpdate()); Jreen::Disco *disco = d->client->disco(); disco->setSoftwareVersion(QLatin1String("qutIM"), versionString(), SystemInfo::getFullName()); disco->addIdentity(Jreen::Disco::Identity(QLatin1String("client"), QLatin1String("type"), QLatin1String("qutIM"), QLatin1String("en"))); QString qutim = tr("qutIM", "Local qutIM's name"); QString lang = tr("en", "Default language"); if(qutim != QLatin1String("qutIM") && lang != QLatin1String("en")) disco->addIdentity(Jreen::Disco::Identity(QLatin1String("client"), QLatin1String("type"),qutim,lang)); connect(d->roster, SIGNAL(loaded()), &d->signalMapper, SLOT(map())); connect(d->privacyManager, SIGNAL(listsReceived()), &d->signalMapper, SLOT(map())); d->signalMapper.setMapping(d->roster, 1); d->signalMapper.setMapping(d->privacyManager, 2); connect(d->client.data(), SIGNAL(connected()), d->privacyManager, SLOT(request())); connect(&d->signalMapper, SIGNAL(mapped(int)), this, SLOT(_q_on_module_loaded(int))); // connect(d->roster, SIGNAL(loaded()), d, SLOT(onConnected())); // connect(d->client.data(),SIGNAL(connected()), d, SLOT(onConnected())); d->roster->loadFromStorage(); connect(d->conferenceManager.data(), SIGNAL(conferenceCreated(qutim_sdk_0_3::Conference*)), this, SIGNAL(conferenceCreated(qutim_sdk_0_3::Conference*))); // d->params.addItem<Jreen::Client>(d->client); // d->params.addItem<Jreen::PubSub::Manager>(d->pubSubManager); // d->params.addItem<Adhoc>(p->adhoc); // d->params.addItem<VCardManager>(p->vCardManager->manager()); // d->params.addItem<SIManager>(p->siManager); // d->softwareDetection = new JSoftwareDetection(p->account, p->params); foreach (const ObjectGenerator *gen, ObjectGenerator::module<JabberExtension>()) { if (JabberExtension *ext = gen->generate<JabberExtension>()) { d->extensions.append(ext); ext->init(this); } } JPGPSupport::instance()->addAccount(this); }
JAccount::JAccount(const QString &id) : Account(id, JProtocol::instance()), d_ptr(new JAccountPrivate(this)) { Q_D(JAccount); d->client.reset(new Client(id)); connect(d->client.data(), SIGNAL(disconnected(Jreen::Client::DisconnectReason)), this, SLOT(_q_disconnected(Jreen::Client::DisconnectReason))); connect(d->client.data(), SIGNAL(serverFeaturesReceived(QSet<QString>)), this ,SLOT(_q_init_extensions(QSet<QString>))); d->loadedModules = 0; d->privacyManager = new PrivacyManager(d->client.data()); d->pubSubManager = new Jreen::PubSub::Manager(d->client.data()); d->privateXml = new Jreen::PrivateXml(d->client.data()); d->roster = new JRoster(this); Jreen::Capabilities::Ptr caps = d->client->presence().payload<Jreen::Capabilities>(); caps->setNode(QLatin1String("http://qutim.org/")); d->conferenceManager = new JMUCManager(this, this); d->messageSessionManager = new JMessageSessionManager(this); connect(d->messageSessionManager, SIGNAL(messageEcnrypted(quint64)), SIGNAL(messageEcnrypted(quint64))); d->softwareDetection = new JSoftwareDetection(this); d->client->presence().addExtension(new VCardUpdate()); Jreen::Disco *disco = d->client->disco(); disco->setSoftwareVersion(QLatin1String("qutIM"), versionString(), SystemInfo::getFullName()); disco->addIdentity(Jreen::Disco::Identity(QLatin1String("client"), QLatin1String("type"), QLatin1String("qutIM"), QLatin1String("en"))); QString qutim = tr("qutIM", "Local qutIM's name"); QString lang = tr("en", "Default language"); if(qutim != QLatin1String("qutIM") && lang != QLatin1String("en")) disco->addIdentity(Jreen::Disco::Identity(QLatin1String("client"), QLatin1String("type"),qutim,lang)); connect(d->roster, SIGNAL(loaded()), &d->signalMapper, SLOT(map())); connect(d->privacyManager, SIGNAL(listsReceived()), &d->signalMapper, SLOT(map())); d->signalMapper.setMapping(d->roster, 1); d->signalMapper.setMapping(d->privacyManager, 2); connect(d->client.data(), SIGNAL(connected()), d->privacyManager, SLOT(request())); connect(&d->signalMapper, SIGNAL(mapped(int)), this, SLOT(_q_on_module_loaded(int))); d->roster->loadFromStorage(); connect(d->conferenceManager.data(), SIGNAL(conferenceCreated(qutim_sdk_0_3::Conference*)), this, SIGNAL(conferenceCreated(qutim_sdk_0_3::Conference*))); foreach (const ObjectGenerator *gen, ObjectGenerator::module<JabberExtension>()) { if (JabberExtension *ext = gen->generate<JabberExtension>()) { d->extensions.append(ext); ext->init(this); } } { // Temporary hook // TODO: Remove this hook or make migration more automatic Config config = this->config(QStringLiteral("general")); const QString passwd = QStringLiteral("passwd"); if (config.hasChildKey(passwd)) { d->keyChain->write(this, config.value(passwd, QString(), Config::Crypted)); config.remove(passwd); } } // JPGPSupport::instance()->addAccount(this); }