本文整理汇总了C++中QXmppMessage::setId方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmppMessage::setId方法的具体用法?C++ QXmppMessage::setId怎么用?C++ QXmppMessage::setId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmppMessage
的用法示例。
在下文中一共展示了QXmppMessage::setId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testReplaceWithEmptyMessage
void tst_QXmppMessage::testReplaceWithEmptyMessage()
{
const QByteArray replaceXml(
"<message to='[email protected]/balcony' id='good1'>"
"<body/>"
"<replace id='bad1' xmlns='urn:xmpp:message-correct:0'/>"
"</message>");
QXmppMessage replaceMessage;
parsePacket(replaceMessage, replaceXml);
QCOMPARE(replaceMessage.isReplace(), true);
QCOMPARE(replaceMessage.replaceId(), QString("bad1"));
QCOMPARE(replaceMessage.body(), QString(""));
const QByteArray replaceSerialisation(
"<message id=\"good1\" to=\"[email protected]/balcony\" type=\"chat\">"
"<body/>"
"<replace id=\"bad1\" xmlns=\"urn:xmpp:message-correct:0\"/>"
"</message>");
QXmppMessage serialisationMessage;
serialisationMessage.setTo("[email protected]/balcony");
serialisationMessage.setId("good1");
serialisationMessage.setBody("");
serialisationMessage.setReplace("bad1");
serializePacket(serialisationMessage, replaceSerialisation);
}
示例2: testChatMarkers
//.........这里部分代码省略.........
QCOMPARE(acknowledgedMessage.id(), QString("message-2"));
QCOMPARE(acknowledgedMessage.markedId(), QString("message-1"));
QCOMPARE(acknowledgedMessage.thread(), QString());
QCOMPARE(acknowledgedMessage.markedThread(), QString("sleeping"));
const QByteArray emptyThreadXml(
"<message "
"from='[email protected]/throne' "
"id='message-2' "
"to='[email protected]/westminster'>"
"<received xmlns='urn:xmpp:chat-markers:0' "
"id='message-1'/>"
"</message>");
QXmppMessage emptyThreadMessage;
parsePacket(emptyThreadMessage, emptyThreadXml);
QCOMPARE(emptyThreadMessage.isMarkable(), false);
QCOMPARE(emptyThreadMessage.marker(), QXmppMessage::Received);
QCOMPARE(emptyThreadMessage.id(), QString("message-2"));
QCOMPARE(emptyThreadMessage.markedId(), QString("message-1"));
QCOMPARE(emptyThreadMessage.thread(), QString());
QCOMPARE(emptyThreadMessage.markedThread(), QString());
const QByteArray notMarkableSerialisation(
"<message "
"id=\"message-3\" "
"to=\"[email protected]/westminster\" "
"from=\"[email protected]/throne\" "
"type=\"chat\"/>");
QXmppMessage serialisationMessage;
serialisationMessage.setFrom("[email protected]/throne");
serialisationMessage.setTo("[email protected]e.lit/westminster");
serialisationMessage.setId("message-3");
serialisationMessage.setMarkable(false);
serializePacket(serialisationMessage, notMarkableSerialisation);
const QByteArray markableSerialisation(
"<message "
"id=\"message-3\" "
"to=\"[email protected]/westminster\" "
"from=\"[email protected]/throne\" "
"type=\"chat\">"
"<markable xmlns=\"urn:xmpp:chat-markers:0\"/>"
"</message>");
serialisationMessage.setMarkable(true);
serializePacket(serialisationMessage, markableSerialisation);
const QByteArray receivedSerialisation(
"<message "
"id=\"message-3\" "
"to=\"[email protected]/westminster\" "
"from=\"[email protected]/throne\" "
"type=\"chat\">"
"<received xmlns=\"urn:xmpp:chat-markers:0\" "
"id=\"message-2\"/>"
"</message>");
serialisationMessage.setMarkable(false);
serialisationMessage.setMarker(QXmppMessage::Received, "message-2");
serializePacket(serialisationMessage, receivedSerialisation);
const QByteArray receivedThreadSerialisation(
"<message "
"id=\"message-3\" "
示例3: executeCommand
bool XMPPChatMarkerCommand::executeCommand(QStringList * const arguments)
{
bool ret = false;
if (arguments->length() not_eq 2)
{
this->client->write(tr("ERROR: xmppChatMarker <resource> <marker>") + "\r\n");
}
else
{
const QString resource = arguments->first();
QXmppClient * const client =
XMPPResourceStore::instance()->getFromStore(resource);
arguments->removeFirst();
if (client)
{
QSharedPointer<QXmppStanza> lastStanza
= XMPPResourceStore::instance()->getLastMessageReceived(
client);
if (lastStanza)
{
const QSharedPointer<QXmppMessage> lastMsg
= lastStanza.dynamicCast<QXmppMessage>();
if (lastMsg and lastMsg->isMarkable())
{
bool markerOk = true;
QXmppMessage::Marker msgMarker;
const QString marker = arguments->first();
arguments->removeFirst();
if (marker == "received")
{
msgMarker = QXmppMessage::Received;
}
else if (marker == "displayed")
{
msgMarker = QXmppMessage::Displayed;
}
else if (marker == "acknowledged")
{
msgMarker = QXmppMessage::Acknowledged;
}
else
{
markerOk = false;
}
if (markerOk)
{
QXmppMessage markerMessage;
markerMessage.setId(QUuid::createUuid().toString());
markerMessage.setThread("");
markerMessage.setMarkable(false);
markerMessage.setTo(lastMsg->from());
markerMessage.setMarker(msgMarker, lastMsg->id());
markerMessage.addHint(QXmppMessage::AllowPermantStorage);
if (XMPPDebugCommand::isDebugEnabled())
{
XMPPPrintCommand::printMessage(
true,
&markerMessage);
}
ret = client->sendPacket(markerMessage);
if (not ret)
{
this->client->write(tr("ERROR: Failed to send packet") + "\r\n");
}
else
{
XMPPResourceStore::instance()->setLastMessageSent(
client,
markerMessage);
}
}
else
{
this->client->write(tr("ERROR: Invalid marker") + "\r\n");
}
}
else
{
this->client->write(tr("ERROR: The last message isn't Markable") + "\r\n");
}
}
else
{
this->client->write(tr("ERROR: Can't find the last message received to mark")
+ "\r\n");
}
}
else
{
this->client->write(tr("ERROR: Unknown resource") + "\r\n");
}
}
return ret;
}