本文整理汇总了C++中QXmppMessage::extensions方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmppMessage::extensions方法的具体用法?C++ QXmppMessage::extensions怎么用?C++ QXmppMessage::extensions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmppMessage
的用法示例。
在下文中一共展示了QXmppMessage::extensions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testSubextensions
void tst_QXmppMessage::testSubextensions()
{
const QByteArray xml("<message id=\"aeb214\" to=\"[email protected]/chamber\" type=\"normal\">"
"<result xmlns=\"urn:xmpp:mam:tmp\" id=\"5d398-28273-f7382\" queryid=\"f27\">"
"<forwarded xmlns=\"urn:xmpp:forward:0\">"
"<delay xmlns=\"urn:xmpp:delay\" stamp=\"2010-07-10T23:09:32Z\"/>"
"<message from=\"[email protected]/balcony\" id=\"8a54s\" "
"to=\"[email protected]/orchard\" type=\"chat\">"
"<body>What man art thou that thus bescreen'd in night so stumblest on my counsel?</body>"
"</message>"
"</forwarded>"
"</result>"
"</message>");
QXmppMessage message;
parsePacket(message, xml);
QCOMPARE(message.extensions().size(), 1);
QCOMPARE(message.extensions().first().tagName(), QLatin1String("result"));
serializePacket(message, xml);
}
示例2:
bool Xep0313Manager::CheckMessage (const QXmppMessage& msg)
{
for (const auto& extension : msg.extensions ())
if (extension.tagName () == "result" &&
extension.attribute ("xmlns") == NsMam)
{
HandleMessage (extension);
return true;
}
return false;
}
示例3: HandleMessage
void RoomHandler::HandleMessage (const QXmppMessage& msg, const QString& nick)
{
Q_FOREACH (const QXmppElement& elem, msg.extensions ())
{
const QString& xmlns = elem.attribute ("xmlns");
if (xmlns == ns_data)
{
QXmppDataForm *df = new QXmppDataForm ();
df->parse (XooxUtil::XmppElem2DomElem (elem));
if (df->isNull ())
{
qWarning () << Q_FUNC_INFO
<< "unable to parse form from"
<< msg.from ();
delete df;
}
else
emit gotPendingForm (df, msg.from ());
}
else
qWarning () << Q_FUNC_INFO
<< "unhandled <x> element"
<< xmlns;
}
const bool existed = Nick2Entry_.contains (nick);
RoomParticipantEntry_ptr entry = GetParticipantEntry (nick, false);
if (msg.type () == QXmppMessage::Chat && !nick.isEmpty ())
{
if (msg.isAttentionRequested ())
entry->HandleAttentionMessage (msg);
if (msg.state ())
entry->UpdateChatState (msg.state (), QString ());
if (!msg.body ().isEmpty ())
{
GlooxMessage *message = new GlooxMessage (msg,
Account_->GetClientConnection ().get ());
entry->HandleMessage (message);
}
}
else
{
RoomPublicMessage *message = 0;
if (msg.type () == QXmppMessage::GroupChat &&
!msg.subject ().isEmpty ())
{
Subject_ = msg.subject ();
CLEntry_->HandleSubjectChanged (Subject_);
const QString& string = nick.isEmpty () ?
msg.subject () :
tr ("%1 changed subject to %2")
.arg (nick)
.arg (msg.subject ());
message = new RoomPublicMessage (string,
IMessage::DIn,
CLEntry_,
IMessage::MTEventMessage,
IMessage::MSTOther);
}
else if (!nick.isEmpty ())
{
if (!msg.body ().isEmpty ())
message = new RoomPublicMessage (msg, CLEntry_, entry);
}
else if (!msg.body ().isEmpty ())
message = new RoomPublicMessage (msg.body (),
IMessage::DIn,
CLEntry_,
IMessage::MTEventMessage,
IMessage::MSTOther);
if (message)
CLEntry_->HandleMessage (message);
if (!existed)
Nick2Entry_.remove (nick);
}
}