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

kopete/libkopete

Kopete::Contact

Kopete::Contact Class Reference

#include <kopetecontact.h>

Inheritance diagram for Kopete::Contact:

Inheritance graph
[legend]

List of all members.


Detailed Description

Author:
Duncan Mac-Vicar P.

<duncan@kde.org>

Author:
Martijn Klingens <klingens@kde.org>

Olivier Goffart <ogoffart@kde.org>

This class abstracts a generic contact Use it for inserting contacts in the contact list for example.

Definition at line 57 of file kopetecontact.h.


Public Types

enum  CanCreateFlags { CannotCreate = false, CanCreate = true }
enum  Changed { MovedBetweenGroup = 0x01, DisplayNameChanged = 0x02 }

Public Slots

void changeMetaContact ()
virtual KDE_DEPRECATED void deleteContact ()
void execute ()
virtual void sendFile (const KUrl &sourceURL=KUrl(), const QString &fileName=QString(), uint fileSize=0L)
void sendMessage ()
virtual void slotUserInfo ()
void startChat ()
virtual void sync (unsigned int changed=0xFF)

Signals

void contactDestroyed (Kopete::Contact *contact)
void idleStateChanged (Kopete::Contact *contact)
void onlineStatusChanged (Kopete::Contact *contact, const Kopete::OnlineStatus &status, const Kopete::OnlineStatus &oldStatus)

Public Member Functions

Account * account () const
bool canAcceptFiles () const
 Contact (Account *account, const QString &id, MetaContact *parent, const QString &icon=QString())
QString contactId () const
virtual QList< KAction * > * customContextMenuActions (ChatSession *manager)
virtual QList< KAction * > * customContextMenuActions ()
QString formattedIdleTime () const
QString formattedName () const
QString & icon () const
virtual unsigned long int idleTime () const
bool isFileCapable () const
bool isOnline () const
virtual bool isReachable ()
virtual ChatSession * manager (CanCreateFlags canCreate=CannotCreate)=0
MetaContact * metaContact () const
QString nickName () const
OnlineStatus onlineStatus () const
KMenu * popupMenu (ChatSession *manager=0L)
Protocol * protocol () const
virtual void serialize (QMap< QString, QString > &serializedData, QMap< QString, QString > &addressBookData)
void setFileCapable (bool filecap)
void setIcon (const QString &icon)
void setIdleTime (unsigned long int)
void setMetaContact (MetaContact *m)
void setNickName (const QString &name)
void setOnlineStatus (const OnlineStatus &status)
void setPhoto (const QString &photoPath)
void setStatusMessage (const Kopete::StatusMessage &statusMessage)
Kopete::StatusMessage statusMessage () const
QString toolTip () const
 ~Contact ()

Properties

bool canAcceptFiles
QString contactId
bool fileCapable
QString formattedIdleTime
QString formattedName
QString icon
bool isOnline
QString nickName
QString toolTip

Member Enumeration Documentation

enum Kopete::Contact::CanCreateFlags

Enumerator:
CannotCreate 
CanCreate 

Definition at line 277 of file kopetecontact.h.

enum Kopete::Contact::Changed

used in sync()

Enumerator:
MovedBetweenGroup  the contact has been moved between groups
DisplayNameChanged  the displayname of the contact changed

Definition at line 79 of file kopetecontact.h.


Constructor & Destructor Documentation

Kopete::Contact::Contact ( Account *  account,
const QString &  id,
MetaContact *  parent,
const QString &  icon = QString() 
)

Create new contact.

The parent MetaContact must not be NULL

Note:
id is required to be unique per protocol and per account. Across those boundaries ids may occur multiple times. The id is solely for comparing items safely (using pointers is more crash-prone). DO NOT assume anything regarding the id's value! Even if it may look like an ICQ UIN or an MSN passport, this is undefined and may change at any time!
Parameters:
account is the parent account. this constructor automatically register the contact to the account
id is the Contact's unique Id (mostly the user's login)
parent is the parent MetaContact this Contact is part of
icon is an optional icon

Definition at line 86 of file kopetecontact.cpp.

Kopete::Contact::~Contact (  ) 

Definition at line 121 of file kopetecontact.cpp.


Member Function Documentation

Account * Kopete::Contact::account (  )  const

Get the account that this contact belongs to.

Returns:
the Account object for this contact

Definition at line 452 of file kopetecontact.cpp.

bool Kopete::Contact::canAcceptFiles (  )  const

Get whether or not this contact can accept file transfers.

This function checks to make sure that the contact is online as well as capable of sending files.

See also:
isReachable()
Returns:
true if this contact is online and is capable of receiving files
Todo:
have a capabilioties. or move to protocol capabilities

void Kopete::Contact::changeMetaContact (  )  [slot]

Changes the MetaContact that this contact is a part of.

This function is called by the KAction changeMetaContact that is part of the context menu.

Definition at line 295 of file kopetecontact.cpp.

void Kopete::Contact::contactDestroyed ( Kopete::Contact *  contact  )  [signal]

The contact is about to be destroyed.

Called when entering the destructor. Useful for cleanup, since metaContact() is still accessible at this point.

Warning:
this signal is emit in the Contact destructor, so all virtual method are not available

QString Kopete::Contact::contactId (  )  const

Get the unique id that identifies a contact.

Note:
Id is required to be unique per protocol and per account. Across those boundaries ids may occur multiple times. The id is solely for comparing items safely (using pointers is more crash-prone). DO NOT assume anything regarding the id's value! Even if it may look like an ICQ UIN or an MSN passport, this is undefined and may change at any time!
Returns:
The unique id of the contact

QList< KAction * > * Kopete::Contact::customContextMenuActions ( ChatSession *  manager  )  [virtual]

Todo:
What is this function for ?

Definition at line 480 of file kopetecontact.cpp.

QList< KAction * > * Kopete::Contact::customContextMenuActions (  )  [virtual]

Get the set of custom menu items for this contact.

Returns a set of custom menu items for the context menu which is displayed in showContextMenu (private). Protocols should use this to add protocol-specific actions to the popup menu. Kopete take care of the deletion of the action collection. Actions should have the collection as parent.

Returns:
Collection of menu items to be show on the context menu
Todo:
if possible, try to use KXMLGUI

Definition at line 475 of file kopetecontact.cpp.

void Kopete::Contact::deleteContact (  )  [virtual, slot]

Deprecated:
Use DeleteContactTask instead. Method to delete a contact from the contact list, should be implemented by protocol plugin to handle protocol-specific actions required to delete a contact (ie. messages to the server, etc) the default implementation simply call deleteLater()

Definition at line 430 of file kopetecontact.cpp.

void Kopete::Contact::execute (  )  [slot]

The user clicked on the contact, do the default action.

Definition at line 400 of file kopetecontact.cpp.

QString Kopete::Contact::formattedIdleTime (  )  const

Returns a formatted string of idleTime().

Suitable for GUI display

QString Kopete::Contact::formattedName (  )  const

Returns a formatted string of "firstName" and/or "lastName" properties if present.

Suitable for GUI display

QString& Kopete::Contact::icon (  )  const

Returns the name of the icon to use for this contact If null, the protocol icon need to be used.

The icon is not colored, nor has the status icon overloaded

void Kopete::Contact::idleStateChanged ( Kopete::Contact *  contact  )  [signal]

The contact's idle state changed.

You need to emit this signal to update the view. That mean when activity has been noticed

unsigned long int Kopete::Contact::idleTime (  )  const [virtual]

Get the time (in seconds) this contact has been idle It will return the time set in setIdleTime() with an addition of the time since you set this last time.

Returns:
time this contact has been idle for, in seconds
FIXME: Can we make this just 'unsigned long' ? QT Properties can't handle 'unsigned long int'

Definition at line 507 of file kopetecontact.cpp.

bool Kopete::Contact::isFileCapable (  )  const

Get whether or not this contact is capable of file transfers.

See also:
setFileCapable()
Returns:
true if the protocol for this contact is capable of file transfers

false if the protocol for this contact is not capable of file transfers

Todo:
have a capabilioties. or move to protocol capabilities

Definition at line 491 of file kopetecontact.cpp.

