本文整理汇总了C++中QXmppMessage::setStamp方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmppMessage::setStamp方法的具体用法?C++ QXmppMessage::setStamp怎么用?C++ QXmppMessage::setStamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmppMessage
的用法示例。
在下文中一共展示了QXmppMessage::setStamp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 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" &&
示例3: typingStop
/* it sends information about typing : typing is stoped */
void MyXmppClient::typingStop(QString bareJid, QString resource) {
qDebug() << bareJid << " " << "stop typing...";
QXmppMessage xmppMsg;
QString jid_to = bareJid;
if( resource == "" ) jid_to += "/resource"; else jid_to += "/" + resource;
xmppMsg.setTo( jid_to );
QString jid_from = m_myjid + "/" + xmppClient->configuration().resource();
xmppMsg.setFrom( jid_from );
xmppMsg.setReceiptRequested( false );
QDateTime currTime = QDateTime::currentDateTime();
xmppMsg.setStamp( currTime );
xmppMsg.setState( QXmppMessage::Paused );
xmppClient->sendPacket( xmppMsg );
}