本文整理汇总了C++中QXmppMessage::stamp方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmppMessage::stamp方法的具体用法?C++ QXmppMessage::stamp怎么用?C++ QXmppMessage::stamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmppMessage
的用法示例。
在下文中一共展示了QXmppMessage::stamp方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: messageReceived
void Conversation::messageReceived(const QXmppMessage &msg)
{
if (msg.type() != QXmppMessage::Chat ||
QXmppUtils::jidToBareJid(msg.from()) != m_jid)
return;
// handle chat state
if (msg.state() != m_remoteState) {
m_remoteState = msg.state();
emit remoteStateChanged(m_remoteState);
}
// handle message body
if (msg.body().isEmpty())
return;
HistoryMessage message;
message.body = msg.body();
message.date = msg.stamp();
if (!message.date.isValid())
message.date = m_client->serverTime();
message.jid = m_jid;
message.received = true;
if (m_historyModel)
m_historyModel->addMessage(message);
}
示例2: testForwarding
void tst_QXmppMessage::testForwarding()
{
const QByteArray xml("<message type=\"normal\">"
"<body>hi!</body>"
"<forwarded xmlns=\"urn:xmpp:forward:0\">"
"<delay xmlns=\"urn:xmpp:delay\" stamp=\"2010-06-29T08:23:06Z\"/>"
"<message xmlns=\"jabber:client\" "
"type=\"chat\" "
"from=\"[email protected]/QXmpp\" "
"to=\"[email protected]/QXmpp\">"
"<body>ABC</body>"
"</message>"
"</forwarded>"
"</message>");
QXmppMessage message;
parsePacket(message, xml);
QCOMPARE(message.hasForwarded(), true);
QXmppMessage fwd = message.forwarded();
QCOMPARE(fwd.stamp(), QDateTime(QDate(2010, 06, 29), QTime(8, 23, 6), Qt::UTC));
QCOMPARE(fwd.body(), QString("ABC"));
QCOMPARE(fwd.to(), QString("[email protected]/QXmpp"));
QCOMPARE(fwd.from(), QString("[email protected]/QXmpp"));
}
示例3: testDelay
void tst_QXmppMessage::testDelay()
{
QFETCH(QByteArray, xml);
QFETCH(QDateTime, stamp);
QXmppMessage message;
parsePacket(message, xml);
QCOMPARE(message.stamp(), stamp);
serializePacket(message, xml);
}
示例4: testDelayWithMultipleStamp
void tst_QXmppMessage::testDelayWithMultipleStamp()
{
// the XEP-0203 should override XEP-0091's value since XEP-0091 was no more standard protocol
QByteArray xml(
"<message type=\"normal\">"
"<delay xmlns=\"urn:xmpp:delay\" stamp=\"2010-06-29T08:23:06.123Z\"/>"
"<x xmlns=\"jabber:x:delay\" stamp=\"20100629T08:23:06\"/>"
"</message>");
QByteArray resultXml(
"<message type=\"normal\">"
"<delay xmlns=\"urn:xmpp:delay\" stamp=\"2010-06-29T08:23:06.123Z\"/>"
"</message>");
QXmppMessage message;
parsePacket(message, xml);
qDebug() << message.stamp();
QCOMPARE(message.stamp(), QDateTime(QDate(2010, 06, 29), QTime(8, 23, 6, 123), Qt::UTC));
serializePacket(message, resultXml);
}
示例5: testMessageLegacyDelay
void TestPackets::testMessageLegacyDelay()
{
const QByteArray xml(
"<message to=\"[email protected]/QXmpp\" from=\"[email protected]/QXmpp\" type=\"normal\">"
"<x xmlns=\"jabber:x:delay\" stamp=\"20100629T08:23:06\"/>"
"</message>");
QXmppMessage message;
parsePacket(message, xml);
QCOMPARE(message.stamp(), QDateTime(QDate(2010, 06, 29), QTime(8, 23, 6), Qt::UTC));
serializePacket(message, xml);
}
示例6: handleReceivedMessage
void JabberChatService::handleReceivedMessage(const QXmppMessage &xmppMessage)
{
if (!m_formattedStringFactory)
return;
m_chatStateService->extractReceivedChatState(xmppMessage);
if (xmppMessage.body().isEmpty())
return;
if (xmppMessage.type() == QXmppMessage::Type::Error) // #1642
return;
auto message = xmppMessage.type() == QXmppMessage::GroupChat
? m_roomChatService->handleReceivedMessage(xmppMessage)
: handleNormalReceivedMessage(xmppMessage);
if (message.isNull())
return;
message.setType(MessageTypeReceived);
message.setSendDate(xmppMessage.stamp().toLocalTime());
message.setReceiveDate(QDateTime::currentDateTime());
auto body = xmppMessage.body();
if (rawMessageTransformerService())
body = QString::fromUtf8(rawMessageTransformerService()->transform(body.toUtf8(), message).rawContent());
auto htmlBody = replacedNewLine(Qt::escape(body), QLatin1String("<br/>"));
auto formattedString = m_formattedStringFactory.data()->fromHtml(htmlBody);
if (!formattedString || formattedString->isEmpty())
return;
message.setContent(std::move(formattedString));
auto id = xmppMessage.from();
auto resourceIndex = id.indexOf('/');
if (resourceIndex >= 0)
id = id.mid(0, resourceIndex);
m_contactMessageTypes.insert(id, xmppMessage.type());
emit messageReceived(message);
}
示例7: testMessageCarbons
void tst_QXmppMessage::testMessageCarbons()
{
const QByteArray xml("<message type=\"normal\">"
"<body>hi!</body>"
"<sent xmlns='urn:xmpp:carbons:2'>"
"<forwarded xmlns=\"urn:xmpp:forward:0\">"
"<delay xmlns=\"urn:xmpp:delay\" stamp=\"2010-06-29T08:23:06Z\"/>"
"<message xmlns=\"jabber:client\" "
"type=\"chat\" "
"from=\"[email protected]/QXmpp\" "
"to=\"[email protected]/QXmpp\">"
"<body>ABC</body>"
"</message>"
"</forwarded>"
"</sent>"
"</message>");
QXmppMessage message;
parsePacket(message, xml);
QCOMPARE(message.hasMessageCarbon(), true);
QXmppMessage fwd = message.carbonMessage();
QCOMPARE(fwd.stamp(), QDateTime(QDate(2010, 06, 29), QTime(8, 23, 6), Qt::UTC));
QCOMPARE(fwd.body(), QString("ABC"));
QCOMPARE(fwd.to(), QString("[email protected]/QXmpp"));
QCOMPARE(fwd.from(), QString("[email protected]/QXmpp"));
const QByteArray carbonXml("<iq id=\"id1\""
" type=\"set\">"
"<enable xmlns=\"urn:xmpp:carbons:2\"/>"
"</iq>");
QXmppMessageCarbonsIq carbonIq;
carbonIq.setId("id1");
serializePacket(carbonIq, carbonXml);
}