Yate
ClientLogic Class Reference

Base class for all client logics. More...

#include <yatecbase.h>

Inheritance diagram for ClientLogic:
GenObject DefaultLogic

Public Member Functions

virtual ~ClientLogic ()
 
const Stringname () const
 
int priority () const
 
virtual const StringtoString () const
 
bool setParams (const NamedList &params)
 
virtual bool action (Window *wnd, const String &name, NamedList *params=0)
 
virtual bool toggle (Window *wnd, const String &name, bool active)
 
virtual bool select (Window *wnd, const String &name, const String &item, const String &text=String::empty())
 
virtual bool select (Window *wnd, const String &name, const NamedList &items)
 
virtual bool setClientParam (const String &param, const String &value, bool save, bool update)
 
virtual bool imIncoming (Message &msg)
 
virtual bool callIncoming (Message &msg, const String &dest)
 
virtual bool validateCall (NamedList &params, Window *wnd=0)
 
virtual bool callStart (NamedList &params, Window *wnd=0, const String &cmd=String::empty())
 
virtual bool line (const String &name, Window *wnd=0)
 
virtual bool display (NamedList &params, bool widget, Window *wnd=0)
 
virtual bool backspace (const String &name, Window *wnd=0)
 
virtual bool command (const String &name, Window *wnd=0)
 
virtual bool debug (const String &name, bool active, Window *wnd=0)
 
virtual bool editAccount (bool newAcc, NamedList *params, Window *wnd=0)
 
virtual bool acceptAccount (NamedList *params, Window *wnd=0)
 
virtual bool delAccount (const String &account, Window *wnd=0)
 
virtual bool updateAccount (const NamedList &account, bool login, bool save)
 
virtual bool loginAccount (const NamedList &account, bool login)
 
virtual bool updateContact (const NamedList &contact, bool save, bool update)
 
virtual bool acceptContact (NamedList *params, Window *wnd=0)
 
virtual bool editContact (bool newCont, NamedList *params=0, Window *wnd=0)
 
virtual bool delContact (const String &contact, Window *wnd=0)
 
virtual bool callContact (NamedList *params=0, Window *wnd=0)
 
virtual bool updateProviders (const NamedList &provider, bool save, bool update)
 
virtual bool callLogUpdate (const NamedList &params, bool save, bool update)
 
virtual bool callLogDelete (const String &billid)
 
virtual bool callLogClear (const String &table, const String &direction)
 
virtual bool callLogCall (const String &billid, Window *wnd=0)
 
virtual bool callLogCreateContact (const String &billid)
 
virtual bool help (const String &action, Window *wnd)
 
virtual bool calltoLoaded ()
 
virtual void loadedWindows ()
 
virtual void initializedWindows ()
 
virtual bool initializedClient ()
 
virtual void exitingClient ()
 
virtual bool handleUiAction (Message &msg, bool &stopLogic)
 
virtual bool handleCallCdr (Message &msg, bool &stopLogic)
 
virtual bool handleUserLogin (Message &msg, bool &stopLogic)
 
virtual bool handleUserNotify (Message &msg, bool &stopLogic)
 
virtual bool handleUserRoster (Message &msg, bool &stopLogic)
 
virtual bool handleResourceNotify (Message &msg, bool &stopLogic)
 
virtual bool handleResourceSubscribe (Message &msg, bool &stopLogic)
 
virtual bool handleClientChanUpdate (Message &msg, bool &stopLogic)
 
virtual bool handleContactInfo (Message &msg, bool &stopLogic)
 
virtual bool defaultMsgHandler (Message &msg, int id, bool &stopLogic)
 
virtual void engineStart (Message &msg)
 
virtual bool addDurationUpdate (DurationUpdate *duration, bool autoDelete=false)
 
virtual bool removeDurationUpdate (const String &name, bool delObj=false)
 
virtual bool removeDurationUpdate (DurationUpdate *duration, bool delObj=false)
 
virtual DurationUpdatefindDurationUpdate (const String &name, bool ref=true)
 
virtual void clearDurationUpdate ()
 
virtual void destruct ()
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual bool alive () const
 
virtual const StringtraceId () const
 
virtual void * getObject (const String &name) const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 

Static Public Member Functions

static const StringcdrRemoteParty (const NamedList &params, bool outgoing)
 
static const StringcdrRemoteParty (const NamedList &params)
 
static void initStaticData ()
 
static bool saveContact (Configuration &cfg, ClientContact *c, bool save=true)
 
static bool clearContact (Configuration &cfg, ClientContact *c, bool save=true)
 
- Static Public Member Functions inherited from GenObject
static void * getObject (const String &name, const GenObject *obj)
 
static bool getObjCounting ()
 
static void setObjCounting (bool enable)
 
static NamedCountergetObjCounter (const String &name, bool create=true)
 
static ObjListgetObjCounters ()
 

Static Public Attributes

static ObjList s_accOptions
 
static const char * s_provParams []
 
static ObjList s_protocols
 
static Mutex s_protocolsMutex
 

Protected Member Functions

 ClientLogic (const char *name, int priority)
 
virtual void idleTimerTick (Time &time)
 

Protected Attributes

ObjList m_durationUpdate
 
Mutex m_durationMutex
 

Friends

class Client
 

Detailed Description

Base class for all client logics.

This class implements the logic behind different actions in the client. It specifies the way the graphical interface of the client will behave in different circumstances.

Constructor & Destructor Documentation

◆ ~ClientLogic()

virtual ~ClientLogic ( )
virtual

Destructor. Remove itself from the client's list

◆ ClientLogic()

ClientLogic ( const char * name,
int priority )
protected

Constructor. Append itself to the client's list

Parameters
nameThe name of this logic (module)
priorityThe priority of this logic

Member Function Documentation

◆ acceptAccount()

virtual bool acceptAccount ( NamedList * params,
Window * wnd = 0 )
inlinevirtual

Called when the user wants to save account data

Parameters
paramsInitial parameters
wndOptional window containing the widget that triggered the action
Returns
True on success

Reimplemented in DefaultLogic.

◆ acceptContact()

virtual bool acceptContact ( NamedList * params,
Window * wnd = 0 )
inlinevirtual

Called when the user wants to save account data

Parameters
paramsInitial parameters
wndOptional window containing the widget that triggered the action
Returns
True on success

Reimplemented in DefaultLogic.

◆ action()

virtual bool action ( Window * wnd,
const String & name,
NamedList * params = 0 )
inlinevirtual

Handle actions from user interface

Parameters
wndThe window in which the user did something
nameThe action's name
paramsOptional action parameters
Returns
True if the action was handled

Reimplemented in DefaultLogic.

◆ addDurationUpdate()

virtual bool addDurationUpdate ( DurationUpdate * duration,
bool autoDelete = false )
virtual

Add a duration object to this client's list

Parameters
durationThe object to add
autoDeleteTrue to delete the object when the list is cleared
Returns
True on success

◆ backspace()

virtual bool backspace ( const String & name,
Window * wnd = 0 )
virtual

Erase the last digit from the given widget and set focus on it

Parameters
nameThe widget (it might be the window itself)
wndOptional window containing the widget that triggered the action
Returns
True on success

◆ callContact()

virtual bool callContact ( NamedList * params = 0,
Window * wnd = 0 )
inlinevirtual

Called when the user wants to call an existing contact

Parameters
paramsOptional parameters
wndOptional window containing the widget that triggered the action
Returns
True on success

Reimplemented in DefaultLogic.

◆ callIncoming()

virtual bool callIncoming ( Message & msg,
const String & dest )
inlinevirtual

Call execute handler called by the client. The default logic ask the client to build an incoming channel

Parameters
msgThe call.execute message
destThe destination (target)
Returns
True if a channel was created and connected

Reimplemented in DefaultLogic.

◆ callLogCall()

virtual bool callLogCall ( const String & billid,
Window * wnd = 0 )
inlinevirtual

Make an outgoing call to a target picked from the call log

Parameters
billidThe bill id of the call
wndOptional window starting the action
Returns
True on success (call initiated)

Reimplemented in DefaultLogic.

◆ callLogClear()

virtual bool callLogClear ( const String & table,
const String & direction )
inlinevirtual

Clear the specified log and the entries from the history file and save the history file

Parameters
tableTebale to clear
directionThe call direction to clear (incoming,outgoing). Note that the direction is the value saved from call.cdr messages. If empty, all log entries will be cleared
Returns
True

Reimplemented in DefaultLogic.

◆ callLogCreateContact()

virtual bool callLogCreateContact ( const String & billid)
inlinevirtual

Create a contact from a call log entry

Parameters
billidThe bill id of the call
Returns
True on success (address book popup window was displayed)

Reimplemented in DefaultLogic.

◆ callLogDelete()

virtual bool callLogDelete ( const String & billid)
inlinevirtual

Remove a call log item

Parameters
billidThe bill id of the call
Returns
True on success

Reimplemented in DefaultLogic.

◆ callLogUpdate()

virtual bool callLogUpdate ( const NamedList & params,
bool save,
bool update )
inlinevirtual

Update the call log history

Parameters
paramsCall log data
saveTrue to save data to history file
updateTrue to update the interface
Returns
True

Reimplemented in DefaultLogic.

◆ callStart()

virtual bool callStart ( NamedList & params,
Window * wnd = 0,
const String & cmd = String::empty() )
inlinevirtual

Called when the user trigger a call start action The default logic fill the parameter list and ask the client to create an outgoing channel

Parameters
paramsList of call parameters
wndOptional window containing the widget that triggered the action
cmdOptional command (widget name)
Returns
True on success

Reimplemented in DefaultLogic.

◆ calltoLoaded()

virtual bool calltoLoaded ( )
inlinevirtual

Called by the client after loaded the callto history file

Returns
True to tell the client to stop notifying other logics

Reimplemented in DefaultLogic.

◆ cdrRemoteParty() [1/2]

static const String & cdrRemoteParty ( const NamedList & params)
inlinestatic

Retrieve the remote party from CDR parameters

Parameters
paramsCDR parameters
Returns
The remote party (may be empty)

References ClientLogic::cdrRemoteParty(), and String::empty().

◆ cdrRemoteParty() [2/2]

static const String & cdrRemoteParty ( const NamedList & params,
bool outgoing )
inlinestatic

Retrieve the remote party from CDR parameters

Parameters
paramsCDR parameters
outgoingTrue if the call was an outgoing one
Returns
The remote party (may be empty)

Referenced by ClientLogic::cdrRemoteParty().

◆ clearContact()

static bool clearContact ( Configuration & cfg,
ClientContact * c,
bool save = true )
static

Delete a contact from a configuration file

Parameters
cfgThe configuration file
cThe contact to delete
saveTrue to save the file
Returns
True on success

◆ clearDurationUpdate()

virtual void clearDurationUpdate ( )
virtual

Remove all duration objects

◆ command()

virtual bool command ( const String & name,
Window * wnd = 0 )
virtual

Enqueue an engine.command message

Parameters
nameThe command line
wndOptional window containing the widget that triggered the action
Returns
True on success

◆ debug()

virtual bool debug ( const String & name,
bool active,
Window * wnd = 0 )
virtual

Enqueue an engine.debug message.

Parameters
nameThe debug action content (following the prefix). The format of this parameter must be 'module:active-true:active-false'. The line parameter of the message will be filled with 'active-true' if active is true and with 'active-false' if active is false
activeThe widget's state
wndOptional window containing the widget that triggered the action
Returns
True on success

◆ defaultMsgHandler()

virtual bool defaultMsgHandler ( Message & msg,
int id,
bool & stopLogic )
inlinevirtual

Default message processor called for id's not defined in client. Descendants may override it to process custom messages installed by them and relayed through the client

Parameters
msgReceived message
idMessage id
stopLogicSet to true on exit to tell the client to stop asking other logics
Returns
True to stop further processing by the engine

Reimplemented in DefaultLogic.

◆ delAccount()

virtual bool delAccount ( const String & account,
Window * wnd = 0 )
inlinevirtual

Called when the user wants to delete an existing account

Parameters
accountThe account's name. Set to empty to delete the current selection
wndOptional window containing the widget that triggered the action
Returns
True on success

Reimplemented in DefaultLogic.

◆ delContact()

virtual bool delContact ( const String & contact,
Window * wnd = 0 )
inlinevirtual

Called when the user wants to delete an existing contact

Parameters
contactThe contact's id. Set to empty to delete the current selection
wndOptional window containing the widget that triggered the action
Returns
True on success

Reimplemented in DefaultLogic.

◆ destruct()

virtual void destruct ( )
virtual

Release memory. Remove from client's list

Reimplemented from GenObject.

◆ display()

virtual bool display ( NamedList & params,
bool widget,
Window * wnd = 0 )
virtual

Show/hide widget(s) or window(s) on 'display'/'show' action.

Parameters
paramsWidget(s) or window(s) to show/hide
widgetTrue if the operation indicates widget(s), false otherwise
wndOptional window owning the widget(s) to show or hide
Returns
False if failed to show/hide all widgets/windows

◆ editAccount()

virtual bool editAccount ( bool newAcc,
NamedList * params,
Window * wnd = 0 )
inlinevirtual

Called when the user wants to add a new account or edit an existing one

Parameters
newAccTrue to add a new account, false to edit an exisiting one
paramsInitial parameters
wndOptional window containing the widget that triggered the action
Returns
True on success

Reimplemented in DefaultLogic.

◆ editContact()

virtual bool editContact ( bool newCont,
NamedList * params = 0,
Window * wnd = 0 )
inlinevirtual

Called when the user wants to add a new contact or edit an existing one

Parameters
newContTrue to add a new contact, false to edit an existing one
paramsOptional initial parameters
wndOptional window containing the widget that triggered the action
Returns
True on success

Reimplemented in DefaultLogic.

◆ engineStart()

virtual void engineStart ( Message & msg)
inlinevirtual

Engine start notification

Parameters
msgThe engine.start message

Reimplemented in DefaultLogic.

◆ exitingClient()

virtual void exitingClient ( )
inlinevirtual

Called by the client before exiting. The default logic save client settings

Reimplemented in DefaultLogic.

◆ findDurationUpdate()

virtual DurationUpdate * findDurationUpdate ( const String & name,
bool ref = true )
virtual

Find a duration update by its name

Parameters
nameThe name of the object to find
refTrue to increase its reference counter before returning
Returns
DurationUpdate pointer or 0

◆ handleCallCdr()

virtual bool handleCallCdr ( Message & msg,
bool & stopLogic )
inlinevirtual

Process call.cdr message

Parameters
msgReceived message
stopLogicSet to true on exit to tell the client to stop asking other logics
Returns
True to stop further processing by the engine

Reimplemented in DefaultLogic.

◆ handleClientChanUpdate()

virtual bool handleClientChanUpdate ( Message & msg,
bool & stopLogic )
inlinevirtual

Process clientchan.update message

Parameters
msgReceived message
stopLogicSet to true on exit to tell the client to stop asking other logics
Returns
True to stop further processing by the engine

Reimplemented in DefaultLogic.

◆ handleContactInfo()

virtual bool handleContactInfo ( Message & msg,
bool & stopLogic )
inlinevirtual

Process contact.info message

Parameters
msgReceived message
stopLogicSet to true on exit to tell the client to stop asking other logics
Returns
True to stop further processing by the engine

Reimplemented in DefaultLogic.

◆ handleResourceNotify()

virtual bool handleResourceNotify ( Message & msg,
bool & stopLogic )
inlinevirtual

Process resource.notify message

Parameters
msgReceived message
stopLogicSet to true on exit to tell the client to stop asking other logics
Returns
True to stop further processing by the engine

Reimplemented in DefaultLogic.

◆ handleResourceSubscribe()

virtual bool handleResourceSubscribe ( Message & msg,
bool & stopLogic )
inlinevirtual

Process resource.subscribe message

Parameters
msgReceived message
stopLogicSet to true on exit to tell the client to stop asking other logics
Returns
True to stop further processing by the engine

Reimplemented in DefaultLogic.

◆ handleUiAction()

virtual bool handleUiAction ( Message & msg,
bool & stopLogic )
inlinevirtual

Process ui.action message

Parameters
msgReceived message
stopLogicSet to true on exit to tell the client to stop asking other logics
Returns
True to stop further processing by the engine

Reimplemented in DefaultLogic.

◆ handleUserLogin()

virtual bool handleUserLogin ( Message & msg,
bool & stopLogic )
inlinevirtual

Process user.login message

Parameters
msgReceived message
stopLogicSet to true on exit to tell the client to stop asking other logics
Returns
True to stop further processing by the engine

Reimplemented in DefaultLogic.

◆ handleUserNotify()

virtual bool handleUserNotify ( Message & msg,
bool & stopLogic )
inlinevirtual

Process user.notify message

Parameters
msgReceived message
stopLogicSet to true on exit to tell the client to stop asking other logics
Returns
True to stop further processing by the engine

Reimplemented in DefaultLogic.

◆ handleUserRoster()

virtual bool handleUserRoster ( Message & msg,
bool & stopLogic )
inlinevirtual

Process user.roster message

Parameters
msgReceived message
stopLogicSet to true on exit to tell the client to stop asking other logics
Returns
True to stop further processing by the engine

Reimplemented in DefaultLogic.

◆ help()

virtual bool help ( const String & action,
Window * wnd )
inlinevirtual

Process help related actions

Parameters
actionThe action's name
wndThe window owning the control
Returns
True on success

Reimplemented in DefaultLogic.

◆ idleTimerTick()

virtual void idleTimerTick ( Time & time)
inlineprotectedvirtual

Method called by the client when idle. This method is called in the UI's thread

Parameters
timeThe current time

Reimplemented in DefaultLogic.

◆ imIncoming()

virtual bool imIncoming ( Message & msg)
inlinevirtual

Process an IM message

Parameters
msgThe im.execute or chan.text message

Reimplemented in DefaultLogic.

◆ initializedClient()

virtual bool initializedClient ( )
inlinevirtual

Called by the client after loaded and intialized the windows and loaded configuration files. The default logic update client settings

Returns
True to stop processing this notification

Reimplemented in DefaultLogic.

◆ initializedWindows()

virtual void initializedWindows ( )
inlinevirtual

Called by the client after loaded and intialized the windows

Reimplemented in DefaultLogic.

◆ initStaticData()

static void initStaticData ( )
static

Init static logic lists. Called by the client when start running

◆ line()

virtual bool line ( const String & name,
Window * wnd = 0 )
virtual

Called when the user selected a line

Parameters
nameThe line name
wndOptional window containing the widget that triggered the action
Returns
True on success

◆ loadedWindows()

virtual void loadedWindows ( )
inlinevirtual

Called by the client after loaded the windows

Reimplemented in DefaultLogic.

◆ loginAccount()

virtual bool loginAccount ( const NamedList & account,
bool login )
inlinevirtual

Login/logout an account

Parameters
accountThe account's parameters. The name of the list must be the account's name
loginTrue to login the account, false to logout
Returns
True on success

Reimplemented in DefaultLogic.

◆ name()

const String & name ( ) const
inline

Get the name of this logic

Returns
This logic's name

◆ priority()

int priority ( ) const
inline

Get the priority of this logic

Returns
This logic's priority

◆ removeDurationUpdate() [1/2]

virtual bool removeDurationUpdate ( const String & name,
bool delObj = false )
virtual

Remove a duration object from list

Parameters
nameThe name of the object to remove
delObjTrue to destroy the object, false to remove it
Returns
True on success

◆ removeDurationUpdate() [2/2]

virtual bool removeDurationUpdate ( DurationUpdate * duration,
bool delObj = false )
virtual

Remove a duration object from list

Parameters
durationThe object to remove
delObjTrue to destroy the object, false to remove it
Returns
True on success

◆ saveContact()

static bool saveContact ( Configuration & cfg,
ClientContact * c,
bool save = true )
static

Save a contact into a configuration file

Parameters
cfgThe configuration file
cThe contact to save
saveTrue to save the file
Returns
True on success

◆ select() [1/2]

virtual bool select ( Window * wnd,
const String & name,
const NamedList & items )
inlinevirtual

Handle 'select' with multiple items actions from user interface

Parameters
wndThe window in which the user did something
nameThe object's name
itemsList of selected items
Returns
True if the action was handled

Reimplemented in DefaultLogic.

◆ select() [2/2]

virtual bool select ( Window * wnd,
const String & name,
const String & item,
const String & text = String::empty() )
inlinevirtual

Handle 'select' actions from user interface

Parameters
wndThe window in which the user did something
nameThe object's name
itemItem identifying the selection
textSelection's text
Returns
True if the action was handled

Reimplemented in DefaultLogic.

◆ setClientParam()

virtual bool setClientParam ( const String & param,
const String & value,
bool save,
bool update )
inlinevirtual

Set a client's parameter. Save the settings file and/or update interface

Parameters
paramParameter's name
valueThe value of the parameter
saveTrue to save the configuration file
updateTrue to update the interface
Returns
True on success

Reimplemented in DefaultLogic.

◆ setParams()

bool setParams ( const NamedList & params)

Process a request to set client parameters

Parameters
paramsThe parameter list
Returns
True on success

◆ toggle()

virtual bool toggle ( Window * wnd,
const String & name,
bool active )
inlinevirtual

Handle actions from checkable widgets

Parameters
wndThe window in which the user did something
nameThe object's name
activeObject's state
Returns
True if the action was handled by a client logic

Reimplemented in DefaultLogic.

◆ toString()

virtual const String & toString ( ) const
virtual

Function that returns the name of the logic

Returns
The name of this client logic

Reimplemented from GenObject.

◆ updateAccount()

virtual bool updateAccount ( const NamedList & account,
bool login,
bool save )
inlinevirtual

Add/set an account. Login if required

Parameters
accountThe account's parameters. The name of the list must be the account's name
loginTrue to login the account
saveTrue to save the accounts file. If true and file save fails the method will fail
Returns
True on success

Reimplemented in DefaultLogic.

◆ updateContact()

virtual bool updateContact ( const NamedList & contact,
bool save,
bool update )
inlinevirtual

Add/set a contact

Parameters
contactThe contact's parameters. The name of the list must be the contacts's id (name). If it starts with 'client/' this is a contact updated from server: it can't be changed
saveTrue to save data to contacts file
updateTrue to update the interface
Returns
True on success

Reimplemented in DefaultLogic.

◆ updateProviders()

virtual bool updateProviders ( const NamedList & provider,
bool save,
bool update )
inlinevirtual

Add/set account providers data

Parameters
providerThe provider's parameters. The name of the list must be the provider's id (name)
saveTrue to save data to providers file
updateTrue to update the interface
Returns
True on success

Reimplemented in DefaultLogic.

◆ validateCall()

virtual bool validateCall ( NamedList & params,
Window * wnd = 0 )
inlinevirtual

Check presence of all necessary data to make a call

Parameters
paramsList of call parameters
wndOptional window containing the widget that triggered the action
Returns
True on success

Reimplemented in DefaultLogic.


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