本文整理汇总了C++中QXmppMessage::state方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmppMessage::state方法的具体用法?C++ QXmppMessage::state怎么用?C++ QXmppMessage::state使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmppMessage
的用法示例。
在下文中一共展示了QXmppMessage::state方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleMessage
void RoomHandler::HandleMessage (const QXmppMessage& msg, const QString& nick)
{
const bool existed = Nick2Entry_.contains (nick);
RoomParticipantEntry_ptr entry = GetParticipantEntry (nick, false);
if (msg.type () == QXmppMessage::Chat && !nick.isEmpty ())
{
if (msg.state ())
entry->UpdateChatState (msg.state (), QString ());
if (!msg.body ().isEmpty ())
{
GlooxMessage *message = new GlooxMessage (msg,
Account_->GetClientConnection ().get ());
entry->HandleMessage (message);
}
}
else
{
RoomPublicMessage *message = 0;
if (msg.type () == QXmppMessage::GroupChat &&
!msg.subject ().isEmpty ())
{
Subject_ = msg.subject ();
CLEntry_->HandleSubjectChanged (Subject_);
const QString& string = nick.isEmpty () ?
msg.subject () :
tr ("%1 changed subject to %2")
.arg (nick)
.arg (msg.subject ());
message = new RoomPublicMessage (string,
IMessage::DIn,
CLEntry_,
IMessage::MTEventMessage,
IMessage::MSTOther);
}
else if (!nick.isEmpty ())
{
if (!msg.body ().isEmpty ())
message = new RoomPublicMessage (msg, CLEntry_, entry);
}
else
message = new RoomPublicMessage (msg.body (),
IMessage::DIn,
CLEntry_,
IMessage::MTEventMessage,
IMessage::MSTOther);
if (message)
CLEntry_->HandleMessage (message);
if (!existed)
Nick2Entry_.remove (nick);
}
}
示例2: messageReceivedSlot
void MyXmppClient::messageReceivedSlot( const QXmppMessage &xmppMsg )
{
QString bareJid_from = MyXmppClient::getBareJidByJid( xmppMsg.from() );
QString bareJid_to = MyXmppClient::getBareJidByJid( xmppMsg.to() );
if( xmppMsg.state() == QXmppMessage::Active ) qDebug() << "Msg state is QXmppMessage::Active";
else if( xmppMsg.state() == QXmppMessage::Inactive ) qDebug() << "Msg state is QXmppMessage::Inactive";
else if( xmppMsg.state() == QXmppMessage::Gone ) qDebug() << "Msg state is QXmppMessage::Gone";
else if( xmppMsg.state() == QXmppMessage::Composing ) {
if (bareJid_from != "") {
m_flTyping = true;
emit typingChanged(m_accountId,bareJid_from, true);
qDebug() << bareJid_from << " is composing.";
}
}
else if( xmppMsg.state() == QXmppMessage::Paused ) {
if (bareJid_from != "") {
m_flTyping = false;
emit typingChanged(m_accountId,bareJid_from, false);
qDebug() << bareJid_from << " paused.";
}
} else {
if( xmppMsg.isAttentionRequested() )
{
//qDebug() << "ZZZ: attentionRequest !!! from:" <<xmppMsg.from();
//msgWrapper->attention( bareJid_from, false );
}
qDebug() << "MessageWrapper::messageReceived(): xmppMsg.state():" << xmppMsg.state();
}
if ( !( xmppMsg.body().isEmpty() || xmppMsg.body().isNull() || bareJid_from == m_myjid ) ) {
m_bareJidLastMessage = getBareJidByJid(xmppMsg.from());
m_resourceLastMessage = getResourceByJid(xmppMsg.from());
this->openChat( bareJid_from );
RosterItemModel *item = (RosterItemModel*)cachedRoster->find( bareJid_from );
if( item != 0 ) { int cnt = item->unreadMsg(); item->setUnreadMsg( ++cnt ); } else {
RosterItemModel *itemModel = new RosterItemModel( );
itemModel->setPresence( this->getPicPresence( QXmppPresence::Unavailable ) );
itemModel->setContactName( bareJid_from );
itemModel->setJid( bareJid_from );
itemModel->setUnreadMsg( 1 );
itemModel->setStatusText( "");
cachedRoster->append(itemModel);
itemModel = 0;
delete itemModel;
}
item = 0; delete item;
emit insertMessage(m_accountId,this->getBareJidByJid(xmppMsg.from()),xmppMsg.body(),QDateTime::currentDateTime().toString("dd-MM-yy hh:mm"),0);
}
}
示例3: testBasic
void tst_QXmppMessage::testBasic()
{
QFETCH(QByteArray, xml);
QFETCH(int, type);
QFETCH(QString, body);
QFETCH(QString, subject);
QFETCH(QString, thread);
QXmppMessage message;
parsePacket(message, xml);
QCOMPARE(message.to(), QString("[email protected]/QXmpp"));
QCOMPARE(message.from(), QString("[email protected]/QXmpp"));
QVERIFY(message.extendedAddresses().isEmpty());
QCOMPARE(int(message.type()), type);
QCOMPARE(message.body(), body);
QCOMPARE(message.subject(), subject);
QCOMPARE(message.thread(), thread);
QCOMPARE(message.state(), QXmppMessage::None);
QCOMPARE(message.isAttentionRequested(), false);
QCOMPARE(message.isReceiptRequested(), false);
QCOMPARE(message.hasForwarded(), false);
QCOMPARE(message.receiptId(), QString());
QCOMPARE(message.xhtml(), QString());
serializePacket(message, xml);
}
示例4: slotMessageReceived
void CFrmGroupChat::slotMessageReceived(const QXmppMessage &message)
{
LOG_MODEL_DEBUG("Group chat", "CFrmGroupChat::slotMessageReceived:type:%d;state:%d;from:%s;to:%s;body:%s",
message.type(),
message.state(), //消息的状态 0:消息内容,其它值表示这个消息的状态
qPrintable(message.from()),
qPrintable(message.to()),
qPrintable(message.body())
);
if(QXmppUtils::jidToBareJid(message.from()) != QXmppUtils::jidToBareJid(m_pRoom->jid()))
{
LOG_MODEL_DEBUG("Group chat", "the room is %s, from %s received",
m_pRoom->jid().toStdString().c_str(),
message.from().toStdString().c_str());
return;
}
if(message.body().isEmpty())
return;
QString nick;
nick = QXmppUtils::jidToResource(message.from());
if(nick.isEmpty())
nick = tr("System");
AppendMessageToList(message.body(), nick);
}
示例5: testState
void tst_QXmppMessage::testState()
{
QFETCH(QByteArray, xml);
QFETCH(int, state);
QXmppMessage message;
parsePacket(message, xml);
QCOMPARE(int(message.state()), state);
serializePacket(message, xml);
}
示例6: slotClientMessageReceived
void CFrmUserList::slotClientMessageReceived(const QXmppMessage &message)
{
LOG_MODEL_DEBUG("Roster", "CFrmUserList::slotClientMessageReceived:type:%d;state:%d;from:%s;to:%s;body:%s",
message.type(),
message.state(), //消息的状态 0:消息内容,其它值表示这个消息的状态
qPrintable(message.from()),
qPrintable(message.to()),
qPrintable(message.body())
);
m_LastUser = message.from();//保存接收到最后消息的用户
QMap<QString, CRoster*>::iterator it;
it = m_Rosters.find(QXmppUtils::jidToBareJid(message.from()));
if(m_Rosters.end() != it)
{
if(QXmppMessage::None == message.state())
{
it.value()->AppendMessage(message.body());
}
//TODO:消息输入状态显示
}
}
示例7: testMessageFull
void TestPackets::testMessageFull()
{
const QByteArray xml(
"<message to=\"[email protected]/QXmpp\" from=\"[email protected]/QXmpp\" type=\"normal\">"
"<subject>test subject</subject>"
"<body>test body & stuff</body>"
"<thread>test thread</thread>"
"<composing xmlns=\"http://jabber.org/protocol/chatstates\"/>"
"</message>");
QXmppMessage message;
parsePacket(message, xml);
QCOMPARE(message.to(), QString("[email protected]/QXmpp"));
QCOMPARE(message.from(), QString("[email protected]/QXmpp"));
QCOMPARE(message.type(), QXmppMessage::Normal);
QCOMPARE(message.body(), QString("test body & stuff"));
QCOMPARE(message.subject(), QString("test subject"));
QCOMPARE(message.thread(), QString("test thread"));
QCOMPARE(message.state(), QXmppMessage::Composing);
serializePacket(message, xml);
}
示例8: HandleMessage
void RoomHandler::HandleMessage (const QXmppMessage& msg, const QString& nick)
{
Q_FOREACH (const QXmppElement& elem, msg.extensions ())
{
const QString& xmlns = elem.attribute ("xmlns");
if (xmlns == ns_data)
{
QXmppDataForm *df = new QXmppDataForm ();
df->parse (XooxUtil::XmppElem2DomElem (elem));
if (df->isNull ())
{
qWarning () << Q_FUNC_INFO
<< "unable to parse form from"
<< msg.from ();
delete df;
}
else
emit gotPendingForm (df, msg.from ());
}
else
qWarning () << Q_FUNC_INFO
<< "unhandled <x> element"
<< xmlns;
}
const bool existed = Nick2Entry_.contains (nick);
RoomParticipantEntry_ptr entry = GetParticipantEntry (nick, false);
if (msg.type () == QXmppMessage::Chat && !nick.isEmpty ())
{
if (msg.isAttentionRequested ())
entry->HandleAttentionMessage (msg);
if (msg.state ())
entry->UpdateChatState (msg.state (), QString ());
if (!msg.body ().isEmpty ())
{
GlooxMessage *message = new GlooxMessage (msg,
Account_->GetClientConnection ().get ());
entry->HandleMessage (message);
}
}
else
{
RoomPublicMessage *message = 0;
if (msg.type () == QXmppMessage::GroupChat &&
!msg.subject ().isEmpty ())
{
Subject_ = msg.subject ();
CLEntry_->HandleSubjectChanged (Subject_);
const QString& string = nick.isEmpty () ?
msg.subject () :
tr ("%1 changed subject to %2")
.arg (nick)
.arg (msg.subject ());
message = new RoomPublicMessage (string,
IMessage::DIn,
CLEntry_,
IMessage::MTEventMessage,
IMessage::MSTOther);
}
else if (!nick.isEmpty ())
{
if (!msg.body ().isEmpty ())
message = new RoomPublicMessage (msg, CLEntry_, entry);
}
else if (!msg.body ().isEmpty ())
message = new RoomPublicMessage (msg.body (),
IMessage::DIn,
CLEntry_,
IMessage::MTEventMessage,
IMessage::MSTOther);
if (message)
CLEntry_->HandleMessage (message);
if (!existed)
Nick2Entry_.remove (nick);
}
}