本文整理汇总了C++中IQ::clearChild方法的典型用法代码示例。如果您正苦于以下问题:C++ IQ::clearChild方法的具体用法?C++ IQ::clearChild怎么用?C++ IQ::clearChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IQ
的用法示例。
在下文中一共展示了IQ::clearChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotRegister
void GatewayTask::slotRegister(const XMPP::IQ& iq)
{
QString tag = iq.childElement().tagName();
QString ns = iq.childElement().namespaceURI();
if ( tag == "query" && ns == NS_IQ_REGISTER && iq.type() == "get" ) {
Registration form(d->reg);
form.setTo(iq.from());
form.setFrom(iq.to());
form.setId(iq.id());
form.setType(IQ::Result);
d->stream->sendStanza(form);
return;
}
if ( tag == "query" && ns == NS_IQ_REGISTER && iq.type() == "set" ) {
Registration request(iq);
if ( request.from().isEmpty() ) {
Registration err = IQ::createReply(request);
err.setError( Stanza::Error(Stanza::Error::UnexpectedRequest) );
d->stream->sendStanza(err);
return;
}
if ( request.hasField(Registration::Remove) ) {
Registration reply = IQ::createReply(iq);
reply.clearChild();
reply.setType(IQ::Result);
d->stream->sendStanza(reply);
Presence removeSubscription;
removeSubscription.setTo( iq.from().bare() );
removeSubscription.setType(Presence::Unsubscribe);
d->stream->sendStanza(removeSubscription);
Presence removeAuth;
removeAuth.setTo( iq.from().bare() );
removeAuth.setType(Presence::Unsubscribed);
d->stream->sendStanza(removeAuth);
Presence logout;
logout.setTo( iq.from() );
logout.setType(Presence::Unavailable);
d->stream->sendStanza(logout);
emit userUnregister(iq.from());
return;
}
if ( request.getField(Registration::Username).isEmpty() || request.getField(Registration::Password).isEmpty() ) {
Registration err(request);
err.swapFromTo();
err.setError( Stanza::Error(Stanza::Error::NotAcceptable) );
d->stream->sendStanza(err);
return;
}
/* registration success */
IQ reply = IQ::createReply(iq);
reply.clearChild();
d->stream->sendStanza(reply);
/* subscribe for user presence */
Presence subscribe;
subscribe.setFrom(iq.to());
subscribe.setTo( iq.from().bare() );
subscribe.setType(Presence::Subscribe);
d->stream->sendStanza(subscribe);
emit userRegister( request.from(), request.getField(Registration::Username), request.getField(Registration::Password) );
Presence presence;
presence.setFrom(iq.to());
presence.setTo( iq.from().bare() );
d->stream->sendStanza(presence);
/* execute log-in case */
emit userLogIn(iq.from(), Presence::None);
return;
}
}