Yate
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends
ClientContact Class Reference

A client contact. More...

#include <yatecbase.h>

Inheritance diagram for ClientContact:
RefObject GenObject MucRoom

List of all members.

Public Member Functions

 ClientContact (ClientAccount *owner, const char *id, const char *name=0, const char *uri=0)
 ClientContact (ClientAccount *owner, const NamedList &params, const char *id=0, const char *uri=0)
ClientAccountaccount ()
const StringaccountName () const
const URIuri () const
void setUri (const char *u)
ObjListresources ()
bool online () const
void setOnline (bool on)
ObjListgroups ()
bool local (bool defVal=false) const
void setLocal (bool on)
bool remote (bool defVal=false) const
void setRemote (bool on)
void setDockedChat (bool on)
void getContactSection (String &buf)
virtual const StringtoString () const
virtual MucRoommucRoom ()
StringbuildInstanceId (String &dest, const String &inst=String::empty())
void buildIdHash (String &buf, const String &prefix=String::empty())
bool isChatWnd (Window *wnd)
bool hasChat ()
virtual void flashChat (bool on=true)
virtual bool sendChat (const char *body, const String &res=String::empty(), const String &type=String::empty(), const char *state="active")
virtual void getChatInput (String &text, const String &name="message")
virtual void setChatInput (const String &text=String::empty(), const String &name="message")
virtual void getChatHistory (String &text, bool richText=false, const String &name="history")
virtual void setChatHistory (const String &text, bool richText=false, const String &name="history")
virtual void addChatHistory (const String &what, NamedList *&params, const String &name="history")
virtual void getChatProperty (const String &name, const String &prop, String &value)
virtual void setChatProperty (const String &name, const String &prop, const String &value)
bool isChatVisible ()
virtual bool showChat (bool visible, bool active=false)
WindowgetChatWnd ()
virtual void createChatWindow (bool force=false, const char *name=0)
virtual void updateChatWindow (const NamedList &params, const char *title=0, const char *icon=0)
virtual bool isChatActive ()
void destroyChatWindow ()
virtual StringfindGroup (const String &group)
virtual bool appendGroup (const String &group)
virtual bool removeGroup (const String &group)
virtual bool setGroups (const NamedList &list, const String &param)
virtual ClientResourcestatus (bool ref=false)
virtual ClientResourcefindResource (const String &id, bool ref=false)
virtual ClientResourcefindAudioResource (bool ref=false)
virtual ClientResourcefindFileTransferResource (bool ref=false)
virtual ClientResourceappendResource (const String &id)
virtual bool insertResource (ClientResource *res)
virtual bool removeResource (const String &id)

Static Public Member Functions

static StringbuildContactId (String &dest, const String &account, const String &contact)
static void splitContactId (const String &src, String &account)
static void splitContactInstanceId (const String &src, String &account, String &contact, String *instance=0)

Public Attributes

String m_name
String m_subscription
NamedList m_params

Static Public Attributes

static String s_chatPrefix
static String s_dockedChatWnd
static String s_dockedChatWidget
static String s_mucsWnd
static String s_chatInput

Protected Member Functions

 ClientContact (ClientAccount *owner, const char *id, bool mucRoom)
void removeFromOwner ()
virtual void destroyed ()

Protected Attributes

ClientAccountm_owner
bool m_online
String m_id
URI m_uri
ObjList m_resources
ObjList m_groups
bool m_dockedChat
String m_chatWndName

Friends

class ClientAccount

Detailed Description

A client contact.

A client contact The contact is using the owner's mutex to lock it's operations


Constructor & Destructor Documentation

ClientContact ( ClientAccount owner,
const char *  id,
const char *  name = 0,
const char *  uri = 0 
) [explicit]

Constructor. Append itself to the owner's list

Parameters:
ownerThe contact's owner
idThe contact's id
nameOptional display name. Defaults to the id's value if 0
uriOptional contact URI
ClientContact ( ClientAccount owner,
const NamedList params,
const char *  id = 0,
const char *  uri = 0 
) [explicit]

Constructor. Build a contact from a list of parameters. Append itself to the owner's list

Parameters:
ownerThe contact's owner
paramsThe list of parameters used to build this contact
idOptional contact id
uriOptional contact URI
ClientContact ( ClientAccount owner,
const char *  id,
bool  mucRoom 
) [explicit, protected]

Constructor. Append itself to the owner's list

Parameters:
ownerThe contact's owner
idThe contact's id
mucRoomTrue if this contact is a MUC room

Member Function Documentation

ClientAccount* account ( ) [inline]

Get this contact's account

Returns:
This contact's account
const String& accountName ( ) const [inline]

Get this contact account's name (id)

