#include <yatecbase.h>
Public Types | |
enum | MsgID { CallCdr = 0, UiAction = 1, UserLogin = 2, UserNotify = 3, ResourceNotify = 4, ResourceSubscribe = 5, XmppIq = 7, ClientChanUpdate = 8, ChanNotify = 9, MsgIdCount = 10 } |
enum | ClientToggle { OptMultiLines = 0, OptAutoAnswer = 1, OptRingIn = 2, OptRingOut = 3, OptActivateLastOutCall = 4, OptActivateLastInCall = 5, OptActivateCallOnSelect = 6, OptKeypadVisible = 7, OptCount = 8 } |
enum | Protocol { SIP = 0, JABBER = 1, H323 = 2, IAX = 3, OtherProtocol = 4 } |
Public Member Functions | |
Client (const char *name=0) | |
virtual | ~Client () |
virtual void | run () |
virtual void | cleanup () |
virtual void | main ()=0 |
virtual void | lock ()=0 |
virtual void | unlock ()=0 |
void | lockOther () |
void | unlockOther () |
virtual void | allHidden ()=0 |
void | loadUI (const char *file=0, bool init=true) |
virtual void | quit ()=0 |
virtual bool | received (Message &msg, int id) |
virtual bool | createWindowSafe (const String &name, const String &alias=String::empty()) |
virtual bool | createObject (void **dest, const String &type, const char *name, NamedList *params=0) |
virtual bool | closeWindow (const String &name, bool hide=true) |
virtual bool | debugHook (bool active) |
virtual bool | addToLog (const String &text) |
virtual bool | setStatus (const String &text, Window *wnd=0) |
bool | setStatusLocked (const String &text, Window *wnd=0) |
bool | setParams (const NamedList *params, Window *wnd=0, Window *skip=0) |
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()) |
bool | oneThread () const |
int | line () const |
void | line (int newLine) |
bool | hasElement (const String &name, Window *wnd=0, Window *skip=0) |
bool | setActive (const String &name, bool active, Window *wnd=0, Window *skip=0) |
bool | setFocus (const String &name, bool select=false, Window *wnd=0, Window *skip=0) |
bool | setShow (const String &name, bool visible, Window *wnd=0, Window *skip=0) |
bool | setText (const String &name, const String &text, bool richText=false, Window *wnd=0, Window *skip=0) |
bool | setCheck (const String &name, bool checked, Window *wnd=0, Window *skip=0) |
bool | setSelect (const String &name, const String &item, Window *wnd=0, Window *skip=0) |
bool | setUrgent (const String &name, bool urgent, Window *wnd=0, Window *skip=0) |
bool | hasOption (const String &name, const String &item, Window *wnd=0, Window *skip=0) |
virtual bool | getOptions (const String &name, NamedList *items, Window *wnd=0, Window *skip=0) |
bool | addOption (const String &name, const String &item, bool atStart, const String &text=String::empty(), Window *wnd=0, Window *skip=0) |
bool | delOption (const String &name, const String &item, Window *wnd=0, Window *skip=0) |
virtual bool | addLines (const String &name, const NamedList *lines, unsigned int max, bool atStart=false, Window *wnd=0, Window *skip=0) |
bool | addTableRow (const String &name, const String &item, const NamedList *data=0, bool atStart=false, Window *wnd=0, Window *skip=0) |
bool | delTableRow (const String &name, const String &item, Window *wnd=0, Window *skip=0) |
bool | setTableRow (const String &name, const String &item, const NamedList *data, Window *wnd=0, Window *skip=0) |
bool | getTableRow (const String &name, const String &item, NamedList *data=0, Window *wnd=0, Window *skip=0) |
bool | clearTable (const String &name, Window *wnd=0, Window *skip=0) |
bool | getText (const String &name, String &text, Window *wnd=0, Window *skip=0) |
bool | getCheck (const String &name, bool &checked, Window *wnd=0, Window *skip=0) |
bool | getSelect (const String &name, String &item, Window *wnd=0, Window *skip=0) |
virtual bool | setProperty (const String &name, const String &item, const String &value, Window *wnd=0, Window *skip=0) |
virtual bool | getProperty (const String &name, const String &item, String &value, Window *wnd=0, Window *skip=0) |
void | moveRelated (const Window *wnd, int dx, int dy) |
bool | initialized () const |
void | idleActions () |
virtual bool | chooseFile (Window *parent, const NamedList ¶ms, NamedList *files, String *file) |
virtual bool | setClientParam (const String ¶m, const String &value, bool save, bool update) |
virtual bool | backspace (const String &name, Window *wnd=0) |
void | installRelay (const char *name, int id, int prio) |
virtual bool | callRouting (Message &msg) |
virtual bool | buildIncomingChannel (Message &msg, const String &dest) |
virtual bool | buildOutgoingChannel (NamedList ¶ms) |
bool | callIncoming (Message &msg, const String &dest) |
void | callAnswer (const String &id) |
void | callTerminate (const String &id, const char *reason=0, const char *error=0) |
ClientChannel * | getActiveChannel () |
virtual bool | ringer (bool in, bool on) |
virtual bool | createSound (const char *name, const char *file, const char *device=0) |
bool | emitDigits (const char *digits, const String &id=String::empty()) |
bool | emitDigit (char digit, const String &id=String::empty()) |
bool | getBoolOpt (ClientToggle toggle) |
bool | setBoolOpt (ClientToggle toggle, bool value, bool updateUi=false) |
Static Public Member Functions | |
static Client * | self () |
static bool | changing () |
static Window * | getWindow (const String &name) |
static bool | setVisible (const String &name, bool show=true) |
static bool | getVisible (const String &name) |
static bool | openPopup (const String &name, const NamedList *params=0, const Window *parent=0) |
static bool | openMessage (const char *text, const Window *parent=0, const char *context=0) |
static bool | openConfirm (const char *text, const Window *parent=0, const char *context=0) |
static ObjList * | listWindows () |
static bool | addLogic (ClientLogic *logic) |
static void | removeLogic (ClientLogic *logic) |
static ClientLogic * | findLogic (const String &name) |
static Message * | eventMessage (const String &event, Window *wnd=0, const char *name=0, NamedList *params=0) |
static bool | save (Configuration &cfg, Window *parent=0, bool showErr=true) |
static ClientToggle | getBoolOpt (const String &name) |
static void | setLogicsTick () |
static Protocol | getProtocol (const String &proto) |
static const String & | getProtocol (int proto) |
Static Public Attributes | |
static Configuration | s_settings |
static Configuration | s_actions |
static Configuration | s_accounts |
static Configuration | s_contacts |
static Configuration | s_providers |
static Configuration | s_history |
static Configuration | s_calltoHistory |
static Regexp | s_notSelected |
static const char * | s_provParams [] |
static ObjList | s_accOptions |
static String | s_protocols [OtherProtocol] |
static String | s_skinPath |
static String | s_soundPath |
static String | s_ringInName |
static String | s_ringOutName |
static String | s_statusWidget |
static String | s_debugWidget |
static String | s_toggles [OptCount] |
Protected Member Functions | |
virtual bool | createWindow (const String &name, const String &alias=String::empty())=0 |
virtual void | loadWindows (const char *file=0)=0 |
virtual void | initWindows () |
virtual void | initClient () |
virtual void | exitClient () |
bool | needProxy () const |
bool | driverLockLoop () |
Static Protected Member Functions | |
static bool | driverLock (long maxwait=0) |
static void | driverUnlock () |
Protected Attributes | |
ObjList | m_windows |
bool | m_initialized |
int | m_line |
bool | m_oneThread |
bool | m_toggles [OptCount] |
ObjList | m_relays |
Static Protected Attributes | |
static Client * | s_client |
static int | s_changing |
static ObjList | s_logics |
static bool | s_idleLogicsTick |
Friends | |
class | Window |
class | ClientChannel |
class | ClientDriver |
class | ClientLogic |
Singleton class that holds the User Interface's main thread and methods
enum ClientToggle |
Client boolean options mapped to UI toggles
enum Protocol |
Known voip protocols
Client | ( | const char * | name = 0 |
) |
Constructor
name | The client's name |
virtual ~Client | ( | ) | [virtual] |
Destructor
virtual void run | ( | ) | [virtual] |
Run the client's thread
Implements Runnable.
virtual void cleanup | ( | ) | [virtual] |
Cleanup when thread terminates
Reimplemented from Thread.
virtual void main | ( | ) | [pure virtual] |
Execute the client
virtual void lock | ( | ) | [pure virtual] |
Lock the client
virtual void unlock | ( | ) | [pure virtual] |
Unlock the client
void lockOther | ( | ) | [inline] |
Lock the client only if we are using more then 1 thread
void unlockOther | ( | ) | [inline] |
Unlock the client only if we are using more then 1 thread
virtual void allHidden | ( | ) | [pure virtual] |
Handle all windows closed event from UI
void loadUI | ( | const char * | file = 0 , |
|
bool | init = true | |||
) |
Load windows and optionally (re)initialize the client's options.
file | The resource file describing the windows. Set to 0 to use the default one | |
init | True to (re)initialize the client |
virtual void quit | ( | ) | [pure virtual] |
Terminate application
virtual bool received | ( | Message & | msg, | |
int | id | |||
) | [virtual] |
Process a received message. Check for a logic to process it
msg | Received message | |
id | Message id |
Implements MessageReceiver.
virtual bool createWindowSafe | ( | const String & | name, | |
const String & | alias = String::empty() | |||
) | [virtual] |
Create a window with a given name
name | The window's name | |
alias | Window name alias after succesfully loaded. Set to empty string to use the given name |
virtual bool createObject | ( | void ** | dest, | |
const String & | type, | |||
const char * | name, | |||
NamedList * | params = 0 | |||
) | [virtual] |
Ask to an UI factory to create an object in the UI's thread
dest | Destination to be filled with the newly create object's address | |
type | Object's type | |
name | Object's name | |
params | Optional object parameters |
virtual bool closeWindow | ( | const String & | name, | |
bool | hide = true | |||
) | [virtual] |
Hide/destroy a window with a given name
name | The window's name | |
hide | True to hide, false to close |
virtual bool debugHook | ( | bool | active | ) | [virtual] |
Install/uninstall a debugger output hook
active | True to install, false to uninstall the hook |
virtual bool addToLog | ( | const String & | text | ) | [virtual] |
Add a log line
text | Text to add |
Set the status text
text | Status text | |
wnd | Optional window owning the status control |
Set the status text safely
text | Status text | |
wnd | Optional window owning the status control |
Set multiple window parameters
params | The parameter list | |
wnd | Optional window whose params are to be set | |
skip | Optional window to skip if wnd is 0 |
Handle actions from user interface. Enqueue an ui.event message if the action is not handled by a client logic
wnd | The window in which the user did something | |
name | The action's name | |
params | Optional action parameters |
Handle actions from checkable widgets. Enqueue an ui.event message if the action is not handled by a client logic
wnd | The window in which the user did something | |
name | The object's name | |
active | Object's state |
virtual bool select | ( | Window * | wnd, | |
const String & | name, | |||
const String & | item, | |||
const String & | text = String::empty() | |||
) | [virtual] |
Handle 'select' actions from user interface. Enqueue an ui.event message if the action is not handled by a client logic
wnd | The window in which the user selected the object | |
name | The action's name | |
item | Item identifying the selection | |
text | Selection's text |
bool oneThread | ( | ) | const [inline] |
Check if the client is using more then 1 thread
int line | ( | ) | const [inline] |
Get the currently selected line
void line | ( | int | newLine | ) |
Set the selected line
newLine | The selected line |
virtual bool getOptions | ( | const String & | name, | |
NamedList * | items, | |||
Window * | wnd = 0 , |
|||
Window * | skip = 0 | |||
) | [virtual] |
Get an element's items
name | Name of the element to search for | |
items | List to fill with element's items | |
wnd | Optional window owning the element | |
skip | Optional window to skip when searching for the element |
virtual bool addLines | ( | const String & | name, | |
const NamedList * | lines, | |||
unsigned int | max, | |||
bool | atStart = false , |
|||
Window * | wnd = 0 , |
|||
Window * | skip = 0 | |||
) | [virtual] |
Append or insert text lines to a widget
name | The name of the widget | |
lines | List containing the lines | |
max | The maximum number of lines allowed to be displayed. Set to 0 to ignore | |
atStart | True to insert, false to append | |
wnd | Optional window owning the widget | |
skip | Optional window to skip if wnd is 0 |
virtual bool setProperty | ( | const String & | name, | |
const String & | item, | |||
const String & | value, | |||
Window * | wnd = 0 , |
|||
Window * | skip = 0 | |||
) | [virtual] |
Set a property
name | Name of the element | |
item | Property's name | |
value | Property's value | |
wnd | Optional target window | |
skip | Optional window to skip if wnd is 0 |
virtual bool getProperty | ( | const String & | name, | |
const String & | item, | |||
String & | value, | |||
Window * | wnd = 0 , |
|||
Window * | skip = 0 | |||
) | [virtual] |
Get a property
name | Name of the element | |
item | Property's name | |
value | Property's value | |
wnd | Optional target window | |
skip | Optional window to skip if wnd is 0 |
virtual bool chooseFile | ( | Window * | parent, | |
const NamedList & | params, | |||
NamedList * | files, | |||
String * | file | |||
) | [inline, virtual] |
Show a file open dialog window This method isn't using the proxy thread since it's usually called on UI action
parent | Dialog window's parent | |
params | Dialog window's params. Parameters that can be specified include 'caption', 'dir', 'filters', 'selectedfilter', 'confirmoverwrite', 'choosedir'. The parameter 'filters' may be a pipe ('|') separated list of filters | |
files | List of selected file(s). Allow multiple file selection if non 0 | |
file | The selected file if multiple file selection is disabled |
virtual bool setClientParam | ( | const String & | param, | |
const String & | value, | |||
bool | save, | |||
bool | update | |||
) | [virtual] |
Request to a logic to set a client's parameter. Save the settings file and/or update interface
param | Parameter's name | |
value | The value of the parameter | |
save | True to save the configuration file | |
update | True to update the interface |
Called when the user pressed the backspace key
name | The active widget (it might be the window itself) | |
wnd | Optional window containing the widget that triggered the action |
void installRelay | ( | const char * | name, | |
int | id, | |||
int | prio | |||
) |
virtual bool callRouting | ( | Message & | msg | ) | [inline, virtual] |
Call routing handler called by the driver
msg | The call.route message |
Build an incoming channel. Answer it if succesfully connected and auto answer is set. Reject it if multiline is false and the driver is busy. Set the active one if requested by config and there is no active channel. Start the ringer if there is no active channel
msg | The call.execute message | |
dest | The destination (target) |
virtual bool buildOutgoingChannel | ( | NamedList & | params | ) | [virtual] |
Build an outgoing channel
params | Call parameters |
Call execute handler called by the driver. Ask the logics to create the channel
msg | The call.execute message | |
dest | The destination (target) |
void callAnswer | ( | const String & | id | ) |
Answer an incoming call
id | The accepted channel's id |
void callTerminate | ( | const String & | id, | |
const char * | reason = 0 , |
|||
const char * | error = 0 | |||
) |
Terminate a call
id | The channel's id | |
reason | Optional termination reason | |
error | Optional termination error |
ClientChannel* getActiveChannel | ( | ) |
Get the active channel if any
virtual bool ringer | ( | bool | in, | |
bool | on | |||
) | [virtual] |
Start/stop ringer. The ringer is started only if not disabled
in | True if the request is for the incoming call alert, false if it is for the outgoing call ringing alert | |
on | True to start, false to stop the sound |
virtual bool createSound | ( | const char * | name, | |
const char * | file, | |||
const char * | device = 0 | |||
) | [inline, virtual] |
Create a sound object. Append it to the global list
name | The name of sound object | |
file | The file to play (should contain the whole path and the file name) | |
device | Optional device used to play the file. Set to 0 to use the default one |
bool emitDigits | ( | const char * | digits, | |
const String & | id = String::empty() | |||
) |
Send digits on selected channel
digits | The digits to send | |
id | The channel id. Use the active one if empty |
bool emitDigit | ( | char | digit, | |
const String & | id = String::empty() | |||
) | [inline] |
Send a digit on selected channel
digit | The digit to send | |
id | The channel id. Use the active one if empty |
bool getBoolOpt | ( | ClientToggle | toggle | ) | [inline] |
Get a boolean option of this client
toggle | Options's id to retrieve |
bool setBoolOpt | ( | ClientToggle | toggle, | |
bool | value, | |||
bool | updateUi = false | |||
) |
Set a boolean option of this client
toggle | Options's id to set | |
value | Value to set | |
updateUi | True to update UI |
static bool addLogic | ( | ClientLogic * | logic | ) | [static] |
Add a logic to the list. The added object is not owned by the client
logic | Pointer to the logic to add |
static void removeLogic | ( | ClientLogic * | logic | ) | [static] |
Remove a logic from the list without destroying it
logic | Pointer to the logic to remove |
static ClientLogic* findLogic | ( | const String & | name | ) | [static] |
Convenience method to retrieve a logic
name | The logic's name |
static Message* eventMessage | ( | const String & | event, | |
Window * | wnd = 0 , |
|||
const char * | name = 0 , |
|||
NamedList * | params = 0 | |||
) | [static] |
Build an 'ui.event' message
event | Event's name | |
wnd | Optional window to add to message | |
name | Optional 'name' parameter value | |
params | Other optional parameters to be added to the message |
static bool save | ( | Configuration & | cfg, | |
Window * | parent = 0 , |
|||
bool | showErr = true | |||
) | [static] |
Save a configuration file. Call openMessage() on failure
cfg | The configuration file to save | |
parent | The parent of the error window if needded | |
showErr | True to open a message popup on failure |
static ClientToggle getBoolOpt | ( | const String & | name | ) | [static] |
Check if a string names a client's boolean option
name | String to check |
static void setLogicsTick | ( | ) | [inline, static] |
Set the flag indicating that the client should tick the logics
Get the protocol from a string
static const String& getProtocol | ( | int | proto | ) | [inline, static] |
Get the protocol name from an integer value
References String::empty().