本文整理汇总了C++中QXmppMessage::parse方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmppMessage::parse方法的具体用法?C++ QXmppMessage::parse怎么用?C++ QXmppMessage::parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmppMessage
的用法示例。
在下文中一共展示了QXmppMessage::parse方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
QXmppMessage Forwarded2Message (const QXmppElement& wrapper)
{
const auto& forwardedElem = wrapper.tagName () == "forwarded" ?
wrapper :
wrapper.firstChildElement ("forwarded");
if (forwardedElem.isNull ())
return {};
const auto& messageElem = forwardedElem.firstChildElement ("message");
if (messageElem.isNull ())
return {};
QXmppMessage original;
#if QXMPP_VERSION >= 0x000800
original.parse (messageElem.sourceDomElement ());
#else
#warning "You won't have good forwarded messages, Message Archive Management and Message Carbons will look like crap."
original.parse (XmppElem2DomElem (messageElem));
#endif
auto delayElem = forwardedElem.firstChildElement ("delay");
if (!delayElem.isNull ())
{
const auto& sourceDT = QXmppUtils::datetimeFromString (delayElem.attribute ("stamp"));
original.setStamp (sourceDT.toLocalTime ());
}
return original;
}
示例2: handleStanza
bool QXmppCarbonManager::handleStanza(const QDomElement &element)
{
if(element.tagName() != "message")
return false;
bool sent = true;
QDomElement carbon = element.firstChildElement("sent");
if(carbon.isNull()) {
carbon = element.firstChildElement("received");
sent = false;
}
if(carbon.isNull() || carbon.namespaceURI() != ns_carbons)
return false; // Neither sent nor received -> no carbon message
QDomElement forwarded = carbon.firstChildElement("forwarded");
if(forwarded.isNull())
return false;
QDomElement messageelement = forwarded.firstChildElement("message");
if(messageelement.isNull())
return false;
QXmppMessage message;
message.parse(messageelement);
if(sent)
emit messageSent(message);
else
emit messageReceived(message);
return true;
}
示例3: handleStanza
bool QXmppMessageReceiptManager::handleStanza(const QDomElement &stanza)
{
if (stanza.tagName() != "message")
return false;
QXmppMessage message;
message.parse(stanza);
// Handle receipts and cancel any further processing.
if (!message.receiptId().isEmpty()) {
Q_EMIT messageDelivered(message.from(), message.receiptId());
return true;
}
// If requested, send a receipt.
if (message.isReceiptRequested()
&& !message.from().isEmpty()
&& !message.id().isEmpty()) {
QXmppMessage receipt;
receipt.setTo(message.from());
receipt.setReceiptId(message.id());
client()->sendPacket(receipt);
}
// Continue processing.
return false;
}
示例4: handleStanza
bool XmppServerArchive::handleStanza(const QDomElement &element)
{
const QString domain = server()->domain();
const QString from = element.attribute("from");
const QString to = element.attribute("to");
if (element.tagName() == "message" &&
to != domain &&
(QXmppUtils::jidToDomain(from) == domain || QXmppUtils::jidToDomain(to) == domain) &&
element.attribute("type") != "error" &&
element.attribute("type") != "groupchat" &&
element.attribute("type") != "headline" &&
!element.firstChildElement("body").text().isEmpty())
{
const QDateTime now = QDateTime::currentDateTime().toUTC();
QXmppMessage message;
message.parse(element);
if (QXmppUtils::jidToDomain(from) == domain)
saveMessage(message, now, false);
if (QXmppUtils::jidToDomain(to) == domain) {
saveMessage(message, now, true);
// offline messages
bool found = false;
XmppServerPresence *presenceExtension = XmppServerPresence::instance(server());
Q_ASSERT(presenceExtension);
foreach (const QXmppPresence &presence, presenceExtension->availablePresences(QXmppUtils::jidToBareJid(to))) {
if (QXmppUtils::jidToResource(to).isEmpty() || presence.from() == to) {
found = true;
break;
}
}
if (!found) {
message.setStamp(now);
message.setState(QXmppMessage::None);
message.setTo(QXmppUtils::jidToBareJid(to));
QBuffer buffer;
buffer.open(QIODevice::WriteOnly);
QXmlStreamWriter writer(&buffer);
message.toXml(&writer);
OfflineMessage offline;
offline.setData(QString::fromUtf8(buffer.data()));
offline.setJid(QXmppUtils::jidToBareJid(to));
offline.setStamp(now);
offline.save();
return true;
}
}
return false;
} else if (element.tagName() == "presence" &&
示例5: handleStanza
bool QXmppSimpleArchiveManager::handleStanza(const QDomElement &element)
{
bool isIq = (element.tagName() == "iq");
if (!isIq && (element.tagName() != "message")) {
return false;
}
// XEP-0313: Message Archiving
if(isIq && !QXmppSimpleArchiveQueryIq::isSimpleArchiveQueryIq(element)) {
return false;
}
if (isIq && (element.attribute("type") == "result")) {
QString id = element.attribute("id");
if (m_pendingQueries.contains(id)) {
PendingQuery pendingQuery = m_pendingQueries.value(id);
m_pendingQueries.remove(id);
QXmppSimpleArchiveQueryIq packet;
packet.parse(element);
emit archiveMessagesReceived(pendingQuery.jid, pendingQuery.messages, packet.resultSetReply());
return true;
}
} else if (isIq && (element.attribute("type") == "error")) {
QDomElement queryElement = element.firstChildElement("query");
if (!queryElement.isNull()) {
QString queryId = queryElement.attribute("queryid");
if (m_pendingQueries.contains(queryId)) {
PendingQuery pendingQuery = m_pendingQueries.value(queryId);
m_pendingQueries.remove(queryId);
emit archiveMessagesReceived(pendingQuery.jid, pendingQuery.messages, QXmppResultSetReply());
return true;
}
}
} else {
// message, check for result UUID + query ID
QDomElement resultElement = element.firstChildElement("result");
if (!resultElement.isNull()) {
QString queryId = resultElement.attribute("queryid");
if (m_pendingQueries.contains(queryId)) {
QXmppMessage msg;
msg.parse(element);
m_pendingQueries[queryId].messages.append(msg.mamMessage());
return true;
} else {
qWarning() << "SimpleArchiveManager: unknown query ID:" << queryId;
}
}
}
return false;
}
示例6: ownMessage
bool Lvk::CA::FbOwnMessageExtension::handleStanza(const QDomElement &nodeRecv)
{
bool handled = false;
if (nodeRecv.tagName() == "iq") {
QDomElement child = nodeRecv.firstChildElement();
if (child.tagName() == "own-message" && child.attribute("self") == "false") {
QXmppMessage msg;
msg.parse(child);
emit ownMessage(msg);
handled = true;
}
}
return handled;
}
示例7: parseForward
QXmppMessage QXmppMessage::parseForward(QDomElement &element)
{
QXmppMessage result;
if (!element.isNull() && element.namespaceURI() == ns_stanza_forwarding)
{
QDomElement msgElement = element.firstChildElement("message");
QXmppMessage fwd;
fwd.parse(msgElement);
QDomElement delayElement = element.firstChildElement("delay");
if (!delayElement.isNull() && delayElement.namespaceURI() == ns_delayed_delivery) {
const QString str = delayElement.attribute("stamp");
fwd.d->stamp = QXmppUtils::datetimeFromString(str);
fwd.d->stampType = DelayedDelivery;
}
result = fwd;
}
return result;
}
示例8: handleStanza
bool QXmppPEPManager::handleStanza(const QDomElement &stanza)
{
bool isIq = (stanza.tagName() == "iq");
if (!isIq && (stanza.tagName() != "message")) {
return false;
}
// XEP-0163: Personal Eventing Protocol
QDomElement pepElement = stanza.firstChildElement("event");
if(!pepElement.isNull() && pepElement.namespaceURI() == ns_personal_eventing_protocol)
{
QXmppMessage message;
message.parse(stanza);
QDomElement itemsElement = pepElement.firstChildElement("items");
QString nodeType = itemsElement.attribute("node");
// XEP-0152: Reachability Addresses
if(nodeType == ns_reach)
{
QDomElement itemElement = itemsElement.firstChildElement("item");
if(!itemElement.isNull())
{
QString itemId = itemElement.attribute("id");
QDomElement reachElement = itemElement.firstChildElement("reach");
QXmppReachAddress reachAddress;
reachAddress.parse(reachElement);
if(!reachAddress.isNull())
emit reachabilityAddressReceived(message.from(), itemId, reachAddress);
return true;
}
}
}
return false;
}