bool Kopete::Contact::isOnline (  )  const

Get whether this contact is online.

Returns:
true if the contact is online, false otherwise.

bool Kopete::Contact::isReachable (  )  [virtual]

Get whether this contact can receive messages.

Used in determining if the contact is able to receive messages. This function must be defined by child classes

Returns:
true if the contact can be reached

false if the contact cannot be reached

Definition at line 378 of file kopetecontact.cpp.

virtual ChatSession* Kopete::Contact::manager ( CanCreateFlags  canCreate = CannotCreate  )  [pure virtual]

Returns the primary message manager affiliated with this contact Although a contact can have more than one active message manager (as is the case with MSN at least), only one message manager will ever be the contacts "primary" message manager.

. aka the 1 on 1 chat. This function should always return that instance.

Parameters:
canCreate If a new message manager can be created in addition to any existing managers. Currently, this is only set to true when a chat is initiated by the user by clicking the contact list.

MetaContact * Kopete::Contact::metaContact (  )  const

Get the metacontact for this contact.

Returns:
The MetaContact object for this contact

Definition at line 437 of file kopetecontact.cpp.

QString Kopete::Contact::nickName (  )  const

Convenience method to retrieve the nickName property.

This method will return the contactId if there has been no nickName property set

OnlineStatus Kopete::Contact::onlineStatus (  )  const

Get the online status of the contact.

Returns:
the online status of the contact

Definition at line 130 of file kopetecontact.cpp.

void Kopete::Contact::onlineStatusChanged ( Kopete::Contact *  contact,
const Kopete::OnlineStatus &  status,
const Kopete::OnlineStatus &  oldStatus 
) [signal]

The contact's online status changed.

KMenu * Kopete::Contact::popupMenu ( ChatSession *  manager = 0L  ) 

Get the Context Menu for this contact.

This menu includes generic actions common to each protocol, and action defined in customContextMenuActions()

Definition at line 221 of file kopetecontact.cpp.

Protocol * Kopete::Contact::protocol (  )  const

Get the protocol that the contact belongs to.

simply return account()->protocol()

Returns:
the contact's protocol

Definition at line 447 of file kopetecontact.cpp.

void Kopete::Contact::sendFile ( const KUrl &  sourceURL = KUrl(),
const QString &  fileName = QString(),
uint  fileSize = 0L 
) [virtual, slot]

This is the Contact level slot for sending files.

It should be implemented by all contacts which have the setFileCapable() flag set to true. If the function is called through the GUI, no parameters are sent and they take on default values (the file is chosen with a file open dialog)

