• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdenetwork
  • Sitemap
  • Contact Us
 

kopete/libkopete

Kopete::Message

Kopete::Message Class Reference

#include <kopetemessage.h>

List of all members.


Detailed Description

Representation of a message in Kopete.

Author:
Martijn Klingens <klingens@kde.org>

Olivier Goffart <ogoffart@kde.org>

Charles Connell <charles@connells.org>

Michaƫl Larouche <larouche@kde.org>

Message represents any kind of messages shown on a chat view. The message may contain a simple plain text string, or a rich text HTML message. Also, Message can use a QTextDocument to structure the message.

Message in plain text can however have a color or a specific font. You can set color with setForegroundColor() and setBackgroundColor() and change the font with setFont()

Message have a direction from where the message come from. By default, the direction is Internal but it is strongly advised to set the direction explicitly.

Creating a plain text message

Kopete::Message newMessage(sourceContact, destionationContact);
newMessage.setPlainBody( QString("A plain text message") );
newMessage.setDirection( Kopete::Message::Inbound );

Creating a complete rich text message

Kopete::Message richTextMessage(sourceContact, destinationContactList);
richTextMessage.setTimestamp( QDateTime::currentDateTime() );
richTextMessage.setDirection( Kopete::Message::Outbound );
richTextMessage.setSubjet( QString("Kopete API documentation thread") );
richTextMessage.setHtmlBody( QString("<b>A bold text</b>") );

Definition at line 80 of file kopetemessage.h.


Public Types

enum  MessageDirection { Inbound = 0, Outbound = 1, Internal = 2 }
enum  MessageImportance { Low = 0, Normal = 1, Highlight = 2 }
enum  MessageType { TypeNormal, TypeAction }

Public Member Functions

void addClass (const QString &classe)
QColor backgroundColor () const
const QTextDocument * body () const
QStringList classes () const
MessageDirection direction () const
QString escapedBody () const
QFont font () const
QColor foregroundColor () const
Qt::TextFormat format () const
const Contact * from () const
QString getHtmlStyleAttribute () const
MessageImportance importance () const
bool isRightToLeft () const
ChatSession * manager () const
 Message (const Message &other)
 Message (const Contact *fromKC, const QList< Contact * > &contacts)
 Message (const Contact *fromKC, const Contact *toKC)
 Message ()
Message & operator= (const Message &other)
QString parsedBody () const
QString plainBody () const
QString requestedPlugin () const
void setBackgroundColor (const QColor &color)
void setBackgroundOverride (bool enable)
void setBody (const QTextDocument *body)
void setClasses (const QStringList &classes)
void setDirection (MessageDirection direction)
void setFont (const QFont &font)
void setForegroundColor (const QColor &color)
void setForegroundOverride (bool enable)
void setHtmlBody (const QString &body)
void setImportance (MessageImportance importance)
void setManager (ChatSession *manager)
void setPlainBody (const QString &body)
void setRequestedPlugin (const QString &requestedPlugin)
void setRichTextOverride (bool enable)
void setSubject (const QString &subject)
void setTimestamp (const QDateTime &timestamp)
void setType (MessageType type)
QString subject () const
QDateTime timestamp () const
QList< Contact * > to () const
MessageType type () const
 ~Message ()

Static Public Member Functions

static QString escape (const QString &)
static QString unescape (const QString &xml)

Member Enumeration Documentation

enum Kopete::Message::MessageDirection

Direction of a message.

Enumerator:
Inbound  Message is from the chat partner.
Outbound  Message sent by the user.
Internal  (Default) Message which are not sent via the network. This is just a notification a plugin can show in a chat view

Definition at line 86 of file kopetemessage.h.

enum Kopete::Message::MessageImportance

Specifies the type of notification that will be sent with this message.

Enumerator:
Low  almost no notifications. automatically used in groupChat
Normal  Default notification, for normal message.
Highlight  Highlight notification, for most important messages, which require particular attentions.

Definition at line 105 of file kopetemessage.h.

enum Kopete::Message::MessageType

Specifies the type of the message.

Enumerator:
TypeNormal  A typical message.
TypeAction  An IRC-style action.

Definition at line 96 of file kopetemessage.h.


Constructor & Destructor Documentation

Kopete::Message::Message (  )  [explicit]

Constructs a new empty message.

Definition at line 117 of file kopetemessage.cpp.

Kopete::Message::~Message (  ) 

Deref and clean private object if refcount == 0.

Definition at line 150 of file kopetemessage.cpp.

Kopete::Message::Message ( const Contact *  fromKC,
const Contact *  toKC 
) [explicit]

Constructs a new message with a from and to contact.

This constructor is a convience of the constructor who take a list of contacts for destination

Parameters:
fromKC Contact who send the message
toKC Contact which the message is destined.

Definition at line 122 of file kopetemessage.cpp.

