forked from svedm/yate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
yatecbase.h
5993 lines (5292 loc) · 193 KB
/
yatecbase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* yatecbase.h
* This file is part of the YATE Project http://YATE.null.ro
*
* Common base classes for all telephony clients
*
* Yet Another Telephony Engine - a fully featured software PBX and IVR
* Copyright (C) 2004-2014 Null Team
*
* This software is distributed under multiple licenses;
* see the COPYING file in the main directory for licensing
* information for this specific distribution.
*
* This use of this software may be subject to additional restrictions.
* See the LEGAL file in the main directory for details.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef __YATECBASE_H
#define __YATECBASE_H
#ifndef __cplusplus
#error C++ is required
#endif
#include <yatephone.h>
/**
* Holds all Telephony Engine related classes.
*/
namespace TelEngine {
class Flags32; // Keeps a 32bit length flag mask
class NamedInt; // A named integer value
class Window; // A generic window
class UIWidget; // A custom widget
class UIFactory; // Base factory used to build custom widgets
class Client; // The client
class ClientChannel; // A client telephony channel
class ClientDriver; // The client telephony driver
class ClientLogic; // Base class for all client logics
class DefaultLogic; // The client's default logic
class ClientWizard; // A client wizard
class ClientAccount; // A client account
class ClientAccountList; // A client account list
class ClientContact; // A client contact
class ClientResource; // A client contact's resource
class MucRoomMember; // A MUC room member
class MucRoom; // An account's MUC room contact
class DurationUpdate; // Class used to update UI durations
class ClientSound; // A sound file
class ClientFileItem; // Base class for file/dir items
class ClientDir; // A directory
class ClientFile; // A file
/**
* This class keeps a 32bit length flag mask
* @short A 32 bit length list of flags
*/
class YATE_API Flags32
{
public:
/**
* Constructor
*/
inline Flags32()
: m_flags(0)
{}
/**
* Constructor
* @param value Flags value
*/
inline Flags32(u_int32_t value)
: m_flags(value)
{}
/**
* Retrieve flags value
* @return The flags
*/
inline u_int32_t flags() const
{ return m_flags; }
/**
* Set flags
* @param mask Flag(s) to set
*/
inline void set(u_int32_t mask)
{ m_flags = m_flags | mask; }
/**
* Reset flags
* @param mask Flag(s) to reset
*/
inline void reset(u_int32_t mask)
{ m_flags = m_flags & ~mask; }
/**
* Check if a mask of flags is set
* @param mask Flag(s) to check
* @return The flags of mask which are set, 0 if no mask flag is set
*/
inline u_int32_t flag(u_int32_t mask) const
{ return (m_flags & mask); }
/**
* Set or reset flags
* @param mask Flag(s)
* @param on True to set, false to reset
*/
inline void changeFlag(u_int32_t mask, bool on) {
if (on)
set(mask);
else
reset(mask);
}
/**
* Set or reset flags, check if changed
* @param mask Flag(s)
* @param ok True to set, false to reset
* @return True if any flag contained in mask changed
*/
inline bool changeFlagCheck(u_int32_t mask, bool ok) {
if ((0 != flag(mask)) == ok)
return false;
changeFlag(mask,ok);
return true;
}
/**
* Change flags
* @param value New flags value
*/
inline void change(u_int32_t value)
{ m_flags = value; }
/**
* Conversion to u_int32_t operator
*/
inline operator u_int32_t() const
{ return m_flags; }
/**
* Asignement from int operator
*/
inline const Flags32& operator=(int value)
{ m_flags = value; return *this; }
protected:
u_int32_t m_flags;
};
/**
* This class holds a name integer value
* @short A named integer value
*/
class YATE_API NamedInt: public String
{
YCLASS(NamedInt,String)
public:
/**
* Constructor
* @param name Name
* @param val The value
*/
inline NamedInt(const char* name, int val = 0)
: String(name), m_value(val)
{}
/**
* Copy constructor
* @param other Source object
*/
inline NamedInt(const NamedInt& other)
: String(other), m_value(other.value())
{}
/**
* Retrieve the value
* @return The integer value
*/
inline int value() const
{ return m_value; }
/**
* Set the value
* @param val The new integer value
*/
inline void setValue(int val)
{ m_value = val; }
/**
* Add an item to a list. Replace existing item with the same name
* @param list The list
* @param obj The object
*/
static void addToListUniqueName(ObjList& list, NamedInt* obj);
/**
* Clear all items with a given value
* @param list The list
* @param val Value to remove
*/
static void clearValue(ObjList& list, int val);
/**
* Get an item's value from name
* @param list The list containing the item
* @param name Item name
* @param defVal Value to return if not found
* @return Item value
*/
static inline int lookup(const ObjList& list, const String& name, int defVal = 0) {
ObjList* o = list.find(name);
return o ? (static_cast<NamedInt*>(o->get()))->value() : defVal;
}
/**
* Get an item's name from value
* @param list The list containing the item
* @param val Item value
* @param defVal Name to return if not found
* @return Item name
*/
static inline const String& lookupName(const ObjList& list, int val,
const String& defVal = String::empty()) {
for (ObjList* o = list.skipNull(); o; o = o->skipNext()) {
NamedInt* ni = static_cast<NamedInt*>(o->get());
if (ni->value() == val)
return *ni;
}
return defVal;
}
protected:
int m_value;
private:
NamedInt() {}
};
/**
* A window is the basic user interface element.
* Everything inside is implementation specific functionality.
* @short An abstract user interface window
*/
class YATE_API Window : public GenObject
{
YCLASS(Window,GenObject)
friend class Client;
YNOCOPY(Window); // no automatic copies please
public:
/**
* Constructor, creates a new windows with an ID
* @param id String identifier of the new window
*/
explicit Window(const char* id = 0);
/**
* Destructor
*/
virtual ~Window();
/**
* Retrieve the standard name of this Window, used to search in lists
* @return Identifier of this window
*/
virtual const String& toString() const;
/*
* Get the window's title (may not be displayed on screen)
* @return Title of this window
*/
virtual void title(const String& text);
/**
* Set the contextual information previously associated with this window
* @param text New contextual information
*/
virtual void context(const String& text);
/**
* Set window parameters or widget contents
* @param params List of parameters to set in the window and its widgets
* @return True if all parameters could be set
*/
virtual bool setParams(const NamedList& params);
/**
* Force this window on top of another one which becomes its parent
* @param parent Window to force as parent of this one
*/
virtual void setOver(const Window* parent) = 0;
/**
* Check if this window has an element by name
* @param name Name of the element to search for
* @return True if one element with the given name exists
*/
virtual bool hasElement(const String& name) = 0;
/**
* Set an element as interactive in the window
* @param name Name of the element
* @param active True to make interactive, false to disallow interaction
* @return True if the operation was successfull
*/
virtual bool setActive(const String& name, bool active) = 0;
/**
* Set an element as receiving input in the window
* @param name Name of the element
* @param select Also select the content of the focused element
* @return True if the operation was successfull
*/
virtual bool setFocus(const String& name, bool select = false) = 0;
/**
* Set the visibility of an element in the window
* @param name Name of the element
* @param visible True to make element visible, false to hide it
* @return True if the operation was successfull
*/
virtual bool setShow(const String& name, bool visible) = 0;
/**
* Set the displayed text of an element in the window
* @param name Name of the element
* @param text Text value to set in the element
* @param richText True if the text contains format data
* @return True if the operation was successfull
*/
virtual bool setText(const String& name, const String& text,
bool richText = false) = 0;
/**
* Set the checked or toggled status of an element in the window
* @param name Name of the element
* @param checked True to make element checked or toggled
* @return True if the operation was successfull
*/
virtual bool setCheck(const String& name, bool checked) = 0;
/**
* Set the selection of an item in an element in the window
* @param name Name of the element
* @param item Name of the item that should be selected
* @return True if the operation was successfull
*/
virtual bool setSelect(const String& name, const String& item) = 0;
/**
* Flag an element as requiring immediate attention
* @param name Name of the element
* @param urgent True if the element requires immediate attention
* @return True if the operation was successfull
*/
virtual bool setUrgent(const String& name, bool urgent) = 0;
/**
* Check if an element has an item by its name
* @param name Name of the element to search for
* @param item Name of the item that should be searched
* @return True if one item with the given name exists in the element
*/
virtual bool hasOption(const String& name, const String& item) = 0;
/**
* Add an item to an element that supports such an operation (list)
* @param name Name of the element
* @param item Name of the item to add
* @param atStart True to insert item on the first position, false to append
* @param text Displayed text to associate with the item (not all lists support it)
* @return True if the operation was successfull
*/
virtual bool addOption(const String& name, const String& item, bool atStart = false,
const String& text = String::empty()) = 0;
/**
* Get an element's items
* @param name Name of the element to search for
* @param items List to fill with element's items
* @return True if the element exists
*/
virtual bool getOptions(const String& name, NamedList* items) = 0;
/**
* Remove an item from an element (list)
* @param name Name of the element
* @param item Name of the item to remove
* @return True if the operation was successfull
*/
virtual bool delOption(const String& name, const String& item) = 0;
/**
* Append or insert text lines to a widget
* @param name The name of the widget
* @param lines List containing the lines
* @param max The maximum number of lines allowed to be displayed. Set to 0 to ignore
* @param atStart True to insert, false to append
* @return True on success
*/
virtual bool addLines(const String& name, const NamedList* lines, unsigned int max,
bool atStart = false);
/**
* Add a row to a table owned by this window
* @param name Name of the element
* @param item Name of the item to add
* @param data Table's columns to set
* @param atStart True to insert, false to append
* @return True if the operation was successfull
*/
virtual bool addTableRow(const String& name, const String& item,
const NamedList* data = 0, bool atStart = false);
/**
* Append or update several table rows at once
* @param name Name of the element
* @param data Parameters to initialize the rows with
* @param prefix Prefix to match (and remove) in parameter names
* @return True if all the operations were successfull
*/
virtual bool setMultipleRows(const String& name, const NamedList& data, const String& prefix = String::empty());
/**
* Insert a row into a table owned by this window
* @param name Name of the element
* @param item Name of the item to insert
* @param before Name of the item to insert before
* @param data Table's columns to set
* @return True if the operation was successfull
*/
virtual bool insertTableRow(const String& name, const String& item,
const String& before, const NamedList* data = 0);
/**
* Delete a row from a table owned by this window
* @param name Name of the element
* @param item Name of the item to remove
* @return True if the operation was successfull
*/
virtual bool delTableRow(const String& name, const String& item);
/**
* Update a row from a table owned by this window
* @param name Name of the element
* @param item Name of the item to update
* @param data Data to update
* @return True if the operation was successfull
*/
virtual bool setTableRow(const String& name, const String& item, const NamedList* data);
/**
* Set a table row or add a new one if not found
* @param name Name of the element
* @param item Table item to set/add
* @param data Optional list of parameters used to set row data
* @param atStart True to add item at start, false to add them to the end
* @return True if the operation was successfull
*/
virtual bool updateTableRow(const String& name, const String& item,
const NamedList* data = 0, bool atStart = false);
/**
* Add or set one or more table row(s). Screen update is locked while changing the table.
* Each data list element is a NamedPointer carrying a NamedList with item parameters.
* The name of an element is the item to update.
* Set element's value to boolean value 'true' to add a new item if not found
* or 'false' to set an existing one. Set it to empty string to delete the item
* @param name Name of the table
* @param data The list of items to add/set/delete
* @param atStart True to add new items at start, false to add them to the end
* @return True if the operation was successfull
*/
virtual bool updateTableRows(const String& name, const NamedList* data,
bool atStart = false);
/**
* Retrieve a row from a table owned by this window
* @param name Name of the element
* @param item Name of the item to retrieve
* @param data List to fill with table's columns contents
* @return True if the operation was successfull
*/
virtual bool getTableRow(const String& name, const String& item, NamedList* data = 0);
/**
* Clear (delete all rows) a table owned by this window
* @param name Name of the element
* @return True if the operation was successfull
*/
virtual bool clearTable(const String& name);
/**
* Show or hide control busy state
* @param name Name of the element
* @param on True to show, false to hide
* @return True if all the operations were successfull
*/
virtual bool setBusy(const String& name, bool on) = 0;
/**
* Get an element's text
* @param name Name of the element
* @param text The destination string
* @param richText True to get the element's roch text if supported.
* @return True if the operation was successfull
*/
virtual bool getText(const String& name, String& text, bool richText = false) = 0;
/**
* Get the checked state of a checkable control
* @param name Name of the element
* @param checked The checked state of the control
* @return True if the operation was successfull
*/
virtual bool getCheck(const String& name, bool& checked) = 0;
/**
* Retrieve an element's selection
* @param name Name of the element
* @param item String to fill with selection's contents
* @return True if the operation was successfull
*/
virtual bool getSelect(const String& name, String& item) = 0;
/**
* Retrieve an element's multiple selection
* @param name Name of the element
* @param items List to be to filled with selection's contents
* @return True if the operation was successfull
*/
virtual bool getSelect(const String& name, NamedList& items) = 0;
/**
* Build a menu from a list of parameters.
* See Client::buildMenu() for more info
* @param params Menu build parameters
* @return True on success
*/
virtual bool buildMenu(const NamedList& params) = 0;
/**
* Remove a menu (from UI and memory)
* See Client::removeMenu() for more info
* @param params Menu remove parameters
* @return True on success
*/
virtual bool removeMenu(const NamedList& params) = 0;
/**
* Set an element's image
* @param name Name of the element
* @param image Image to set
* @param fit Fit image in element (defaults to false)
* @return True on success
*/
virtual bool setImage(const String& name, const String& image, bool fit = false) = 0;
/**
* Set a property for this window or for a widget owned by it
* @param name Name of the element
* @param item Property's name
* @param value Property's value
* @return True on success
*/
virtual bool setProperty(const String& name, const String& item, const String& value)
{ return false; }
/**
* Get a property from this window or from a widget owned by it
* @param name Name of the element
* @param item Property's name
* @param value Property's value
* @return True on success
*/
virtual bool getProperty(const String& name, const String& item, String& value)
{ return false; }
/**
* Populate the window if not already done
*/
inline void populate() {
if (m_populated)
return;
doPopulate();
m_populated = true;
}
/**
* Initialize the window if not already done
*/
inline void init() {
if (m_initialized)
return;
doInit();
m_initialized = true;
}
/**
* Show this window
*/
virtual void show() = 0;
/**
* Hide this window
*/
virtual void hide() = 0;
/**
* Resize this window
* @param width The new width
* @param height The new width
*/
virtual void size(int width, int height) = 0;
/**
* Move this window
* @param x The x coordinate of the upper left corner
* @param y The y coordinate of the upper left corner
*/
virtual void move(int x, int y) = 0;
/**
* Move this window related to its current position
* @param dx The value to be added to the current x coordinate of the upper left corner
* @param dy The value to be added to the current y coordinate of the upper left corner
*/
virtual void moveRel(int dx, int dy) = 0;
/**
* Checkes if this window is related to the given window
* @param wnd The window to check for any relation
* @return False if wnd is this window or a master one
*/
virtual bool related(const Window* wnd) const;
virtual void menu(int x, int y) = 0;
/**
* Check if this window can be closed
* @return True if this window can be closed, false to prevent hiding it
*/
virtual bool canClose()
{ return true; }
/**
* Retrieve the standard name of this Window
* @return Identifier of this window
*/
inline const String& id() const
{ return m_id; }
/*
* Get the window's title (may not be displayed on screen)
* @return Title of this window
*/
inline const String& title() const
{ return m_title; }
/**
* Get the contextual information previously associated with this window
* @return String contextual information
*/
inline const String& context() const
{ return m_context; }
/**
* Get the visibility status of this window
* @return True if window is visible, false if it's hidden
*/
inline bool visible() const
{ return m_visible; }
/**
* Set the visibility status of this window
* @param yes True if window should be visible
*/
inline void visible(bool yes)
{ if (yes) show(); else hide(); }
/**
* Check if this window is the active one
* @return True if window is active
*/
inline bool active() const
{ return m_active; }
/**
* Check if this window is a master (topmost) window
* @return True if this window is topmost
*/
inline bool master() const
{ return m_master; }
/**
* Check if this window is a popup window
* @return True if this window is initially hidden
*/
inline bool popup() const
{ return m_popup; }
/**
* Create a modal dialog
* @param name Dialog name (resource config section)
* @param title Dialog title
* @param alias Optional dialog alias (used as dialog object name)
* @param params Optional dialog parameters
* @return True on success
*/
virtual bool createDialog(const String& name, const String& title,
const String& alias = String::empty(), const NamedList* params = 0) = 0;
/**
* Destroy a modal dialog
* @param name Dialog name
* @return True on success
*/
virtual bool closeDialog(const String& name) = 0;
/**
* Check if a string is a parameter prefix handled by setParams().
* Exact prefix match is not a valid one
* @param prefix String to check
* @return True if the given prefix is a valid one
*/
static bool isValidParamPrefix(const String& prefix);
protected:
virtual void doPopulate() = 0;
virtual void doInit() = 0;
String m_id;
String m_title;
String m_context;
bool m_visible;
bool m_active;
bool m_master;
bool m_popup;
bool m_saveOnClose; // Save window's data when destroyed
private:
bool m_populated; // Already populated flag
bool m_initialized; // Already initialized flag
};
class YATE_API UIWidget : public String
{
YCLASS(UIWidget,String)
YNOCOPY(UIWidget); // no automatic copies please
public:
/**
* Constructor, creates a new widget
* @param name The widget's name
*/
inline explicit UIWidget(const char* name = 0)
: String(name)
{ }
/**
* Destructor
*/
virtual ~UIWidget()
{ }
/**
* Retrieve the standard name of this Window
* @return Identifier of this window
*/
inline const String& name() const
{ return toString(); }
/**
* Set widget's parameters
* @param params List of parameters
* @return True if all parameters could be set
*/
virtual bool setParams(const NamedList& params)
{ return false; }
/**
* Get widget's items
* @param items List to fill with widget's items
* @return False on failure (e.g. not initialized)
*/
virtual bool getOptions(NamedList& items)
{ return false; }
/**
* Add a row to a table
* @param item Name of the item to add
* @param data Table's columns to set
* @param atStart True to insert, false to append
* @return True if the operation was successfull
*/
virtual bool addTableRow(const String& item, const NamedList* data = 0,
bool atStart = false)
{ return false; }
/** Append or update several table rows at once
* @param data Parameters to initialize the rows with
* @param prefix Prefix to match (and remove) in parameter names
* @return True if all the operations were successfull
*/
virtual bool setMultipleRows(const NamedList& data, const String& prefix = String::empty())
{ return false; }
/**
* Add or set one or more table row(s). Screen update is locked while changing the table.
* Each data list element is a NamedPointer carrying a NamedList with item parameters.
* The name of an element is the item to update.
* Set element's value to boolean value 'true' to add a new item if not found
* or 'false' to set an existing one. Set it to empty string to delete the item
* @param data The list of items to add/set/delete
* @param atStart True to add new items at start, false to add them to the end
* @return True if the operation was successfull
*/
virtual bool updateTableRows(const NamedList* data, bool atStart = false)
{ return false; }
/**
* Insert a row into a table
* @param item Name of the item to insert
* @param before Name of the item to insert before
* @param data Table's columns to set
* @return True if the operation was successfull
*/
virtual bool insertTableRow(const String& item, const String& before,
const NamedList* data = 0)
{ return false; }
/**
* Delete a row from a table
* @param item Name of the item to remove
* @return True if the operation was successfull
*/
virtual bool delTableRow(const String& item)
{ return false; }
/**
* Update a table's row
* @param item Name of the item to update
* @param data Data to update
* @return True if the operation was successfull
*/
virtual bool setTableRow(const String& item, const NamedList* data)
{ return false; }
/**
* Retrieve a row from a table
* @param item Name of the item to retrieve
* @param data List to fill with table's columns contents
* @return True if the operation was successfull
*/
virtual bool getTableRow(const String& item, NamedList* data = 0)
{ return false; }
/**
* Clear (delete all rows) a table
* @return True if the operation was successfull
*/
virtual bool clearTable()
{ return false; }
/**
* Set the widget's selection
* @param item String containing the new selection
* @return True if the operation was successfull
*/
virtual bool setSelect(const String& item)
{ return false; }
/**
* Retrieve the widget's selection
* @param item String to fill with selection's contents
* @return True if the operation was successfull
*/
virtual bool getSelect(String& item)
{ return false; }
/**
* Retrieve widget's multiple selection
* @param items List to be to filled with selection's contents
* @return True if the operation was successfull
*/
virtual bool getSelect(NamedList& items)
{ return false; }
/**
* Append or insert text lines to this widget
* @param lines List containing the lines
* @param max The maximum number of lines allowed to be displayed. Set to 0 to ignore
* @param atStart True to insert, false to append
* @return True on success
*/
virtual bool addLines(const NamedList& lines, unsigned int max, bool atStart = false)
{ return false; }
/**
* Set the displayed text of this widget
* @param text Text value to set
* @param richText True if the text contains format data
* @return True on success
*/
virtual bool setText(const String& text, bool richText = false)
{ return false; }
/**
* Retrieve the displayed text of this widget
* @param text Text value
* @param richText True to retrieve formatted data
* @return True on success
*/
virtual bool getText(String& text, bool richText = false)
{ return false; }
/**
* Show or hide control busy state
* @param on True to show, false to hide
* @return True if all the operations were successfull
*/
virtual bool setBusy(bool on)
{ return false; }
};
/**
* Each instance of UIFactory creates special user interface elements by type.
* Keeps a global list with all factories. The list doesn't own the facotries
* @short A static user interface creator
*/
class YATE_API UIFactory : public String
{
YCLASS(UIFactory,String)
YNOCOPY(UIFactory); // no automatic copies please
public:
/**
* Constructor. Append itself to the factories list
*/
explicit UIFactory(const char* name);
/**
* Destructor. Remove itself from list
*/
virtual ~UIFactory();
/**
* Check if this factory can build an object of a given type
* @param type Object type to check
* @return True if this factory can build the object
*/
inline bool canBuild(const String& type)
{ return 0 != m_types.find(type); }
/**
* Ask this factory to create an object of a given type
* @param type Object's type
* @param name Object' name
* @param params Optional object parameters
* @return Valid pointer or 0 if failed to build it
*/
virtual void* create(const String& type, const char* name, NamedList* params = 0) = 0;
/**
* Ask all factories to create an object of a given type
* @param type Object's type
* @param name Object' name
* @param params Optional object parameters
* @param factory Optional factory name used to create the requested object. If non 0,
* this will be the only factory asked to create the object
* @return Valid pointer or 0 if failed to build it
*/
static void* build(const String& type, const char* name, NamedList* params = 0,
const char* factory = 0);
protected:
ObjList m_types; // List of object types this factory can build
private:
static ObjList s_factories; // Registered factories list
};
/**
* Singleton class that holds the User Interface's main methods
* @short Class that runs the User Interface
*/
class YATE_API Client : public MessageReceiver
{
YCLASS(Client,MessageReceiver)
friend class Window;
friend class ClientChannel;
friend class ClientDriver;
friend class ClientLogic;
public: