本文整理汇总了C++中QXmppMessage::setBody方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmppMessage::setBody方法的具体用法?C++ QXmppMessage::setBody怎么用?C++ QXmppMessage::setBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmppMessage
的用法示例。
在下文中一共展示了QXmppMessage::setBody方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendMyMessage
bool MyXmppClient::sendMyMessage(QString bareJid, QString resource, QString msgBody) //Q_INVOKABLE
{
if (msgBody == "" || m_stateConnect != Connected) return false; // if message is empty or user not connected - BREAK
QXmppMessage xmppMsg;
QString jid_from = bareJid;
if( resource == "" ) jid_from += "/resource"; else jid_from += "/" + resource;
xmppMsg.setTo( jid_from );
QString jid_to = m_myjid + "/" + xmppClient->configuration().resource();
xmppMsg.setFrom( jid_to );
xmppMsg.setBody( msgBody );
xmppMsg.setState( QXmppMessage::Active );
xmppClient->sendPacket( xmppMsg );
this->messageReceivedSlot( xmppMsg );
emit insertMessage(m_accountId,this->getBareJidByJid(xmppMsg.to()),msgBody,QDateTime::currentDateTime().toString("dd-MM-yy hh:mm"),1);
return true;
}
示例2: sendMessage
bool Conversation::sendMessage(const QString &body)
{
if (body.isEmpty() || m_jid.isEmpty() || !m_client || !m_client->isConnected())
return false;
// send message
QXmppMessage message;
message.setTo(m_jid);
message.setBody(body);
message.setState(QXmppMessage::Active);
if (!m_client->sendPacket(message))
return false;
// update state
if (m_localState != QXmppMessage::Active) {
m_localState = QXmppMessage::Active;
emit localStateChanged(m_localState);
}
// add message to history
if (m_historyModel) {
HistoryMessage message;
message.body = body;
message.date = m_client->serverTime();
message.jid = m_client->configuration().jidBare();
message.received = false;
m_historyModel->addMessage(message);
}
return true;
}
示例3: eventFilter
bool ChatWindow::eventFilter(QObject* sender, QEvent* event) {
if (sender == ui->messagePlainTextEdit) {
if (event->type() != QEvent::KeyPress) {
return false;
}
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
if ((keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) &&
(keyEvent->modifiers() & Qt::ShiftModifier) == 0) {
QString messageText = ui->messagePlainTextEdit->document()->toPlainText().trimmed();
if (!messageText.isEmpty()) {
#ifdef HAVE_QXMPP
const QXmppMucRoom* publicChatRoom = XmppClient::getInstance().getPublicChatRoom();
QXmppMessage message;
message.setTo(publicChatRoom->jid());
message.setType(QXmppMessage::GroupChat);
message.setBody(messageText);
XmppClient::getInstance().getXMPPClient().sendPacket(message);
#endif // HAVE_QXMPP
QTextCursor cursor = ui->messagePlainTextEdit->textCursor();
cursor.select(QTextCursor::Document);
cursor.removeSelectedText();
}
return true;
}
} else if (event->type() == QEvent::MouseButtonRelease) {
QVariant userVar = sender->property("user");
if (userVar.isValid()) {
AddressManager::getInstance().goToUser(userVar.toString());
return true;
}
}
return QWidget::eventFilter(sender, event);
}
示例4: 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);
}
示例5: DrawAttention
void EntryBase::DrawAttention (const QString& text, const QString& variant)
{
const QString& to = variant.isEmpty () ?
GetJID () :
GetJID () + '/' + variant;
QXmppMessage msg;
msg.setBody (text);
msg.setTo (to);
msg.setType (QXmppMessage::Headline);
msg.setAttentionRequested (true);
Account_->GetClientConnection ()->GetClient ()->sendPacket (msg);
}