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

kopete/libkopete

  • Kopete
  • Message
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Kopete::Message Class Reference

#include <kopetemessage.h>

Public Types

enum  MessageDirection { Inbound = 0, Outbound = 1, Internal = 2 }
 
enum  MessageImportance { Low = 0, Normal = 1, Highlight = 2 }
 
enum  MessageState { StateUnknown = 0, StateSending = 1, StateSent = 2, StateError = 3 }
 
enum  MessageType { TypeNormal, TypeAction, TypeFileTransferRequest, TypeVoiceClipRequest }
 

Public Member Functions

 Message ()
 
 Message (const Contact *fromKC, const Contact *toKC)
 
 Message (const Contact *fromKC, const QList< Contact * > &contacts)
 
 Message (const Message &other)
 
 ~Message ()
 
void addClass (const QString &classe)
 
QColor backgroundColor () const
 
const QTextDocument * body () const
 
QStringList classes () const
 
bool delayed () const
 
MessageDirection direction () const
 
QString escapedBody () const
 
QString fileName () const
 
QPixmap filePreview () const
 
unsigned long fileSize () const
 
bool fileTransferDisabled () const
 
QFont font () const
 
QColor foregroundColor () const
 
Qt::TextFormat format () const
 
const Contact * from () const
 
QString getHtmlStyleAttribute () const
 
uint id () const
 
MessageImportance importance () const
 
bool isRightToLeft () const
 
ChatSession * manager () const
 
Message & operator= (const Message &other)
 
QString parsedBody () const
 
QString plainBody () const
 
const QStringList regexpPatterns ()
 
QString requestedPlugin () const
 
void setBackgroundColor (const QColor &color)
 
void KDE_DEPRECATED setBackgroundOverride (bool enable)
 
void setBody (const QTextDocument *body)
 
void setClasses (const QStringList &classes)
 
void setDelayed (bool delay)
 
void setDirection (MessageDirection direction)
 
void setFileName (const QString &fileName)
 
void setFilePreview (const QPixmap &preview)
 
void setFileSize (unsigned long size)
 
void setFileTransferDisabled (bool disabled)
 
void setFont (const QFont &font)
 
void setForcedHtmlBody (const QString &body)
 
void setForegroundColor (const QColor &color)
 
void KDE_DEPRECATED setForegroundOverride (bool enable)
 
void setFormattingOverride (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 KDE_DEPRECATED setRichTextOverride (bool enable)
 
void setState (MessageState state)
 
void setSubject (const QString &subject)
 
void setTimestamp (const QDateTime &timestamp)
 
void setType (MessageType type)
 
MessageState state () const
 
QString subject () const
 
QDateTime timestamp () const
 
QList< Contact * > to () const
 
MessageType type () const
 

Static Public Member Functions

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

Detailed Description

Representation of a message in Kopete.

Author
Martijn Klingens kling.nosp@m.ens@.nosp@m.kde.o.nosp@m.rg
Olivier Goffart ogoff.nosp@m.art@.nosp@m.kde.o.nosp@m.rg
Charles Connell charl.nosp@m.es@c.nosp@m.onnel.nosp@m.ls.o.nosp@m.rg
Michaƫl Larouche larou.nosp@m.che@.nosp@m.kde.o.nosp@m.rg

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.setSubject( QString("Kopete API documentation thread") );
richTextMessage.setHtmlBody( QString("<b>A bold text</b>") );

Definition at line 82 of file kopetemessage.h.

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 88 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 109 of file kopetemessage.h.

enum Kopete::Message::MessageState
Enumerator
StateUnknown 

state of message isn't known (e.g. protocol doesn't support message acknowledgment)

StateSending 

message was sent but not yet delivered.

StateSent 

message was delivered

StateError 

message has not been delivered

Definition at line 116 of file kopetemessage.h.

enum Kopete::Message::MessageType

Specifies the type of the message.

Enumerator
TypeNormal 

A typical message.

TypeAction 

An IRC-style action.

TypeFileTransferRequest 

A incoming file transfer request message.

TypeVoiceClipRequest 

A incoming voice clip message.

Definition at line 98 of file kopetemessage.h.

Constructor & Destructor Documentation

Kopete::Message::Message ( )
explicit

Constructs a new empty message.

Definition at line 149 of file kopetemessage.cpp.

Kopete::Message::~Message ( )

Deref and clean private object if refcount == 0.

Definition at line 182 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
fromKCContact who send the message
toKCContact which the message is destined.

Definition at line 154 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
fromKCContact who send the message
contactsList of Contact to send the message

Definition at line 164 of file kopetemessage.cpp.

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

Copy constructor.

Just adds a reference, doesn't actually copy.

Definition at line 171 of file kopetemessage.cpp.

Member Function Documentation

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

Add a class.

See also
classes
Parameters
classclass to add

Definition at line 801 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 544 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 569 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 796 of file kopetemessage.cpp.

bool Kopete::Message::delayed ( ) const

Accessor method for the "delayed" attribute of the message.

Returns
true if the message was delayed (for example because it has been stored on a server while the intended recipient was offline or because the message is contained in the history of a group chat room).

Definition at line 813 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 579 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 350 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 373 of file kopetemessage.cpp.

QString Kopete::Message::fileName ( ) const

Accessor method for the file name of incoming file transfer.

Returns
file name of incoming file transfer

Definition at line 678 of file kopetemessage.cpp.

QPixmap Kopete::Message::filePreview ( ) const

Accessor method for the file preview icon.

Returns
file preview icon

Definition at line 704 of file kopetemessage.cpp.

unsigned long Kopete::Message::fileSize ( ) const

Accessor method for the file transfer size.

Returns
file transfer size

Definition at line 691 of file kopetemessage.cpp.

bool Kopete::Message::fileTransferDisabled ( ) const

Accessor method for the file transfer state.

Returns
if file transfer request should be enable or disable

Definition at line 665 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 554 of file kopetemessage.cpp.

QColor Kopete::Message::foregroundColor ( ) const

Accessor method for the foreground color.

Returns
The message's foreground color

Definition at line 539 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 574 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 509 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 614 of file kopetemessage.cpp.

uint Kopete::Message::id ( ) const

Get unique message id.

Returns
message id

Definition at line 186 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 589 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 549 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 604 of file kopetemessage.cpp.

uint Kopete::Message::nextId ( )
static

Get next unique message id.

Returns
next id

Definition at line 191 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 176 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 399 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 365 of file kopetemessage.cpp.

const QStringList Kopete::Message::regexpPatterns ( )

returns QStringList with regexp patterns will be used to look for links in the message

Definition at line 419 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 529 of file kopetemessage.cpp.

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

Sets the background color for the message.

See also
backgroundColor
Parameters
colorThe color

Definition at line 223 of file kopetemessage.cpp.

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

Does nothing.

Definition at line 196 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
bodyThe body

Definition at line 265 of file kopetemessage.cpp.

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

Set the classes.

See also
classes
Parameters
classesThe new classes

Definition at line 806 of file kopetemessage.cpp.

void Kopete::Message::setDelayed ( bool  delay)

Set the "delayed" attribute of the message.

Parameters
delaywhether the message was delayed, see delayed()

Definition at line 818 of file kopetemessage.cpp.

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

Set the message direction.

Parameters
directionThe message direction
See also
MessageDirection

Definition at line 584 of file kopetemessage.cpp.

void Kopete::Message::setFileName ( const QString &  fileName)

Set file name of incoming file transfer.

Parameters
fileNamefile name

Definition at line 670 of file kopetemessage.cpp.

void Kopete::Message::setFilePreview ( const QPixmap &  preview)

Set file preview icon for file transfer.

Parameters
previewfile preview icon

Definition at line 696 of file kopetemessage.cpp.

void Kopete::Message::setFileSize ( unsigned long  size)

Set file transfer size.

Parameters
sizefile transfer size

Definition at line 683 of file kopetemessage.cpp.

void Kopete::Message::setFileTransferDisabled ( bool  disabled)

Set the state of incoming file transfer.

Parameters
disabledflag to indicate if the file transfer request should be enabled or disabled.

Definition at line 657 of file kopetemessage.cpp.

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

Sets the font for the message.

See also
font
Parameters
fontThe font

Definition at line 228 of file kopetemessage.cpp.

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

Sets the body of the message, which is used even if formatting is overridden.

Parameters
bodyThe body, interpreted as HTML

Definition at line 243 of file kopetemessage.cpp.

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

Sets the foreground color for the message.

See also
foregroundColor
Parameters
colorThe color

Definition at line 218 of file kopetemessage.cpp.

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

Does nothing.

Definition at line 201 of file kopetemessage.cpp.

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

Ignores peer's formatting.

Definition at line 211 of file kopetemessage.cpp.

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

Sets the body of the message.

Parameters
bodyThe body, interpreted as HTML

Definition at line 238 of file kopetemessage.cpp.

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

Set the importance.

See also
importance and
MessageImportance
Parameters
importanceThe message importance to set

Definition at line 280 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
managerThe chat session

Definition at line 609 of file kopetemessage.cpp.

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

Sets the body of the message.

Parameters
bodyThe body, intpreted as plain text

Definition at line 233 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
requesedPluginView plugin name

Definition at line 534 of file kopetemessage.cpp.

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

Does nothing.

Definition at line 206 of file kopetemessage.cpp.

void Kopete::Message::setState ( MessageState  state)

Set the state of message.

See also
MessageState
Parameters
stateThe message state to set

Definition at line 599 of file kopetemessage.cpp.

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

Set message subject.

Parameters
subjectMessage's subject

Definition at line 564 of file kopetemessage.cpp.

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

Set the message timestamp.

Parameters
timestamptimestamp as QDateTime. By default the current date and time.

Definition at line 504 of file kopetemessage.cpp.

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

Set message type.

Parameters
typeThe type of the message
See also
MessageType

Definition at line 524 of file kopetemessage.cpp.

Message::MessageState Kopete::Message::state ( ) const

Accessor method for the state.

Returns
The message state (unknown/sending/sent/error)

Definition at line 594 of file kopetemessage.cpp.

QString Kopete::Message::subject ( ) const

Accessor method for the subject of the message.

Returns
The message subject

Definition at line 559 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 499 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 514 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 519 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 285 of file kopetemessage.cpp.


The documentation for this class was generated from the following files:
  • kopetemessage.h
  • kopetemessage.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:52 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/libkopete

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

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal