void AdvancedConnector::changePollInterval(int secs) { if(d->bs && (d->bs->inherits("XMPP::HttpPoll") || d->bs->inherits("HttpPoll"))) { HttpPoll *s = static_cast<HttpPoll*>(d->bs); s->setPollInterval(secs); } }
void AdvancedConnector::connectToServer(const QString &server) { if(d->mode != Idle) return; if(server.isEmpty()) return; d->errorCode = 0; d->server = server; d->mode = Connecting; d->aaaa = true; if(d->proxy.type() == Proxy::HttpPoll) { // need SHA1 here if(!QCA::isSupported(QCA::CAP_SHA1)) QCA::insertProvider(createProviderHash()); HttpPoll *s = new HttpPoll; d->bs = s; connect(s, SIGNAL(connected()), SLOT(bs_connected())); connect(s, SIGNAL(syncStarted()), SLOT(http_syncStarted())); connect(s, SIGNAL(syncFinished()), SLOT(http_syncFinished())); connect(s, SIGNAL(error(int)), SLOT(bs_error(int))); if(!d->proxy.user().isEmpty()) s->setAuth(d->proxy.user(), d->proxy.pass()); s->setPollInterval(d->proxy.pollInterval()); if(d->proxy.host().isEmpty()) s->connectToUrl(d->proxy.url()); else s->connectToHost(d->proxy.host(), d->proxy.port(), d->proxy.url()); } else { if(!d->opt_host.isEmpty()) { d->host = d->opt_host; d->port = d->opt_port; do_resolve(); } else { d->multi = true; QGuardedPtr<QObject> self = this; srvLookup(d->server); if(!self) return; d->srv.resolveSrvOnly(d->server, "xmpp-client", "tcp"); } } }
void AdvancedConnector::connectToServer(const QString &server) { #ifdef XMPP_DEBUG XDEBUG << "s:" << server; #endif if(d->mode != Idle) return; if(server.isEmpty()) return; d->errorCode = 0; d->mode = Connecting; // Encode the servername d->host = QUrl::toAce(server); if (d->host == QByteArray()) { /* server contains invalid characters for DNS name, but maybe valid characters for connecting, like "::1" */ d->host = server; } d->port = XMPP_DEFAULT_PORT; if(d->proxy.type() == Proxy::HttpPoll) { HttpPoll *s = new HttpPoll; d->bs = s; connect(s, SIGNAL(connected()), SLOT(bs_connected())); connect(s, SIGNAL(syncStarted()), SLOT(http_syncStarted())); connect(s, SIGNAL(syncFinished()), SLOT(http_syncFinished())); connect(s, SIGNAL(error(int)), SLOT(bs_error(int))); if(!d->proxy.user().isEmpty()) s->setAuth(d->proxy.user(), d->proxy.pass()); s->setPollInterval(d->proxy.pollInterval()); if(d->proxy.host().isEmpty()) s->connectToUrl(d->proxy.url()); else s->connectToHost(d->proxy.host(), d->proxy.port(), d->proxy.url()); } else if (d->proxy.type() == Proxy::HttpConnect) { HttpConnect *s = new HttpConnect; d->bs = s; connect(s, SIGNAL(connected()), SLOT(bs_connected())); connect(s, SIGNAL(error(int)), SLOT(bs_error(int))); if(!d->opt_host.isEmpty()) { d->host = d->opt_host; d->port = d->opt_port; } if(!d->proxy.user().isEmpty()) s->setAuth(d->proxy.user(), d->proxy.pass()); s->connectToHost(d->proxy.host(), d->proxy.port(), d->host, d->port); } else if (d->proxy.type() == Proxy::Socks) { SocksClient *s = new SocksClient; d->bs = s; connect(s, SIGNAL(connected()), SLOT(bs_connected())); connect(s, SIGNAL(error(int)), SLOT(bs_error(int))); if(!d->opt_host.isEmpty()) { d->host = d->opt_host; d->port = d->opt_port; } if(!d->proxy.user().isEmpty()) s->setAuth(d->proxy.user(), d->proxy.pass()); s->connectToHost(d->proxy.host(), d->proxy.port(), d->host, d->port); } else { BSocket *s = new BSocket; d->bs = s; #ifdef XMPP_DEBUG XDEBUG << "Adding socket:" << s; #endif connect(s, SIGNAL(connected()), SLOT(bs_connected())); connect(s, SIGNAL(error(int)), SLOT(bs_error(int))); if(!d->opt_host.isEmpty()) { d->host = d->opt_host; d->port = d->opt_port; s->connectToHost(d->host, d->port); return; } else if (d->opt_ssl != Never) { d->port = XMPP_LEGACY_PORT; } s->connectToHost(XMPP_CLIENT_SRV, XMPP_CLIENT_TRANSPORT, d->host, d->port); } }
void AdvancedConnector::connectToServer(const QString &server) { if(d->mode != Idle) return; if(server.isEmpty()) return; d->errorCode = 0; d->mode = Connecting; d->aaaa = true; // Encode the servername d->server = QUrl::toAce(server); //char* server_encoded; //if (!idna_to_ascii_8z(server.utf8().data(), &server_encoded, 0)) { // d->server = QString(server_encoded); // free(server_encoded); //} //else { // d->server = server; //} if(d->proxy.type() == Proxy::HttpPoll) { // need SHA1 here //if(!QCA::isSupported(QCA::CAP_SHA1)) // QCA::insertProvider(createProviderHash()); HttpPoll *s = new HttpPoll; d->bs = s; connect(s, SIGNAL(connected()), SLOT(bs_connected())); connect(s, SIGNAL(syncStarted()), SLOT(http_syncStarted())); connect(s, SIGNAL(syncFinished()), SLOT(http_syncFinished())); connect(s, SIGNAL(error(int)), SLOT(bs_error(int))); if(!d->proxy.user().isEmpty()) s->setAuth(d->proxy.user(), d->proxy.pass()); s->setPollInterval(d->proxy.pollInterval()); if(d->proxy.host().isEmpty()) s->connectToUrl(d->proxy.url()); else s->connectToHost(d->proxy.host(), d->proxy.port(), d->proxy.url()); } else if (d->proxy.type() == Proxy::HttpConnect) { if(!d->opt_host.isEmpty()) { d->host = d->opt_host; d->port = d->opt_port; } else { d->host = server; d->port = 5222; } do_connect(); } else { if(!d->opt_host.isEmpty()) { d->host = d->opt_host; d->port = d->opt_port; do_resolve(); } else { d->multi = true; QPointer<QObject> self = this; srvLookup(d->server); if(!self) return; d->type[d->jdns.queryStart( QString("_xmpp-client._tcp.%1").arg(d->server).toLatin1(), QJDns::Srv)] = QJDns::Srv; } } }