本文整理汇总了C++中kopete::Message::setDirection方法的典型用法代码示例。如果您正苦于以下问题:C++ Message::setDirection方法的具体用法?C++ Message::setDirection怎么用?C++ Message::setDirection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kopete::Message
的用法示例。
在下文中一共展示了Message::setDirection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newMessage
void
WlmContact::receivedMessage (const QString & message)
{
// Create a Kopete::Message
Kopete::ContactPtrList contactList;
account ();
contactList.append (account ()->myself ());
Kopete::Message newMessage (this, contactList);
newMessage.setPlainBody (message);
newMessage.setDirection (Kopete::Message::Inbound);
// Add it to the manager
manager ()->appendMessage (newMessage);
}
示例2: handleIncomingMessage
void JabberGroupMemberContact::handleIncomingMessage ( const XMPP::Message &message )
{
// message type is always chat in a groupchat
QString viewType = "kopete_chatwindow";
Kopete::Message *newMessage = 0L;
kDebug (JABBER_DEBUG_GLOBAL) << "Received Message Type:" << message.type ();
Kopete::ChatSession *kmm = manager( Kopete::Contact::CanCreate );
if(!kmm)
return;
if ( message.type () != "error" )
{
if (!message.invite().isEmpty())
{
/*QString room=message.invite();
QString originalBody=message.body().isEmpty() ? QString() :
i18n( "The original message is : <i>\" %1 \"</i><br />" , Qt::escape(message.body()));
QString mes=i18n("<qt><i>%1</i> has invited you to join the conference <b>%2</b><br />%3<br />"
"If you want to accept and join, just <b>enter your nickname</b> and press OK.<br />"
"If you want to decline, press Cancel.</qt>",
message.from().full(), room , originalBody);
bool ok=false;
QString futureNewNickName = KInputDialog::getText( i18n( "Invited to a conference - Jabber Plugin" ),
mes, QString() , &ok , (mManager ? dynamic_cast<QWidget*>(mManager->view(false)) : 0) );
if ( !ok || !account()->isConnected() || futureNewNickName.isEmpty() )
return;
XMPP::Jid roomjid(room);
account()->client()->joinGroupChat( roomjid.domain() , roomjid.node() , futureNewNickName );*/
return;
}
else if (message.body().isEmpty())
// Then here could be event notifications
{
if (message.containsEvent ( XMPP::CancelEvent ) || (message.chatState() != XMPP::StateNone && message.chatState() != XMPP::StateComposing) )
mManager->receivedTypingMsg ( this, false );
else if (message.containsEvent ( XMPP::ComposingEvent )|| message.chatState() == XMPP::StateComposing )
mManager->receivedTypingMsg ( this, true );
if (message.containsEvent ( XMPP::DisplayedEvent ) )
{
//mManager->receivedEventNotification ( i18n("Message has been displayed") );
}
else if (message.containsEvent ( XMPP::DeliveredEvent ) )
{
//mManager->receivedEventNotification ( i18n("Message has been delivered") );
mManager->receivedMessageState( message.eventId().toUInt(), Kopete::Message::StateSent );
mSendsDeliveredEvent = true;
}
else if (message.containsEvent ( XMPP::OfflineEvent ) )
{
//mManager->receivedEventNotification( i18n("Message stored on the server, contact offline") );
mManager->receivedMessageState( message.eventId().toUInt(), Kopete::Message::StateSent );
}
else if (message.chatState() == XMPP::StateGone )
{
/*if(mManager->view( Kopete::Contact::CannotCreate ))
{ //show an internal message if the user has not already closed his window
Kopete::Message m=Kopete::Message ( this, mManager->members() );
m.setPlainBody( i18n("%1 has ended his/her participation in the chat session.", metaContact()->displayName()) );
m.setDirection( Kopete::Message::Internal );
m.setImportance(Kopete::Message::Low);
mManager->appendMessage ( m, message.from().resource () );
}*/
}
// XEP-0184: Message Delivery Receipts
if ( message.messageReceipt() == ReceiptReceived )
{
//mManager->receivedEventNotification ( i18n("Message has been delivered") );
mManager->receivedMessageState( message.messageReceiptId().toUInt(), Kopete::Message::StateSent );
mSendsDeliveredEvent = true;
}
}
else
// Then here could be event notification requests
{
mRequestComposingEvent = message.containsEvent ( XMPP::ComposingEvent );
mRequestOfflineEvent = message.containsEvent ( XMPP::OfflineEvent );
mRequestDeliveredEvent = message.containsEvent ( XMPP::DeliveredEvent );
mRequestDisplayedEvent = message.containsEvent ( XMPP::DisplayedEvent);
// XEP-0184: Message Delivery Receipts
mRequestReceiptDelivery = ( message.messageReceipt() == ReceiptRequest );
}
}
/**
* Don't display empty messages, these were most likely just carrying
* event notifications or other payload.
*/
if ( message.body().isEmpty () )
return;
Kopete::ContactPtrList contactList = kmm->members();
//.........这里部分代码省略.........
示例3: testPrimitives
void KopeteMessage_Test::testPrimitives()
{
/**********************************************
* from(), to()
*********************************************/
{
Kopete::Message msg( m_contactFrom, m_contactTo);
Q_ASSERT(msg.from());
Q_ASSERT(!msg.to().isEmpty());
}
/**********************************************
* Direction
*********************************************/
{
Kopete::Message msg;
msg.setDirection( Kopete::Message::Inbound );
QCOMPARE(msg.direction(), Kopete::Message::Inbound);
}
{
Kopete::Message msg;
msg.setDirection( Kopete::Message::Outbound );
QCOMPARE(msg.direction(), Kopete::Message::Outbound);
}
{
Kopete::Message msg;
msg.setDirection( Kopete::Message::Internal );
QCOMPARE(msg.direction(), Kopete::Message::Internal);
}
/**********************************************
* Message Format
*********************************************/
{
Kopete::Message msg;
msg.setPlainBody( QLatin1String("foobar") );
QCOMPARE(msg.format(), Qt::PlainText);
}
{
Kopete::Message msg;
msg.setHtmlBody( QLatin1String("foobar") );
QCOMPARE(msg.format(), Qt::RichText);
}
{
QString m = "foobar";
Kopete::Message msg;
msg.setPlainBody(m);
QCOMPARE(msg.format(), Qt::PlainText);
msg.setHtmlBody(m);
QCOMPARE(msg.format(), Qt::RichText);
}
/**********************************************
* setBody()
*********************************************/
{
QString m = "foobar";
Kopete::Message msg;
msg.setHtmlBody( m );
msg.setPlainBody("NEW");
QCOMPARE(QString("NEW"), msg.plainBody());
msg.setPlainBody("NEW_NEW");
QCOMPARE(msg.plainBody(), QString("NEW_NEW"));
}
{
QString m = "foobar";
Kopete::Message msg;
msg.setPlainBody( m );
msg.setPlainBody("NEW");
QCOMPARE(msg.plainBody(), QString("NEW"));
msg.setHtmlBody("NEW_NEW");
QCOMPARE(msg.plainBody(), QString("NEW_NEW"));
}
{
QString m = "<html><head></head><body foo=\"bar\"> <b>HELLO WORLD</b> </body></html>";
Kopete::Message msg;
msg.setPlainBody( m );
QCOMPARE(msg.plainBody(), m);
msg.setPlainBody("<simple> SIMPLE");
QCOMPARE(msg.plainBody(), QString("<simple> SIMPLE"));
msg.setHtmlBody("<simple>SIMPLE</simple>");
QCOMPARE(msg.plainBody(), QString("SIMPLE") );
QCOMPARE(Kopete::Message::unescape( QString( "<simple>SIMPLE</simple>" ) ), QString("SIMPLE") );
QCOMPARE(Kopete::Message::unescape( QString( "Foo <img src=\"foo.png\" />" ) ), QString("Foo ") );
QCOMPARE(Kopete::Message::unescape( QString( "Foo <img src=\"foo.png\" title=\"Bar\" />" ) ), QString("Foo Bar") );
//.........这里部分代码省略.........