当前位置: 首页>>代码示例>>C++>>正文


C++ QXmppMessage::setBody方法代码示例

本文整理汇总了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;
}
开发者ID:ksiazkowicz,项目名称:lightbulb,代码行数:25,代码来源:MyXmppClient.cpp

示例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;
}
开发者ID:jlaine,项目名称:wilink,代码行数:31,代码来源:conversations.cpp

示例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);
}
开发者ID:CoderPaulK,项目名称:hifi,代码行数:33,代码来源:ChatWindow.cpp

示例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);
}
开发者ID:freedbrt,项目名称:qxmpp,代码行数:27,代码来源:tst_qxmppmessage.cpp

示例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);
	}
开发者ID:trett,项目名称:leechcraft,代码行数:12,代码来源:entrybase.cpp


注:本文中的QXmppMessage::setBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。