Parameters:
sourceURL The actual KUrl of the file you are sending
fileName (Optional) An alternate name for the file - what the receiver will see
fileSize (Optional) Size of the file being sent. Used when sending a nondeterminate file size (such as over asocket

Definition at line 205 of file kopetecontact.cpp.

void Kopete::Contact::sendMessage (  )  [slot]

Pops up an email type window.

Definition at line 393 of file kopetecontact.cpp.

void Kopete::Contact::serialize ( QMap< QString, QString > &  serializedData,
QMap< QString, QString > &  addressBookData 
) [virtual]

Serialize the contact for storage in the contact list.

The provided serializedData contain the contact id in the field "contactId". If you don't like this, or don't want to store these fields at all, you are free to remove them from the list.

Most plugins don't need more than these fields, so they only need to set the address book fields themselves. If you have nothing to save at all you can clear the QMap, an empty map is treated as 'nothing to save'.

The provided addressBookFields QMap contains the index field as marked with Plugin::addAddressBookField() with the contact id as value. If no index field is available the QMap is simply passed as an empty map.

See also:
Protocol::deserializeContact

Definition at line 373 of file kopetecontact.cpp.

void Kopete::Contact::setFileCapable ( bool  filecap  ) 

Set the file transfer capability of this contact.

Parameters:
filecap The new file transfer capability setting
Todo:
have a capabilioties. or move to protocol capabilities

Definition at line 496 of file kopetecontact.cpp.

void Kopete::Contact::setIcon ( const QString &  icon  ) 

Change the icon to use for this contact If you don't want to have the protocol icon as icon for this contact, you may set another icon.

The icon doesn't need to be colored with the account icon as this operation will be performed later.

if you want to go back to the protocol icon, set a null string.

Definition at line 469 of file kopetecontact.cpp.

void Kopete::Contact::setIdleTime ( unsigned long int  t  ) 

Set the current idle time in seconds.

Kopete will automatically calculate the time in idleTime except if you set 0.

FIXME: Can we make this just 'unsigned long' ? QT Properties can't handle 'unsigned long int'

Definition at line 515 of file kopetecontact.cpp.

void Kopete::Contact::setMetaContact ( MetaContact *  m  ) 

Move this contact to a new MetaContact.

This basically reparents the contact and updates the internal data structures. If the old contact is going to be empty, the old contact will be removed.

Parameters:
m The new MetaContact to move this contact to

Definition at line 332 of file kopetecontact.cpp.

void Kopete::Contact::setNickName ( const QString &  name  ) 

Convenience method to set the nickName property to the specified value.

Parameters:
name The nickname to set

Definition at line 752 of file kopetecontact.cpp.

void Kopete::Contact::setOnlineStatus ( const OnlineStatus &  status  ) 

Set the contact's online status.

Definition at line 138 of file kopetecontact.cpp.

void Kopete::Contact::setPhoto ( const QString &  photoPath  ) 

Convience method to set the photo property.

Parameters:
photoPath Local path to the photo

Definition at line 767 of file kopetecontact.cpp.

void Kopete::Contact::setStatusMessage ( const Kopete::StatusMessage &  statusMessage  ) 

Set the contact's status message.

It sets also the "awayMessage" property so you don't need to do it.

Definition at line 176 of file kopetecontact.cpp.

virtual void Kopete::Contact::slotUserInfo (  )  [inline, virtual, slot]

Method to retrieve user information.

Should be implemented by the protocols, and popup some sort of dialog box

reimplement it to show the informlation

Todo:
rename and make it pure virtual

Definition at line 398 of file kopetecontact.h.

void Kopete::Contact::startChat (  )  [slot]

This should typically pop up a KopeteChatWindow.

Definition at line 386 of file kopetecontact.cpp.

Kopete::StatusMessage Kopete::Contact::statusMessage (  )  const

Get the current status message of the contact.

Returns:
the status in a Kopete::StatusMessage.

Definition at line 171 of file kopetecontact.cpp.

void Kopete::Contact::sync ( unsigned int  changed = 0xFF  )  [virtual, slot]

Syncronise the server and the metacontact.

Protocols with server-side contact lists can implement this to sync the server groups with the metaContact groups. Or the server alias if any.

This method is called every time the metacontact has been moved or renamed.

default implementation does nothing

Parameters:
changed is a bitmask of the Changed enum which say why the call to this function is done.

Definition at line 459 of file kopetecontact.cpp.

QString Kopete::Contact::toolTip (  )  const

Get the tooltip for this contact Makes use of formattedName() and formattedIdleTime().

Returns:
an RTF tooltip depending on Kopete::AppearanceSettings settings


Property Documentation

bool Kopete::Contact::canAcceptFiles [read]

Definition at line 67 of file kopetecontact.h.

QString Kopete::Contact::contactId [read]

Definition at line 69 of file kopetecontact.h.

bool Kopete::Contact::fileCapable [read, write]

Definition at line 66 of file kopetecontact.h.

QString Kopete::Contact::formattedIdleTime [read]

Definition at line 64 of file kopetecontact.h.

QString Kopete::Contact::formattedName [read]

Definition at line 63 of file kopetecontact.h.

QString & Kopete::Contact::icon [read, write]

Definition at line 70 of file kopetecontact.h.

bool Kopete::Contact::isOnline [read]

Definition at line 65 of file kopetecontact.h.

QString Kopete::Contact::nickName [read, write]

Definition at line 72 of file kopetecontact.h.

QString Kopete::Contact::toolTip [read]

Definition at line 71 of file kopetecontact.h.


The documentation for this class was generated from the following files:
  • kopetecontact.h
  • kopetecontact.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