本文整理汇总了C++中QXmppByteStreamIq::activate方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmppByteStreamIq::activate方法的具体用法?C++ QXmppByteStreamIq::activate怎么用?C++ QXmppByteStreamIq::activate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmppByteStreamIq
的用法示例。
在下文中一共展示了QXmppByteStreamIq::activate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool XmppServerProxy65::handleStanza(const QDomElement &element)
{
if (element.attribute("to") != d->jid)
return false;
if (element.tagName() == "iq" && QXmppDiscoveryIq::isDiscoveryIq(element))
{
QXmppDiscoveryIq discoIq;
discoIq.parse(element);
if (discoIq.type() == QXmppIq::Get)
{
QXmppDiscoveryIq responseIq;
responseIq.setTo(discoIq.from());
responseIq.setFrom(discoIq.to());
responseIq.setId(discoIq.id());
responseIq.setType(QXmppIq::Result);
responseIq.setQueryType(discoIq.queryType());
if (discoIq.queryType() == QXmppDiscoveryIq::InfoQuery)
{
QStringList features = QStringList() << ns_disco_info << ns_disco_items << ns_bytestreams;
QList<QXmppDiscoveryIq::Identity> identities;
QXmppDiscoveryIq::Identity identity;
identity.setCategory("proxy");
identity.setType("bytestreams");
identity.setName("SOCKS5 Bytestreams");
identities.append(identity);
responseIq.setFeatures(features);
responseIq.setIdentities(identities);
}
server()->sendPacket(responseIq);
return true;
}
}
else if (element.tagName() == "iq" && QXmppByteStreamIq::isByteStreamIq(element))
{
QXmppByteStreamIq bsIq;
bsIq.parse(element);
if (bsIq.type() == QXmppIq::Get)
{
// request for the proxy's network address
if (d->allowedDomains.contains(QXmppUtils::jidToDomain(bsIq.from()))) {
QXmppByteStreamIq responseIq;
responseIq.setType(QXmppIq::Result);
responseIq.setTo(bsIq.from());
responseIq.setFrom(bsIq.to());
responseIq.setId(bsIq.id());
QList<QXmppByteStreamIq::StreamHost> streamHosts;
QXmppByteStreamIq::StreamHost streamHost;
streamHost.setJid(d->jid);
streamHost.setHost(d->hostAddress.toString());
streamHost.setPort(d->port);
streamHosts.append(streamHost);
responseIq.setStreamHosts(streamHosts);
server()->sendPacket(responseIq);
} else {
QXmppIq responseIq;
responseIq.setType(QXmppIq::Error);
responseIq.setTo(bsIq.from());
responseIq.setFrom(bsIq.to());
responseIq.setId(bsIq.id());
responseIq.setError(QXmppStanza::Error(QXmppStanza::Error::Auth, QXmppStanza::Error::Forbidden));
server()->sendPacket(responseIq);
}
}
else if (bsIq.type() == QXmppIq::Set)
{
QString hash = streamHash(bsIq.sid(), bsIq.from(), bsIq.activate());
QTcpSocketPair *pair = d->pairs.value(hash);
QXmppIq responseIq;
responseIq.setTo(bsIq.from());
responseIq.setFrom(bsIq.to());
responseIq.setId(bsIq.id());
if (pair &&
d->allowedDomains.contains(QXmppUtils::jidToDomain(bsIq.from())))
{
if (pair->activate()) {
info(QString("Activated connection %1 by %2").arg(hash, bsIq.from()));
responseIq.setType(QXmppIq::Result);
} else {
warning(QString("Failed to activate connection %1 by %2").arg(hash, bsIq.from()));
responseIq.setType(QXmppIq::Error);
}
} else {
warning(QString("Not activating connection %1 by %2").arg(hash, bsIq.from()));
responseIq.setType(QXmppIq::Error);
}
server()->sendPacket(responseIq);
}
return true;
//.........这里部分代码省略.........