Kopete::Message::Message ( const Contact *  fromKC,
const QList< Contact * > &  contacts 
) [explicit]

Constructs a new message with many contacts as the destination.

Parameters:
fromKC Contact who send the message
contacts List of Contact to send the message

Definition at line 132 of file kopetemessage.cpp.

Kopete::Message::Message ( const Message &  other  ) 

Copy constructor.

Just adds a reference, doesn't actually copy.

Definition at line 139 of file kopetemessage.cpp.


Member Function Documentation

void Kopete::Message::addClass ( const QString &  classe  ) 

Add a class.

See also:
classes
Parameters:
class class to add

Definition at line 652 of file kopetemessage.cpp.

QColor Kopete::Message::backgroundColor (  )  const

Accessor method for the background color of the message.

Returns:
The message's background color

Definition at line 462 of file kopetemessage.cpp.

const QTextDocument * Kopete::Message::body (  )  const

Accessor method for the body of the message This is used internaly, to modify it make a copy of it with QTextDocument::clone().

Returns:
The message body

Definition at line 487 of file kopetemessage.cpp.

QStringList Kopete::Message::classes (  )  const

Returns:
The list of classes Class are used to give different notification on a message.

They are also used in the chatwindow as an HTML class

Definition at line 647 of file kopetemessage.cpp.

Message::MessageDirection Kopete::Message::direction (  )  const

Accessor method for the direction of the message.

Returns:
The message direction

Definition at line 497 of file kopetemessage.cpp.

QString Kopete::Message::escape ( const QString &  text  )  [static]

Transform a plaintext message into HTML.

it escape main entity like > < add some <br /> or &nbsp;

Definition at line 289 of file kopetemessage.cpp.

QString Kopete::Message::escapedBody (  )  const

Get the message body as escaped (X)HTML format.

That means every HTML special char (>, <, &, ...) is escaped to the HTML entity (&lt;, &gt;, ...) and newlines (\n) are converted to <br /> Just because you set an HTML body doesn't mean you'll get the same string back here, but it will be equivalent in meaning

Returns:
The message body as escaped text

Definition at line 309 of file kopetemessage.cpp.

QFont Kopete::Message::font (  )  const

Accessor method for the font of the message.

Returns:
The message's font

Definition at line 472 of file kopetemessage.cpp.

QColor Kopete::Message::foregroundColor (  )  const

Accessor method for the foreground color.

Returns:
The message's foreground color

Definition at line 457 of file kopetemessage.cpp.

Qt::TextFormat Kopete::Message::format (  )  const

Accessor method for the format of the message.

Returns:
The message format

Definition at line 492 of file kopetemessage.cpp.

const Contact * Kopete::Message::from (  )  const

Accessor method for the Contact that sent this message.

Returns:
The Contact who sent this message

Definition at line 427 of file kopetemessage.cpp.

QString Kopete::Message::getHtmlStyleAttribute (  )  const

Return HTML style attribute for this message.

Returns:
A string formatted like this: "style=attr"

Definition at line 522 of file kopetemessage.cpp.

Message::MessageImportance Kopete::Message::importance (  )  const

Accessor method for the importance.

See also:
setImportance
Returns:
The message importance (low/normal/highlight)

Definition at line 507 of file kopetemessage.cpp.

bool Kopete::Message::isRightToLeft (  )  const

Accesssor method for the direction of the text based on what language it is in.

Returns:
The message text's direction

Definition at line 467 of file kopetemessage.cpp.

ChatSession * Kopete::Message::manager (  )  const

Get the related message manager.

If it is not set, returns 0L.

The ChatSession is only set if the message is already passed by the manager. We should trust this only in aboutToSend/aboutToReceive signals

Definition at line 512 of file kopetemessage.cpp.

Message & Kopete::Message::operator= ( const Message &  other  ) 

Assignment operator Just like the copy constructor it just refs and doesn't copy.

Definition at line 144 of file kopetemessage.cpp.

QString Kopete::Message::parsedBody (  )  const

Get the message body as parsed HTML with Emoticons, and URL parsed This should be ready to be shown in the chatwindow.

Returns:
The HTML and Emoticon parsed message body

Definition at line 335 of file kopetemessage.cpp.

QString Kopete::Message::plainBody (  )  const

Get the message body back as plain text.

Returns:
The message body as plain text

Definition at line 304 of file kopetemessage.cpp.

QString Kopete::Message::requestedPlugin (  )  const

Accessor method for the preferred plugin If null, Kopete will use the user's preferred plugin.

Returns:
The preferred plugin

Definition at line 447 of file kopetemessage.cpp.

void Kopete::Message::setBackgroundColor ( const QColor &  color  ) 

Sets the background color for the message.

See also:
backgroundColor
Parameters:
color The color

Definition at line 174 of file kopetemessage.cpp.

void Kopete::Message::setBackgroundOverride ( bool  enable  ) 

