예제 #1
0
파일: client.cpp 프로젝트: tshipa/wilink
void ChatClient::_q_discoveryInfoReceived(const QXmppDiscoveryIq &disco)
{
    // we only want results
    if (!d->discoQueue.removeAll(disco.id()) ||
        disco.type() != QXmppIq::Result)
        return;

    foreach (const QXmppDiscoveryIq::Identity &id, disco.identities()) {
        // check if it's a conference server
        if (id.category() == QLatin1String("conference") &&
            id.type() == QLatin1String("text")) {
            d->mucServer = disco.from();
            info("Found chat room server " + d->mucServer);
            emit mucServerChanged(d->mucServer);
        }
        // check if it's a diagnostics server
        else if (id.category() == QLatin1String("diagnostics") &&
                 id.type() == QLatin1String("server")) {
            d->diagnosticServer = disco.from();
            info("Found diagnostics server " + d->diagnosticServer);
            emit diagnosticServerChanged(d->diagnosticServer);
        }
#if 0
        // check if it's a publish-subscribe server
        else if (id.category() == QLatin1String("pubsub") &&
                 id.type() == QLatin1String("service")) {
            d->pubSubServer = disco.from();
            info("Found pubsub server " + d->pubSubServer);
            emit pubSubServerChanged(d->pubSubServer);
        }
#endif
        // check if it's a SOCKS5 proxy server
        else if (id.category() == QLatin1String("proxy") &&
                 id.type() == QLatin1String("bytestreams")) {
            info("Found bytestream proxy " + disco.from());
            QXmppTransferManager *transferManager = findExtension<QXmppTransferManager>();
            if (transferManager)
                transferManager->setProxy(disco.from());
        }
        // check if it's a file sharing server
        else if (id.category() == QLatin1String("store") &&
                 id.type() == QLatin1String("file")) {
            d->shareServer = disco.from();
            info("Found share server " + d->shareServer);
            emit shareServerChanged(d->shareServer);
        }
    }

    // if it's the root server, ask for items
    if (disco.from() == configuration().domain() && disco.queryNode().isEmpty()) {
        const QString id = d->discoManager->requestItems(disco.from(), disco.queryNode());
        if (!id.isEmpty())
            d->discoQueue.append(id);
    }
}
예제 #2
0
	void ServerInfoStorage::HandleItemInfo (const QXmppDiscoveryIq& iq)
	{
		auto hasIdentity = [&iq] (const QString& cat, const QString& type) -> bool
		{
			const auto& ids = iq.identities ();
			return std::any_of (ids.begin (), ids.end (),
					[&cat, &type] (const auto& id) { return id.category () == cat && id.type () == type; });
		};
		if (hasIdentity ("proxy", "bytestreams"))
		{
			BytestreamsProxy_ = iq.from ();
			emit bytestreamsProxyChanged (BytestreamsProxy_);
		}
	}