sipXcallLib home page


PtTerminal.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 
12 #ifndef _PtTerminal_h_
13 #define _PtTerminal_h_
14 
15 // SYSTEM INCLUDES
16 // APPLICATION INCLUDES
17 #include "ptapi/PtDefs.h"
18 #include "tao/TaoDefs.h"
19 #include "os/OsBSem.h"
20 #include "os/OsProtectEventMgr.h"
21 
22 // DEFINES
23 #define PTTERMINAL_MAX_NAME_LENGTH 128
24 // MACROS
25 // EXTERNAL FUNCTIONS
26 // EXTERNAL VARIABLES
27 // CONSTANTS
28 // STRUCTS
29 // TYPEDEFS
30 // FORWARD DECLARATIONS
31 class PtCallListener;
32 class PtTerminalListener;
34 class PtAddress;
35 class PtComponent;
36 class PtConfigDb;
37 class PtProvider;
38 class PtGatewayInterface;
39 class PtComponentGroup;
40 class TaoClientTask;
41 class TaoServerTask;
42 class TaoReference;
43 class TaoObjectMap;
44 
45 
46 //:A PtTerminal represents a physical hardware endpoint connected to the
47 //:telephony domain (that is, a computer workstation or a Pingtel phone
48 //:acting as a physical endpoint in a telephony network).
49 // A PtTerminal object has a string name that is unique for all PtTerminal
50 // objects . The PtTerminal does not attempt to interpret this string in any
51 // way. This name is first assigned when the PtTerminal is created and does
52 // not change throughout the lifetime of the object. The method
53 // PtTerminal.getName() returns the name of the PtTerminal object. The name
54 // of the PtTerminal may not have any real-world interpretation. Typically,
55 // PtTerminals are chosen from a list of PtTerminals obtained from a
56 // PtAddress object.
57 // <p>
58 // Like PtAddresses, PtTerminal objects may be classified into two
59 // categories: local and remote.
60 // <p>
61 // <ul>
62 // <li> <b>Local terminal objects</b> are those terminals that are part of the
63 // provider's local domain. These terminal objects are created by the
64 // implementation of
65 // the provider object when it is first instantiated. All of the provider's
66 // currently known local terminals are reported via the
67 // PtProvider.getTerminals() method. </li><br>
68 // <li>
69 // <b>Remote terminal objects</b> are those outside
70 // of the provider's domain which the provider learns about during its
71 // lifetime through various happenings (such as an incoming call from a
72 // currently unknown address). Remote terminal objects are not reported via
73 // the PtProvider.getTerminals() method. </li>
74 // </ul>
75 // <p>Note that applications may not
76 // create PtTerminal objects. The PtProvider begins with knowledge of certain
77 // PtTerminal objects within its local domain. This list is quasi-static,
78 // changing only as physical endpoints are added and removed in the phone
79 // system.
80 //
81 // <H3>PtTerminal and PtAddress objects</H3>
82 // PtAddress and PtTerminal objects exist in a many-to-many relationship. A
83 // PtAddress object may have zero or more PtTerminals associated with it. For
84 // each PtTerminal associated with a PtAddress, that PtTerminal must also
85 // reflect its association with the PtAddress. The PtTerminals associated with
86 // a PtAddress are given by the PtAddress.getTerminals() method.<br>
87 // <br>
88 // An association between a PtAddress and PtTerminal object indicates that
89 // the PtTerminal contains the PtAddress object as one of its telephone number
90 // addresses. In many instances, a telephone set (represented by a PtTerminal
91 // object) has only one telephone number (represented by a PtAddress object)
92 // associated with it. In more complex configurations, telephone sets may have
93 // several telephone numbers associated with them. Likewise, a telephone
94 // number may appear on more than one telephone set. For example, feature
95 // phones in PBX environments may exhibit this configuration.
96 //
97 // <H3>PtTerminal and PtCall objects</H3>
98 // PtTerminal objects represent the physical endpoints of a telephone call.
99 // With respect to a single PtAddress endpoint on a PtCall, multiple physical
100 // PtTerminal endpoints may exist. PtTerminal objects are related to PtCall
101 // objects via the PtTerminalConnection object. PtTerminalConnection objects
102 // are associated with the PtCall indirectly via PtConnections. A PtTerminal
103 // may be associated with a PtCall only if one of its addresses is associated
104 // with the call. The PtTerminalConnection object has a state that describes
105 // the current relationship between the PtConnection and the PtTerminal. Each
106 // PtTerminal object may be part of more than one telephone call, and in each
107 // case, is represented by a separate PtTerminalConnection object. The
108 // PtTerminal.getTerminalConnections() method returns all PtTerminalConnection
109 // objects currently associated with the PtTerminal.<br>
110 // <br>
111 // A PtTerminal object is associated with a PtConnection until the
112 // PtTerminalConnection moves into the PtTerminalConnection::DROPPED state.
113 // At that time, the PtTerminalConnection is no longer reported via the
114 // PtTerminal.getTerminalConnections() method. Therefore, the
115 // PtTerminal.getTerminalConnections() method never reports a
116 // PtTerminalConnection in the PtTerminalConnection::DROPPED state.
117 //
118 // <H3>PtTerminal Components</H3>
119 // Applications may query each PtTerminal for the components of which it is
120 // made and may monitor and control certain attributes of these components.
121 // The component types that are presently supported include speakerphone,
122 // microphone, display, buttons, ringer, handset, hookswitch, and lamp. Each
123 // component type is derived from the PtComponent base class and exports a
124 // standard interface to control its attributes. For example, the ringer
125 // permits applications to control its volume, while the buttons permit
126 // applications to simulate pressing buttons.
127 //
128 // <H3>Terminal Listeners and Events</H3>
129 // All changes in a PtTerminal object are reported via PtTerminalListener
130 // objects. Applications instantiate an object which is derived from the
131 // PtTerminalListener class and use the PtTerminal.addTerminalListener()
132 // method to begin the delivery of events. All terminal-related events
133 // reported via a PtTerminalListener are instances of either the
134 // PtTerminalEvent class or its descendants. Applications receive events on
135 // a listener until the
136 // listener is removed via the PtTerminal.removeTerminalListener() method or
137 // until the PtTerminal is no longer observable. In these instances, each
138 // PtTerminalListener receives a TERMINAL_EVENT_TRANSMISSION_ENDED event as
139 // its final event.<br>
140 // <br>
141 // To receive event reports regarding the PtTerminal's components (such as
142 // hookswitch state changes or button presses), applications instantiate
143 // an object which is derived from the PtTerminalComponentListener class
144 // and use the PtTerminal.addTerminalListener() method to begin the delivery
145 // of events. Since the PtTerminalComponentListener is a descendant of the
146 // PtTerminalListener class, it receives event reports for changes in the
147 // PtTerminal object as well as changes in the PtTerminal's component objects.
148 //
149 // <H3>Call Listeners</H3>
150 // At times, applications may want to monitor a particular PtTerminal for all
151 // calls which come to that terminal. For example, a desktop telephone
152 // application may only be interested in telephone calls associated with a
153 // particular agent terminal. To achieve this sort of terminal-based call
154 // monitoring, applications may add PtCallListeners to a PtTerminal via the
155 // PtTerminal.addCallListener() method.<br>
156 // <br>
157 // When a PtCallListener is added to a PtTerminal, this listener instance
158 // is immediately added to all calls at this terminal, and is added to all
159 // calls which come to this terminal in the future. These listeners remain on
160 // the telephone call as long as the terminal is associated with the
161 // telephone call.
162 //
163 // <H3>Do Not Disturb</H3>
164 // The PtTerminal class defines the <i>do-not-disturb</i> attribute. The
165 // <i>do-not-disturb</i> attribute indicates to the telephony platform that
166 // this terminal does not want to be bothered with incoming telephone calls.
167 // That is, if this feature is activated, the underlying telephone platform
168 // will not ring this terminal for incoming telephone calls. Applications use
169 // the PtTerminal.setDoNotDisturb() method to activate and deactivate this
170 // feature and the PtTerminal.getDoNotDisturb() method to return the current
171 // state of this attribute.<br>
172 // <br>
173 // Note that the PtAddress class also carries the <i>do-not-disturb</i>
174 // attribute. The attributes associated with each class are maintained
175 // independently. Maintaining a separate <i>do-not-disturb</i> attribute at
176 // both the terminal and address allows for control over the
177 // <i>do-not-disturb</i> feature at either the terminal or address level.
179 {
180 /* //////////////////////////// PUBLIC //////////////////////////////////// */
181 public:
182 
183 /* ============================ CREATORS ================================== */
184 
185  PtTerminal();
186  //:Default constructor
187 
188  PtTerminal(const char* terminalName, TaoClientTask *pClient = NULL);
189 
190  virtual
191  ~PtTerminal();
192  //:Destructor
193 
194  PtTerminal(const PtTerminal& rPtTerminal);
195  //:Copy constructor (not implemented for this class)
196 
197  PtTerminal& operator=(const PtTerminal& rhs);
198  //:Assignment operator (not implemented for this class)
199 
200 /* ============================ MANIPULATORS ============================== */
201 
202  virtual PtStatus addCallListener(PtCallListener& rCallListener);
203  //:Adds a listener to a PtCall object when this PtTerminal object first
204  //:becomes part of that PtCall.
209 
210  virtual PtStatus addTerminalListener(PtTerminalListener& rTerminalListener);
211  //:Adds a listener to this terminal.
216 
217  PtStatus setGatewayInterface(PtGatewayInterface& rGatewayInterface);
218  //: Indicate that this terminal is a gateway and that audio media
219  //: streams capabilities and setup is performed via this interface.
224 
225  virtual PtStatus pickup(PtAddress& rPickupAddress, PtAddress& rTerminalAddress,
226  PtTerminalConnection*& rpNewTermConnection);
227  //:This method "picks up" a PtCall at this PtTerminal.
228  // Picking up a PtCall is analogous to answering a PtCall at this
229  // PtTerminal (i.e., PtTerminalConnection.answer()), except that the
230  // PtCall is typically not ringing at this PtTerminal. For example,
231  // this method is used to answer a "queued" PtCall or a PtCall that is
232  // ringing at another PtTerminal across the room.<br>
233  // <br>
234  // The <i>rPickupAddress</i> represents the destination end of the
235  // telephone call to be picked up. The corresponding PtConnection must
236  // be in either the PtConnection::QUEUED state or the
237  // PtConnection.ALERTING state. The <i>rTerminalAddress</i> argument
238  // chooses the PtAddress associated with this PtTerminal on which to
239  // pick up the PtCall. If this method succeeds, <i>rpNewTermConnection</i>
240  // is set to point to a new PtTerminalConnection that is in the
241  // PtTerminalConnection::TALKING state.
248 
249  virtual PtStatus removeCallListener(PtCallListener& rCallListener);
250  //:Removes the indicated PtCallListener from the PtTerminal.
251  // This method removes a PtCallListener that was added via the
252  // PtTerminal.addCallListener() method. If successful, the listener will
253  // no longer be added to new calls which are presented to this terminal,
254  // however it does not affect PtCallListeners that have already been
255  // added to a call.
260 
261  virtual PtStatus removeTerminalListener(PtTerminalListener& rTerminalListener);
262  //:Removes the indicated listener from the PtTerminal.
267 
268  virtual PtStatus setDoNotDisturb(PtBoolean flag);
269  //:Specifies whether the <i>do-not-disturb</i> feature should be
270  //:activated or deactivated for this terminal.
274 
275  virtual PtStatus setCodecCPULimit(int limit);
276  //:Sets the codec CPU limit level for inbound calls.
278  // be set to LOW (0) or HIGH (1). If set to LOW, only LOW CPU
279  // intensive codecs are allowed. If set to HIGH, both LOW and
280  // HIGH CPU intensive codes are allowed.
283 
284 
285 /* ============================ ACCESSORS ================================= */
286 
287  virtual PtStatus getAddresses(PtAddress addresses[], int size, int& nItems);
288  //:Returns an array of PtAddress objects associated with this
289  //:terminal.
290  // The caller provides an array that can hold up to <i>size</i>
291  // PtAddresses. This method will fill in the <i>aAddresses</i>
292  // array with up to <i>size</i> pointers. The actual number of items
293  // filled in is passed back via the <i>nItems</i> argument.
300 
301  virtual PtStatus getCallListeners(PtCallListener aCallListeners[], int size,
302  int& nItems);
303  //:Returns an array of PtCallListener,s for all of the call
304  //:listeners presently associated with this terminal.
305  // The caller provides an array that can hold up to <i>size</i>
306  // PtCallListener's. This method will fill in the
307  // <i>aCallListeners</i> array with up to <i>size</i> PtCallListener's. The
308  // actual number items filled in is passed back via the
309  // <i>nItems</i> argument.
316 
317  virtual PtStatus getComponent(const char* componentName, PtComponent& rComponent);
318  //:Sets <i>rpComponent</i> to refer to the PtComponent object that
319  //:corresponds to <i>componentName</i> or NULL if there is no
320  //:component with that name.
325 
326  virtual PtStatus getComponents(PtComponent* components[], int size, int& nItems);
327  //:Returns an array of PtComponent's for all of the objects used
328  //:to model the telephony hardware associated with this terminal.
329  // The caller provides an array that can hold up to <i>size</i>
330  // PtComponent's. This method will fill in the <i>components</i>
331  // array with up to <i>size</i> objects. The actual number of objects
332  // filled in is passed back via the <i>nItems</i> argument.
339 
340  virtual PtStatus getComponentGroups(PtComponentGroup componentGroup[], int size, int& nItems);
341  //:Returns an array of ComponentGroup objects available on the Terminal. A
342  //:ComponentGroup object is composed of a number of Components.
343  //:Examples of Component objects include headsets, handsets,
344  // speakerphones, and buttons. ComponentGroup objects group Components
345  // together.
352 
353  virtual PtStatus getConfiguration(PtConfigDb& rpConfigDb);
354  //:Sets <i>rpConfigDb</i> to refer to the configuration object for
355  //:this PtTerminal.
356  // See the PtConfigDb class for information on getting and setting
357  // configuration information.
360 
361  virtual PtStatus getDoNotDisturb(PtBoolean& rFlag);
362  //:Returns the current setting for the <i>do-not-disturb</i> feature.
366 
367  PtStatus getName(char* rpName, int maxLen);
368  //:Returns the name associated with this PtTerminal.
372 
373  virtual PtStatus getTerminalListeners(PtTerminalListener aTermListeners[],
374  int size, int& nItems);
375  //:Returns an array of PtTerminalListener's for all of the
376  //:terminal listeners presently associated with this terminal.
377  // The caller provides an array that can hold up to <i>size</i>
378  // PtTerminalListener's. This method will fill in the
379  // <i>termListeners</i> array with up to <i>size</i> objects. The
380  // actual number of pointers filled in is passed back via the
381  // <i>nItems</i> argument.
388 
389  virtual PtStatus getProvider(PtProvider& rpProvider);
390  //:Returns a reference to the PtProvider associated with this PtTerminal.
394 
395  virtual PtStatus getTerminalConnections(PtTerminalConnection termConnections[],
396  int size, int& nItems);
397  //:Returns an array of PtTerminalConnection's for all of the
398  //:terminal connections currently associated with this terminal.
399  // The caller provides an array that can hold up to <i>size</i>
400  // PtTerminalConnection's. This method will fill in the
401  // <i>termConnections</i> array with up to <i>size</i> objects. The
402  // actual number of items filled in is passed back via the <i>nItems</i>
403  // argument.
410 
411  virtual PtStatus numAddresses(int& count);
412  //:Returns the number of addresses associated with this terminal.
416 
417  virtual PtStatus numCallListeners(int& count);
418  //:Returns the number of call listeners associated with this terminal.
422 
423  virtual PtStatus numComponents(int& count);
424  //:Returns the number of components associated with this terminal.
428 
429  virtual PtStatus numTerminalConnections(int& count);
430  //:Returns the number of terminal connections associated with this terminal.
434 
435  virtual PtStatus numTerminalListeners(int& count);
436  //:Returns the number of terminal listeners associated with this terminal.
440 
441 /* ============================ INQUIRY =================================== */
442 
443 /* //////////////////////////// PROTECTED ///////////////////////////////// */
444 
445 friend class PtProvider;
446 friend class PtTerminalConnection;
447 friend class PtTerminalEvent;
448 
449 /* //////////////////////////// PRIVATE /////////////////////////////////// */
450 protected:
451  OsTime mTimeOut;
452 
453  void initialize(const char *name);
454 
455  static OsBSem semInit ;
456  //: Binary Semaphore used to guard initialiation and tear down
458  static TaoObjectMap *mpComponents; // the database for all existing components
459  static TaoObjectMap *mpComponentGroups; // the database for all existing components
460  static int mRef;
461 
464 
466  {
467  HEAD_SET = 1,
481  };
482 
483 private:
484  OsProtectEventMgr *mpEventMgr;
485 
486  void setName(const char *name);
487 
488 
489 };
490 
491 /* ============================ INLINE METHODS ============================ */
492 
493 #endif // _PtTerminal_h_
Definition: TaoReference.h:35
virtual PtStatus getCallListeners(PtCallListener aCallListeners[], int size, int &nItems)
param: (out) aAddresses - The array of PtAddress&#39;s param: (in) size - The number of elements in the a...
Definition: PtTerminal.cpp:334
PtStatus
Definition: PtDefs.h:49
void initialize(const char *name)
Definition: PtTerminal.cpp:1692
static TaoObjectMap * mpComponentGroups
Definition: PtTerminal.h:459
Definition: PtTerminal.h:475
PtStatus setGatewayInterface(PtGatewayInterface &rGatewayInterface)
param: (in) rTerminalListener - The listener to add to this terminal retcode: PT_SUCCESS - Success re...
PtComponentId
Definition: PtTerminal.h:465
#define PTTERMINAL_MAX_NAME_LENGTH
Definition: PtTerminal.h:23
Definition: TaoObjectMap.h:56
Definition: PtTerminal.h:473
virtual PtStatus numAddresses(int &count)
param: (out) aTermConnections - The array of PtTerminalConnection objects param: (in) size - The numb...
Definition: PtTerminal.cpp:1160
Definition: PtTerminal.h:479
int PtBoolean
Definition: PtDefs.h:71
OsTime mTimeOut
Definition: PtTerminal.h:451
Definition: PtTerminal.h:474
static int mRef
Definition: PtTerminal.h:460
virtual PtStatus numCallListeners(int &count)
param: (out) count - The number of addresses associated with this terminal retcode: PT_SUCCESS - Succ...
Definition: PtTerminal.cpp:1210
Definition: PtTerminal.h:472
virtual PtStatus getTerminalConnections(PtTerminalConnection termConnections[], int size, int &nItems)
param: (out) rpProvider - a reference to the PtProvider object associated with this terminal retcode:...
Definition: PtTerminal.cpp:998
OsProtectEventMgr * mpEventMgr
Definition: PtTerminal.h:484
virtual PtStatus getConfiguration(PtConfigDb &rpConfigDb)
param: (out) pComponentGroup - The array of PtComponetGroups param: (in) size - The number of element...
Definition: PtTerminal.cpp:913
Definition: PtTerminal.h:480
static OsBSem semInit
Definition: PtTerminal.h:455
virtual PtStatus numTerminalListeners(int &count)
param: (out) count - The number of terminal connections associated with this terminal retcode: PT_SUC...
Definition: PtTerminal.cpp:1312
virtual PtStatus pickup(PtAddress &rPickupAddress, PtAddress &rTerminalAddress, PtTerminalConnection *&rpNewTermConnection)
param: (in) rGatewayInterface - reference to the gateway interface on which media setup methods are i...
Definition: PtTerminal.cpp:1412
virtual PtStatus setCodecCPULimit(int limit)
param: (in) flag - TRUE ==> enable, FALSE ==> disable retcode: PT_SUCCESS - Success retcode: PT_PROVI...
Definition: PtTerminal.cpp:1623
Definition: PtConfigDb.h:33
Definition: PtTerminal.h:477
Definition: PtCallListener.h:33
virtual PtStatus removeCallListener(PtCallListener &rCallListener)
param: rPickupAddress - The PtAddress that is to be picked up param: rTerminalAddress - The PtAddress...
Definition: PtTerminal.cpp:1462
Definition: PtComponent.h:30
virtual PtStatus addTerminalListener(PtTerminalListener &rTerminalListener)
param: (in) rCallListener - the listener to add to calls associated with this terminal retcode: PT_SU...
Definition: PtTerminal.cpp:210
virtual PtStatus getProvider(PtProvider &rpProvider)
param: (out) aTermListeners - The array of known terminal listeners param: (in) size - The number of ...
Definition: PtTerminal.cpp:1117
Definition: PtTerminal.h:476
Definition: PtTerminal.h:467
virtual PtStatus getDoNotDisturb(PtBoolean &rFlag)
retcode: PT_SUCCESS - Success retcode: PT_PROVIDER_UNAVAILABLE - The provider is not available ...
Definition: PtTerminal.cpp:955
PtTerminal & operator=(const PtTerminal &rhs)
Definition: PtTerminal.cpp:147
virtual ~PtTerminal()
Definition: PtTerminal.cpp:97
Definition: PtTerminalConnection.h:139
virtual PtStatus getTerminalListeners(PtTerminalListener aTermListeners[], int size, int &nItems)
param: (out) rpName - The reference used to return the name retcode: PT_SUCCESS - Success retcode: PT...
Definition: PtTerminal.cpp:1067
virtual PtStatus addCallListener(PtCallListener &rCallListener)
Definition: PtTerminal.cpp:161
Definition: PtTerminal.h:469
PtStatus getName(char *rpName, int maxLen)
param: (out) rFlag - TRUE ==> enabled, FALSE ==> disabled retcode: PT_SUCCESS - Success retcode: PT_P...
Definition: PtTerminal.cpp:1671
virtual PtStatus removeTerminalListener(PtTerminalListener &rTerminalListener)
param: (in) rCallListener - The listener to remove retcode: PT_SUCCESS - Success retcode: PT_NOT_FOUN...
Definition: PtTerminal.cpp:1515
PtTerminal()
Definition: PtTerminal.cpp:64
Definition: PtTerminalEvent.h:32
virtual PtStatus getAddresses(PtAddress addresses[], int size, int &nItems)
param (in) limit - The codec/CPU limit for this call. The value can
Definition: PtTerminal.cpp:274
static TaoReference * mpTransactionCnt
Definition: PtTerminal.h:457
Definition: PtGatewayInterface.h:76
Definition: PtTerminal.h:471
Definition: PtTerminal.h:178
virtual PtStatus numTerminalConnections(int &count)
param: (out) count - The number of components associated with this terminal retcode: PT_SUCCESS - Suc...
Definition: PtTerminal.cpp:1362
Definition: TaoServerTask.h:49
Definition: PtTerminal.h:470
virtual PtStatus setDoNotDisturb(PtBoolean flag)
param: (in) rTerminalListener - The listener to remove from this terminal retcode: PT_SUCCESS - Succe...
Definition: PtTerminal.cpp:1573
virtual PtStatus getComponent(const char *componentName, PtComponent &rComponent)
param: (out) aCallListeners - The array of known call listeners param: (in) size - The number of elem...
Definition: PtTerminal.cpp:383
static TaoObjectMap * mpComponents
Definition: PtTerminal.h:458
virtual PtStatus getComponents(PtComponent *components[], int size, int &nItems)
param: (in) componentName - The name of the desired component param: (out) rpComponent - Set to point...
Definition: PtTerminal.cpp:717
virtual PtStatus numComponents(int &count)
param: (out) count - The number of call listeners associated with this terminal retcode: PT_SUCCESS -...
Definition: PtTerminal.cpp:1261
Definition: PtAddress.h:189
Definition: PtProvider.h:118
Definition: TaoClientTask.h:50
void setName(const char *name)
Definition: PtTerminal.cpp:1715
Definition: PtTerminalListener.h:31
char mTerminalName[PTTERMINAL_MAX_NAME_LENGTH+1]
Definition: PtTerminal.h:462
TaoClientTask * mpClient
Definition: PtTerminal.h:463
Definition: PtComponentGroup.h:37
virtual PtStatus getComponentGroups(PtComponentGroup componentGroup[], int size, int &nItems)
param: (out) components - The array of PtComponent&#39;s param: (in) size - The number of elements in the...
Definition: PtTerminal.cpp:470
Definition: PtTerminal.h:468
Definition: PtTerminal.h:478