Returns:
This contact account name (id) or an empty string if none

References String::empty(), and String::toString().

virtual void addChatHistory ( const String what,
NamedList *&  params,
const String name = "history" 
) [virtual]

Add an entry to chat history

Parameters:
whatItem to add (chat_in, chat_out, ...)
paramsChat history item parameters (it will be consumed and zeroed)
nameChat history widget name
virtual bool appendGroup ( const String group) [virtual]

Append a group to this contact

Parameters:
groupGroup's name
Returns:
False if the group already exists
virtual ClientResource* appendResource ( const String id) [virtual]

Append a resource having a given id

Parameters:
idThe id of the desired resource
Returns:
ClientResource pointer or 0 if a resource with the given name already exists

Reimplemented in MucRoom.

static String& buildContactId ( String dest,
const String account,
const String contact 
) [inline, static]

Build a contact id to be used in UI (all strings are URI escaped using extra '|' character)

Parameters:
destDestination string
accountAccount owning the contact
contactThe contact's id
Returns:
Destination string

References String::toLower(), and String::uriEscape().

void buildIdHash ( String buf,
const String prefix = String::empty() 
) [inline]

Build a string from prefix and contact id hash

Parameters:
bufDestination string
prefixOptional prefix

References MD5::hexDigest().

String& buildInstanceId ( String dest,
const String inst = String::empty() 
) [inline]

Build a contact instance id to be used in UI

Parameters:
destDestination string
instInstance name
Returns:
Destination string

References String::uriEscape().

virtual void createChatWindow ( bool  force = false,
const char *  name = 0 
) [virtual]

Create the chat window

Parameters:
forceTrue to destroy the current one if any
nameThe window's name. Defaults to global name if empty

Close the chat window or destroy docked chat item

virtual void destroyed ( ) [protected, virtual]

Remove from owner. Destroy the chat window. Release data

Reimplemented from RefObject.

Reimplemented in MucRoom.

virtual ClientResource* findAudioResource ( bool  ref = false) [virtual]

Get the first resource with audio capability

Parameters:
refTrue to obtain a referenced pointer
Returns:
ClientResource pointer or 0 if not found
virtual ClientResource* findFileTransferResource ( bool  ref = false) [virtual]

Get the first resource with file transfer capability capability

Parameters:
refTrue to obtain a referenced pointer
Returns:
ClientResource pointer or 0 if not found
virtual String* findGroup ( const String group) [virtual]

Find a group this contact might belong to

Parameters:
groupThe name of the group to find
Returns:
String pointer or 0 if not found
virtual ClientResource* findResource ( const String id,
bool  ref = false 
) [virtual]

Find a resource having a given id

Parameters:
idThe id of the desired resource
refTrue to obtain a referenced pointer
Returns:
ClientResource pointer or 0 if not found

Reimplemented in MucRoom.

virtual void flashChat ( bool  on = true) [virtual]

Flash chat window/item to notify the user

Parameters:
onTrue to start, false to stop flashing
virtual void getChatHistory ( String text,
bool  richText = false,
const String name = "history" 
) [virtual]

Retrieve the contents of the chat history widget

Parameters:
textChat history text
richTextRetrieve rich/plain text flag
nameChat history widget name
virtual void getChatInput ( String text,
const String name = "message" 
) [virtual]

Retrieve the contents of the chat input widget

Parameters:
textChat input text
nameChat input widget name
virtual void getChatProperty ( const String name,
const String prop,
String value 
) [virtual]

Retrieve a chat widget' property

Parameters:
nameWidget name
propProperty name
valueDestination buffer

Get the chat window

Returns:
Valid Window pointer or 0
void getContactSection ( String buf) [inline]

Remove account prefix from contact id and URI unescape the result

Parameters:
bufDestination buffer

References String::empty(), String::startSkip(), and String::uriUnescape().

ObjList& groups ( ) [inline]

Get the group list of this contact

Returns:
The group list of this contact
bool hasChat ( )

Check if this contact has a chat widget (window or docked item)

Returns:
True if this contact has a chat window or docked item
virtual bool insertResource ( ClientResource res) [virtual]

Insert a resource in the list by its priority. If the resource is already there it will be extracted and re-inserted

Parameters:
resThe resource to insert
Returns:
True on success, false a resource with the same name already exists

Reimplemented in MucRoom.

virtual bool isChatActive ( ) [virtual]

Check if the contact chat is active

Returns:
True if the contact's chat window/page is active
bool isChatVisible ( ) [inline]

Check if this contact's chat window is visible

Returns:
True if this contact's chat window is visible
bool isChatWnd ( Window wnd) [inline]

Check if a window is this contact's chat

Parameters:
wndThe window to check
Returns:
True if the given window is this contact's chat

References Window::toString().

bool local ( bool  defVal = false) const [inline]

Check if the contact is locally saved

Parameters:
defValDefault value to return if parameter is invalid
Returns:
True if the contact is locally saved

References TelEngine::YSTRING().

virtual MucRoom* mucRoom ( ) [inline, virtual]

Return a MucRoom contact from this one

Returns:
MucRoom pointer or 0

Reimplemented in MucRoom.

bool online ( ) const [inline]

Check if the contact is online (the online flag is set or has at least 1 resource in list)

Returns:
True if the contact is online

References ObjList::skipNull().

bool remote ( bool  defVal = false) const [inline]

Check if the contact is saved on server

Parameters:
defValDefault value to return if parameter is invalid
Returns:
True if the contact is saved on server

References TelEngine::YSTRING().

void removeFromOwner ( ) [protected]

Remove from owner

virtual bool removeGroup ( const String group) [virtual]

Remove a contact's group

Parameters:
groupGroup's name
Returns:
False if the group was not found
virtual bool removeResource ( const String id) [virtual]

Remove a resource having a given id

Parameters:
idThe id of the desired resource
Returns:
True if the resource was removed
ObjList& resources ( ) [inline]

Get the resource list of this contact

Returns:
The resource list of this contact
virtual bool sendChat ( const char *  body,
const String res = String::empty(),
const String type = String::empty(),
const char *  state = "active" 
) [virtual]

Send chat to contact (enqueue a msg.execute message)

Parameters:
bodyChat body
resOptional target instance
typeOptional message type parameter
stateOptional chat state
Returns:
True on success
virtual void setChatHistory ( const String text,
bool  richText = false,
const String name = "history" 
) [virtual]

Set the contents of the chat history widget

Parameters:
textChat history text
richTextSet rich/plain text flag
nameChat history widget name
virtual void setChatInput ( const String text = String::empty(),
const String name = "message" 
) [virtual]

Set the chat input widget text

Parameters:
textChat input text
nameChat input widget name
virtual void setChatProperty ( const String name,
const String prop,
const String value 
) [virtual]

Set a chat widget' property

Parameters:
nameWidget name
propProperty name
valueProperty value
void setDockedChat ( bool  on) [inline]

Set/reset the docked chat flag for non MucRoom contact

Parameters:
onThe new value for docked chat flag
virtual bool setGroups ( const NamedList list,
const String param 
) [virtual]

Replace contact's groups from a list of parameters

Parameters:
listThe list of parameters
paramThe parameter name to handle
Returns:
True if the list changed
void setLocal ( bool  on) [inline]

Set contact locally saved flag

Parameters:
onThe new value for locally saved flag

References String::boolText().

void setOnline ( bool  on) [inline]

Set the online flag

Parameters:
onThe new value for online flag
void setRemote ( bool  on) [inline]

Set contact server saved flag

Parameters:
onThe new value for server saved flag

References String::boolText().

void setUri ( const char *  u) [inline]

Set this contact's URI

Parameters:
uNew contact URI
virtual bool showChat ( bool  visible,
bool  active = false 
) [virtual]

Show or hide this contact's chat window or docked item

Parameters:
visibleTrue to show, false to hide the window or destroy the docked item
activeTrue to activate the window or select the docked item if shown
Returns:
True on success
static void splitContactId ( const String src,
String account 
) [inline, static]

Retrieve the account part of a contact id

Parameters:
srcSource string
accountAccount id (URI unescaped)

References String::find(), String::substr(), and String::uriUnescape().

static void splitContactInstanceId ( const String src,
String account,
String contact,
String instance = 0 
) [static]

Split a contact instance id in account/contact/instance parts

Parameters:
srcSource string
accountAccount id (URI unescaped)
contactContact id
instanceOptional pointer to a String to be filled with instance id (URI unescaped)
virtual ClientResource* status ( bool  ref = false) [virtual]

Find the resource with the lowest status

Parameters:
refTrue to obtain a referenced pointer
Returns:
ClientResource pointer or 0 if not found

Reimplemented in MucRoom.

virtual const String& toString ( ) const [inline, virtual]

Get a string representation of this object

Returns:
The contact's id

Reimplemented from GenObject.

virtual void updateChatWindow ( const NamedList params,
const char *  title = 0,
const char *  icon = 0 
) [virtual]

Update contact parameters in chat window

Parameters:
paramsParameters to set
titleOptional window title to set (ignored if docked)
iconOptional window icon to set (ignored if docked)
const URI& uri ( ) const [inline]

Get this contact's URI

Returns:
This contact's URI

The documentation for this class was generated from the following file: