本文整理汇总了C++中QXmppMessage::setState方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmppMessage::setState方法的具体用法?C++ QXmppMessage::setState怎么用?C++ QXmppMessage::setState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmppMessage
的用法示例。
在下文中一共展示了QXmppMessage::setState方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: withSentChatState
QXmppMessage JabberChatStateService::withSentChatState(QXmppMessage message)
{
auto jid = Jid::parse(message.to());
auto contact = ContactManager::instance()->byId(account(), jid.bare(), ActionCreateAndAdd);
message.setState(QXmppMessage::State::Active);
contact.addProperty("jabber:sent-chat-state", static_cast<int>(QXmppMessage::State::Active), CustomProperties::NonStorable);
return message;
}
示例4: 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" &&
示例5: setLocalState
void Conversation::setLocalState(int state)
{
if (state != m_localState) {
m_localState = static_cast<QXmppMessage::State>(state);
// notify state change
if (m_client) {
QXmppMessage message;
message.setTo(m_jid);
message.setState(m_localState);
m_client->sendPacket(message);
}
emit localStateChanged(m_localState);
}
}
示例6: 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 );
}
示例7: attentionSend
void MyXmppClient::attentionSend( QString bareJid, QString resource ) {
qDebug() << "MyXmppClient::attentionSend(" << bareJid << ";" << resource << ")";
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 );
xmppMsg.setState( QXmppMessage::None );
xmppMsg.setType( QXmppMessage::Headline );
xmppMsg.setAttentionRequested( true );
xmppClient->sendPacket( xmppMsg );
}