Enables the use of a background for a message.

Parameters:
enable A flag to indicate if the background should be enabled or disabled.

Definition at line 154 of file kopetemessage.cpp.

void Kopete::Message::setBody ( const QTextDocument *  body  ) 

Sets the body of the message The format is changed to RichText automatically.

Parameters:
body The body

Definition at line 205 of file kopetemessage.cpp.

void Kopete::Message::setClasses ( const QStringList &  classes  ) 

Set the classes.

See also:
classes
Parameters:
classes The new classes

Definition at line 657 of file kopetemessage.cpp.

void Kopete::Message::setDirection ( MessageDirection  direction  ) 

Set the message direction.

Parameters:
direction The message direction
See also:
MessageDirection

Definition at line 502 of file kopetemessage.cpp.

void Kopete::Message::setFont ( const QFont &  font  ) 

Sets the font for the message.

See also:
font
Parameters:
font The font

Definition at line 179 of file kopetemessage.cpp.

void Kopete::Message::setForegroundColor ( const QColor &  color  ) 

Sets the foreground color for the message.

See also:
foregroundColor
Parameters:
color The color

Definition at line 169 of file kopetemessage.cpp.

void Kopete::Message::setForegroundOverride ( bool  enable  ) 

Enables the use of a foreground for a message.

Parameters:
enable A flag to indicate if the foreground should be enabled or disabled.

Definition at line 159 of file kopetemessage.cpp.

void Kopete::Message::setHtmlBody ( const QString &  body  ) 

Sets the body of the message.

Parameters:
body The body, interpreted as HTML

Definition at line 189 of file kopetemessage.cpp.

void Kopete::Message::setImportance ( Message::MessageImportance  i  ) 

Set the importance.

See also:
importance and

MessageImportance

Parameters:
importance The message importance to set

Definition at line 219 of file kopetemessage.cpp.

void Kopete::Message::setManager ( ChatSession *  manager  ) 

Set the messagemanager for this message.

Should be only used by the manager itself.

See also:
manager
Parameters:
manager The chat session

Definition at line 517 of file kopetemessage.cpp.

void Kopete::Message::setPlainBody ( const QString &  body  ) 

Sets the body of the message.

Parameters:
body The body, intpreted as plain text

Definition at line 184 of file kopetemessage.cpp.

void Kopete::Message::setRequestedPlugin ( const QString &  requestedPlugin  ) 

Set a view plugin which will display the message.

This is used mostly by Jabber plugin to select between the email window or the chat window depending of the type of message.

Parameters:
requesedPlugin View plugin name

Definition at line 452 of file kopetemessage.cpp.

void Kopete::Message::setRichTextOverride ( bool  enable  ) 

Enables the use of a RTF formatting for a message.

Parameters:
enable A flag to indicate if the RTF formatting should be enabled or disabled.

Definition at line 164 of file kopetemessage.cpp.

void Kopete::Message::setSubject ( const QString &  subject  ) 

Set message subject.

Parameters:
subject Message's subject

Definition at line 482 of file kopetemessage.cpp.

void Kopete::Message::setTimestamp ( const QDateTime &  timestamp  ) 

Set the message timestamp.

Parameters:
timestamp timestamp as QDateTime. By default the current date and time.

Definition at line 422 of file kopetemessage.cpp.

void Kopete::Message::setType ( MessageType  type  ) 

Set message type.

Parameters:
type The type of the message
See also:
MessageType

Definition at line 442 of file kopetemessage.cpp.

QString Kopete::Message::subject (  )  const

Accessor method for the subject of the message.

Returns:
The message subject

Definition at line 477 of file kopetemessage.cpp.

QDateTime Kopete::Message::timestamp (  )  const

Accessor method for the timestamp of the message.

Returns:
The message's timestamp

Definition at line 417 of file kopetemessage.cpp.

QList< Contact * > Kopete::Message::to (  )  const

Accessor method for the Contacts that this message was sent to.

Returns:
Pointer list of the Contacts this message was sent to

Definition at line 432 of file kopetemessage.cpp.

Message::MessageType Kopete::Message::type (  )  const

Accessor method for the message type.

Returns:
The type of the message
See also:
MessageType

Definition at line 437 of file kopetemessage.cpp.

QString Kopete::Message::unescape ( const QString &  xml  )  [static]

Unescapes a string, removing XML entity references and returns a plain text.

Note that this method is *VERY* expensive when called on rich text bodies, use with care!

Definition at line 224 of file kopetemessage.cpp.


The documentation for this class was generated from the following files:
  • kopetemessage.h
  • kopetemessage.cpp

kopete/libkopete

Skip menu "kopete/libkopete"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdenetwork

Skip menu "kdenetwork"
  • kget
  • kopete
  •   kopete
  •   libkopete
  •       libpapillon
  • krfb
Generated for kdenetwork by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal