sipXcallLib home page


PtAddress.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 #ifndef _PtAddress_h_
12 #define _PtAddress_h_
13 
14 // SYSTEM INCLUDES
15 // APPLICATION INCLUDES
16 #include <ptapi/PtDefs.h>
17 #include <os/OsBSem.h>
18 #include "os/OsProtectEventMgr.h"
19 
20 // DEFINES
21 // MACROS
22 // EXTERNAL FUNCTIONS
23 // EXTERNAL VARIABLES
24 // CONSTANTS
25 // STRUCTS
26 // TYPEDEFS
27 // FORWARD DECLARATIONS
29 class PtAddressListener;
30 class PtCallListener;
31 class PtConnection;
32 class PtProvider;
33 class PtTerminal;
34 class TaoObjectMap;
35 class TaoReference;
36 class PtAddress;
37 class PtCall;
38 class PtProviderListener;
39 class TaoClientTask;
40 class TaoServerTask;
41 
42 //:A PtAddress object represents what we commonly think of as a phone number.
43 // However, for calls to IP telephony endpoints, the "telephone number" is
44 // a URL or IP address identifying the endpoint.
45 // <p>
46 // Address objects may be classified into two categories: local and remote.
47 // <br>
48 // <ul>
49 // <li><b>Local address objects</b> are those addresses that are part of the
50 // provider's local domain. All of the provider's currently known local
51 // addresses are reported via the PtProvider.getAddresses() method. </li>
52 // <p>
53 // <li><B>Remote address objects</B> are those outside of the provider's domain
54 // that the provider learns about during its lifetime through various happenings
55 // (for example, an incoming call from a currently unknown address). Remote
56 // addresses are not reported via the PtProvider.getAddresses() method. </li>
57 // </ul><p>
58 // Note that applications may not create PtAddress objects. The PtProvider
59 // begins with knowledge of certain PtAddress objects within its local domain.
60 // This list is quasi-static, changing only as logical endpoints are added
61 // and removed in the phone system.
62 //
63 // <H3>Address and Terminal Objects</H3>
64 // PtAddress and PtTerminal objects exist in a many-to-many relationship. A
65 // PtAddress object may have zero or more PtTerminals associated with it.
66 // Each PtTerminal associated with a PtAddress must reflect its association
67 // with the PtAddress. The PtTerminals associated with a PtAddress are given
68 // by the PtAddress.getTerminals() method.
69 // <p>
70 // An association between a PtAddress and a PtTerminal indicates that the
71 // terminal is addressable via that address. In many instances, a telephone
72 // set (represented by a PtTerminal object) has only one telephone number
73 // (represented by a PtAddress object) associated with it. In more complex
74 // configurations, telephone sets may have several telephone numbers
75 // associated with them. Likewise, a telephone number may appear on more
76 // than one telephone set.
77 //
78 // <H3>Address and Call Objects</H3>
79 // PtAddress objects represent the logical endpoints of a telephone call. A
80 // logical view of a telephone call views the call as originating from one
81 // PtAddress endpoint and terminating at another PtAddress endpoint.
82 // <p>
83 // PtAddress objects are related to PtCall objects via the PtConnection
84 // object. The PtConnection object has a state that describes the current
85 // relationship between the call and the address. Each PtAddress object may
86 // be part of more than one telephone call, and in each case, is represented
87 // by a separate PtConnection object. The PtAddress.getConnections() method
88 // returns all PtConnection objects currently associated with the call.
89 // <p>
90 // An address is associated with a call until the connection moves into the
91 // PtConnection::DISCONNECTED state. At that time, the connection is no longer
92 // reported by the PtAddress.getConnections() method. Therefore, the
93 // PtAddress.getConnections() method will never report a connection in the
94 // PtConnection::DISCONNECTED state.
95 //
96 // <H3>Address Listeners and Events</H3>
97 // All changes in a PtAddress object are reported via PtAddressListener
98 // objects. Applications instantiate an object which is derived from the
99 // PtAddressListener class and use the PtAddress.addAddressListener() method
100 // to begin the delivery of events. All address-related events reported via
101 // a PtAddressListener are instances of either the PtAddressEvent class
102 // or its descendants. Applications receive events on a listener until the
103 // listener is removed via the PtAddress.removeAddressListener() method, or
104 // until the PtAddress is no longer observable. In these instances, each
105 // AddressListener receives an ADDRESS_EVENT_TRANSMISSION_ENDED event as its
106 // final event.
107 //
108 // <H3>Call Listeners</H3>
109 // At times, applications may want to monitor a particular address for all
110 // calls that come to that address. For example, a customer service agent
111 // application may only be interested in telephone calls that are associated
112 // with a particular agent address. To achieve this sort of address-based call
113 // monitoring, applications may add PtCallListeners to a PtAddress via the
114 // PtAddress.addCallListener() method.
115 // <p>
116 // When a PtCallListener is added to a PtAddress, this listener instance is
117 // immediately added to all calls at this address, and is added to all calls
118 // which come to this address in the future. These listeners remain on the
119 // telephone call as long as the address is associated with the telephone
120 // call.
121 //
122 // <H3>Address Forwarding</H3>
123 // This class supports methods which permit applications to modify and query
124 // the forwarding characteristics of a PtAddress. The forwarding
125 // characteristics determine how incoming telephone calls to this PtAddress
126 // should be handled, if any special handling is desired.
127 // <p>
128 // Each PtAddress may have zero or more forwarding instructions. Each
129 // instruction describes how the switching domain should handle incoming
130 // telephone calls to a PtAddress under different circumstances. Examples of
131 // forwarding instructions are "forward all calls to x9999" or "forward all
132 // calls to x7777 when no one answers." Each forwarding instruction is
133 // represented by an instance of the PtAddressForwarding class.
134 // <p>
135 // Applications assign a list of forwarding instructions via the
136 // PtAddress.setForwarding() method. To obtain the current,
137 // effective forwarding instructions, applications invoke the
138 // PtAddress.getForwarding() method. To cancel all forwarding
139 // instructions, applications use the PtAddress.cancelForwarding()
140 // method.
141 //
142 // <H3>Do-not-disturb and Message-waiting</H3>
143 // The <i>do-not-disturb</i> feature gives the means to notify the telephony
144 // platform that an address does not want to receive incoming telephone calls.
145 // That is, if this feature is activated, the underlying telephony platform
146 // will <b>not</b> alert this PtAddress to incoming telephone calls. Applications
147 // use the PtAddress.setDoNotDisturb() method to activate and deactivate this
148 // feature, and the PtAddress.getDoNotDisturb() method to return the current
149 // state of this attribute.
150 // <p>
151 // Note that the PtTerminal interface also has a <i>do-not-disturb</i>
152 // attribute. This gives the ability to control the <i>do-not-disturb</i>
153 // property at either the PtAddress level (for example, a phone number) or
154 // at the PtTerminal level (for example, an individual phone.)
155 // <p>
156 // The <i>message-waiting</i> attribute indicates whether there are messages
157 // waiting for a human user of the address. These messages may be maintained
158 // either by an application or by some telephony platform. Applications
159 // inform the phone set of the message waiting status, and typically
160 // the phone set displays a visible indicator (such as an LED) to users.
161 // Applications use the PtAddress.setMessageWaiting() method to activate and
162 // deactivate this feature, and the PtAddress.getMessageWaiting() method to
163 // return the current state of this attribute.
164 //
165 // <H3>Offered Timeout</H3>
166 // The offered timeout attribute for a PtAddress indicates how long the
167 // connection for an incoming call will stay in the PtConnection::OFFERED
168 // state before it transitions to the PtConnection::ALERTING state. By
169 // default, the offered timeout for a PtAddress is 0. This means that as
170 // soon as the connection for the incoming call is offered on a PtAddress,
171 // the PtTerminals for that address will begin alerting (by ringing, for
172 // example).
173 // <p>
174 // To implement services such as call screening or find-me-follow-me,
175 // applications must be allowed to explicitly accept, reject or
176 // redirect connections that are offered to a PtAddress. Setting the
177 // offered timeout for a PtAddress to a positive number causes the
178 // PtConnection to stay in the PtConnection::OFFERED state until the
179 // PtCall is either explicitly accepted, rejected, or redirected, or until the
180 // offered timeout expires, whichever comes first. If the offered timeout
181 // expires before the call is explicitly accepted, rejected, or
182 // redirected, the PtConnection transitions to the PtConnection::ALERTING
183 // state.
184 // <p>
185 // The timer-based transition of the PtConnection from
186 // PtConnection::OFFERED to PtConnection::ALERTING may be disabled by
187 // setting the offered timeout for the PtAddress to -1.
188 
190 {
191 /* //////////////////////////// PUBLIC //////////////////////////////////// */
192 public:
193 
194 /* ============================ CREATORS ================================== */
195 
196  PtAddress();
197  //:Default constructor
198 
199  PtAddress(TaoClientTask *pClient, const char* name);
200 
201  PtAddress(PtProvider *pProvider, const char* address);
202 
203  PtAddress(const PtAddress& rPtAddress);
204  //:Copy constructor (not implemented for this class)
205 
206  PtAddress(const char* address);
207 
208  virtual
209  ~PtAddress();
210  //:Destructor
211 
212 /* ============================ MANIPULATORS ============================== */
213 
214  PtAddress& operator=(const PtAddress& rhs);
215  //:Assignment operator (not implemented for this class)
216 
217  virtual PtStatus addAddressListener(PtAddressListener& rAddressListener);
218  //:Adds a listener to this address.
223 
224  virtual PtStatus addCallListener(PtCallListener& rCallListener);
225  //:Adds a listener to a PtCall object when this PtAddress object first
226  //:becomes part of that PtCall.
231 
232  virtual PtStatus cancelForwarding(void);
233  //:Cancels all of the forwarding instructions on this address.
236 
237  virtual PtStatus cancelForwarding(PtAddressForwarding forwards[], int size);
238  //:Cancels forwarding instructions in forwards on this address.
243 
244 
245  virtual PtStatus removeCallListener(PtCallListener& rCallListener);
246  //:Removes the indicated PtCallListener from this PtAddress.
247  // This method removes a PtCallListener which was added via the
248  // PtAddress.addCallListener() method. If successful, the listener will
249  // no longer be added to new calls which are presented to this address,
250  // however it does not affect PtCallListeners which have already been
251  // added to a call.
256 
257  virtual PtStatus removeAddressListener(PtAddressListener& rAddressListener);
258  //:Removes the indicated listener from this PtAddress.
263 
264  virtual PtStatus setDoNotDisturb(PtBoolean flag);
265  //:Specifies whether the <i>do-not-disturb</i> feature should be
266  //:activated or deactivated for this address.
270 
271  virtual PtStatus setForwarding(PtAddressForwarding forwards[], int size);
272  //:Sets the forwarding characteristics for this address.
277 
278  virtual PtStatus setMessageWaiting(PtBoolean flag);
279  //:Specifies whether the <i>message-waiting</i> indicator should be
280  //:activated or deactivated for this address.
284 
285  virtual PtStatus setOfferedTimeout(int milliSecs);
286  //:Specifies the timeout value for transitioning from the
287  //:PtConnection::OFFERED state to the PtConnection::ALERTING state for
288  //:an incoming call to this address.
289  // If <i>milliSecs</i> is 0, a PtConnection in the PtConnection::OFFERED
290  // state will immediately transition to the PtConnection::ALERTING state.
291  // If <i>milliSecs</i> is greater than 0, the connection will stay in
292  // the PtConnection::OFFERED state for the indicated number of
293  // milliseconds or until the connection is explicitly handled (by calling
294  // PtConnection.accept(), PtConnection.reject() or
295  // PtConnection.redirect()). whichever comes first. If the timeout
296  // expires before the connection is explicitly handled, the connection
297  // will then transition into the PtConnection::ALERTING state. Setting
298  // <i>milliSecs</i> to -1, is equivalent to requesting an infinite
299  // timeout.
303 
304 /* ============================ ACCESSORS ================================= */
305 
306  virtual PtStatus getAddressListeners(PtAddressListener* addrListeners[],
307  int size, int& nItems);
308  //:Returns an array of PtAddressListener pointers for all of the
309  //:address listeners presently associated with this address.
310  // The caller provides an array that can hold up to <i>size</i>
311  // PtAddressListener pointers. This method will fill in the
312  // <i>addrListeners</i> array with up to <i>size</i> pointers. The
313  // actual number of pointers filled in is passed back via the
314  // <i>nItems</i> argument.
321 
322  virtual PtStatus getCallListeners(PtCallListener* callListeners[], int size,
323  int& nItems);
324  //:Returns an array of PtCallListener pointers for all of the call
325  //:listeners presently associated with this address.
326  // The caller provides an array that can hold up to <i>size</i>
327  // PtCallListener pointers. This method will fill in the
328  // <i>callListeners</i> array with up to <i>size</i> pointers. The
329  // actual number of pointers filled in is passed back via the
330  // <i>nItems</i> argument.
337 
338  virtual PtStatus getConnections(PtConnection connections[], int size,
339  int& nItems);
340  //:Returns an array of pointers to PtConnection objects currently
341  //:associated with this address.
342  // The caller provides an array that can hold up to <i>size</i>
343  // PtConnection pointers. This method will fill in the
344  // <i>connections</i> array with up to <i>size</i> pointers. The
345  // actual number of pointers filled in is passed back via the
346  // <i>nItems</i> argument.
353 
354  virtual PtStatus getDoNotDisturb(PtBoolean& rFlag);
355  //:Returns the current setting for the <i>do-not-disturb</i> feature.
359 
360  virtual PtStatus getForwarding(PtAddressForwarding forwards[], int size,
361  int& nItems);
362  //:Returns an array of forwarding instructions currently associated with
363  //:this address.
364  // The caller provides an array of PtAddressForwarding objects containing
365  // <i>size</i> elements. This method will fill in the <i>forwards</i>
366  // array with up to <i>size</i> objects. The actual number of items
367  // filled in is passed back via the <i>nItems</i> argument.
374 
375  virtual PtStatus getMessageWaiting(PtBoolean& rFlag);
376  //:Returns the current setting for the <i>message waiting</i> indicator.
380 
381  PtStatus getName(char* rpName, int len);
382  //:Returns the name associated with this PtAddress.
386 
387  virtual PtStatus getOfferedTimeout(int& rMilliSecs);
388  //:Sets <i>rMilliSecs</i> to the timeout value on this PtAddress for
389  //:transitioning from the PtConnection::OFFERED state to the
390  //:PtConnection::ALERTING state for an incoming call to this address.
391  // See the description of PtAddress.setOfferedTimeout() for further
392  // information on the offered timeout mechanism.
396 
397  virtual PtStatus getProvider(PtProvider& rpProvider);
398  //:Returns a pointer to the PtProvider associated with this PtAddress.
402 
403  virtual PtStatus getTerminals(PtTerminal terms[], int size, int& nItems);
404  //:Returns an array of pointers to PtTerminal objects currently
405  //:associated with this address.
406  // The caller provides an array that can hold up to <i>size</i>
407  // PtTerminal pointers. This method will fill in the <i>terms</i> array
408  // with up to <i>size</i> pointers. The actual number of pointers
409  // filled in is passed back via the <i>nItems</i> argument.
416 
417  virtual PtStatus numAddressListeners(int& count);
418  //:Returns the number of address listeners associated with this address.
422 
423  virtual PtStatus numCallListeners(int& count);
424  //:Returns the number of call listeners associated with this address.
428 
429  virtual PtStatus numConnections(int& count);
430  //:Returns the number of connections associated with this address.
434 
435  virtual PtStatus numForwards(int& count);
436  //:Returns the number of forwarding instructions associated with this
437  //:address.
441 
442  virtual PtStatus numTerminals(int& count);
443  //:Returns the number of terminals associated with this address.
447 
448 /* ============================ INQUIRY =================================== */
449 
450 /* //////////////////////////// PROTECTED ///////////////////////////////// */
451 protected:
452  static OsBSem semInit ;
453  //: Binary Semaphore used to guard initialiation and tear down
455  static unsigned int mRef;
456 
458  UtlString mAddress;
459 
460  OsTime mTimeOut;
461 
462  void initialize();
463 
464 /* //////////////////////////// PRIVATE /////////////////////////////////// */
465 private:
466  OsProtectEventMgr *mpEventMgr;
467 
470 
471  static OsBSem mAddressForwardDbSem;
473  static int mAddressForwardCnt;
474 
478 
479 };
480 
481 /* ============================ INLINE METHODS ============================ */
482 
483 #endif // _PtAddress_h_
Definition: TaoReference.h:35
static PtBoolean mbMessageWaiting
Definition: PtAddress.h:475
UtlString mAddress
Definition: PtAddress.h:458
PtStatus
Definition: PtDefs.h:49
void initialize()
Definition: PtAddress.cpp:127
static PtBoolean mOfferedTimeout
Definition: PtAddress.h:477
Definition: TaoObjectMap.h:56
virtual PtStatus setMessageWaiting(PtBoolean flag)
param: (in) forwards - the array of call forwarding instructions param: (in) size - the number of for...
Definition: PtAddress.cpp:625
Definition: PtProviderListener.h:33
virtual PtStatus setDoNotDisturb(PtBoolean flag)
param: (in) rAddressListener - the listener to remove from this address retcode: PT_SUCCESS - Success...
Definition: PtAddress.cpp:484
virtual PtStatus getDoNotDisturb(PtBoolean &rFlag)
param: (out) connections - the array of PtConnection pointers param: (in) size - the number of elemen...
Definition: PtAddress.cpp:873
int PtBoolean
Definition: PtDefs.h:71
virtual PtStatus numCallListeners(int &count)
param: (out) count - The number of address listeners associated with this address retcode: PT_SUCCESS...
Definition: PtAddress.cpp:1042
static OsBSem mAddressForwardDbSem
Definition: PtAddress.h:471
virtual PtStatus setForwarding(PtAddressForwarding forwards[], int size)
param: (in) flag - TRUE ==> enable, FALSE ==> disable retcode: PT_SUCCESS - Success retcode: PT_PROVI...
Definition: PtAddress.cpp:528
virtual PtStatus getConnections(PtConnection connections[], int size, int &nItems)
param: (out) callListeners - the array of pointers to known call listeners param: (in) size - the num...
Definition: PtAddress.cpp:827
virtual PtStatus getProvider(PtProvider &rpProvider)
param: (out) rMilliSecs - Set to the offered timeout value retcode: PT_SUCCESS - Success retcode: PT_...
Definition: PtAddress.cpp:961
virtual PtStatus getForwarding(PtAddressForwarding forwards[], int size, int &nItems)
param: (out) rFlag - TRUE ==> enabled, FALSE ==> disabled retcode: PT_SUCCESS - Success retcode: PT_P...
Definition: PtAddress.cpp:879
static PtAddressForwarding * mpAddressForwards
Definition: PtAddress.h:472
Definition: PtAddressForwarding.h:49
virtual PtStatus getAddressListeners(PtAddressListener *addrListeners[], int size, int &nItems)
param: (in) milliSecs - number of milliseconds to delay retcode: PT_SUCCESS - Success retcode: PT_PRO...
Definition: PtAddress.cpp:735
virtual PtStatus getCallListeners(PtCallListener *callListeners[], int size, int &nItems)
param: (out) addrListeners - the array of pointers to known address listeners param: (in) size - the ...
Definition: PtAddress.cpp:781
Definition: PtCallListener.h:33
static int mAddressForwardCnt
Definition: PtAddress.h:473
virtual PtStatus getOfferedTimeout(int &rMilliSecs)
param: (out) rpName - The reference used to return the name retcode: PT_SUCCESS - Success retcode: PT...
Definition: PtAddress.cpp:911
static unsigned int mRef
Definition: PtAddress.h:455
virtual PtStatus numConnections(int &count)
param: (out) count - The number of call listeners associated with this address retcode: PT_SUCCESS - ...
Definition: PtAddress.cpp:1081
virtual PtStatus removeAddressListener(PtAddressListener &rAddressListener)
param: (in) rCallListener - the listener to remove retcode: PT_SUCCESS - Success retcode: PT_NOT_FOUN...
Definition: PtAddress.cpp:396
OsProtectEventMgr * mpEventMgr
Definition: PtAddress.h:466
virtual PtStatus numTerminals(int &count)
param: (out) count - The number of forwarding instructions associated with this address retcode: PT_S...
Definition: PtAddress.cpp:1124
virtual PtStatus removeCallListener(PtCallListener &rCallListener)
param: (in) forwards - the forwarding instructions to remove param: (in) size - the number of forward...
Definition: PtAddress.cpp:440
virtual PtStatus addAddressListener(PtAddressListener &rAddressListener)
Definition: PtAddress.cpp:165
static TaoReference * mpTransactionCnt
Definition: PtAddress.h:454
static PtBoolean mbDoNotDisturb
Definition: PtAddress.h:476
PtStatus getName(char *rpName, int len)
param: (out) rFlag - TRUE ==> on, FALSE ==> off retcode: PT_SUCCESS - Success retcode: PT_PROVIDER_UN...
Definition: PtAddress.cpp:715
TaoReference * mpAddressListenerCnt
Definition: PtAddress.h:468
virtual ~PtAddress()
Definition: PtAddress.cpp:99
PtAddress()
Definition: PtAddress.cpp:44
Definition: PtConnection.h:178
Definition: PtTerminal.h:178
PtAddress & operator=(const PtAddress &rhs)
Definition: PtAddress.cpp:149
Definition: TaoServerTask.h:49
virtual PtStatus getMessageWaiting(PtBoolean &rFlag)
param: (out) forwards - The array of PtAddressForwarding objects param: (in) size - The number of ele...
Definition: PtAddress.cpp:905
OsTime mTimeOut
Definition: PtAddress.h:460
virtual PtStatus cancelForwarding(void)
param: (in) rCallListener - The listener to add to calls associated with this address retcode: PT_SUC...
Definition: PtAddress.cpp:253
virtual PtStatus getTerminals(PtTerminal terms[], int size, int &nItems)
param: (out) rpProvider - a pointer to the PtProvider object associated with this address retcode: PT...
Definition: PtAddress.cpp:917
virtual PtStatus addCallListener(PtCallListener &rCallListener)
param: (in) rAddressListener - The listener to add to this address retcode: PT_SUCCESS - Success retc...
Definition: PtAddress.cpp:209
Definition: PtAddressListener.h:28
TaoObjectMap * mpAddressListenerDb
Definition: PtAddress.h:469
Definition: PtCall.h:253
Definition: PtAddress.h:189
virtual PtStatus numForwards(int &count)
param: (out) count - The number of connections associated with this address retcode: PT_SUCCESS - Suc...
Definition: PtAddress.cpp:1118
Definition: PtProvider.h:118
Definition: TaoClientTask.h:50
virtual PtStatus setOfferedTimeout(int milliSecs)
param: (in) flag - TRUE ==> on, FALSE ==> off retcode: PT_SUCCESS - Success retcode: PT_PROVIDER_UNAV...
Definition: PtAddress.cpp:669
TaoClientTask * mpClient
Definition: PtAddress.h:457
virtual PtStatus numAddressListeners(int &count)
param: (out) terms - The array of PtTerminal pointers param: (in) size - The number of elements in th...
Definition: PtAddress.cpp:1005
static OsBSem semInit
param: (out) count - The number of terminals associated with this address retcode: PT_SUCCESS - Succe...
Definition: PtAddress.h:452