sipxtacklib  Version 3.3
SipLineMgr.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 _SipLineMgr_h_
13 #define _SipLineMgr_h_
14 
15 // SYSTEM INCLUDES
16 // #include <...>
17 
18 // APPLICATION INCLUDES
19 
20 
21 #include "os/OsServerTask.h"
22 #include "net/SipLine.h"
23 #include "net/SipLineList.h"
24 #include "net/SipLineEvent.h"
25 #include "net/HttpMessage.h"
26 
27 // DEFINES
28 #define MAX_LINES 32 // Max number of lines
29 #define MAX_CREDENTIALS 32 // Max number of credentials per line
30 
31 #define BASE_PHONESET_LINE_KEY "PHONESET_LINE." // Base key for device lines
32 #define BASE_USER_LINE_KEY "USER_LINE." // Base key for user lines
33 #define USER_DEFAULT_OUTBOUND_LINE "USER_DEFAULT_OUTBOUND_LINE" // Default outbound line
34 
35 #define LINE_REGISTRATION_PROVISION "PROVISION" // Registration value: Provision
36 #define LINE_REGISTRATION_REGISTER "REGISTER" // Registration value: Register
37 #define LINE_ALLOW_FORWARDING_ENABLE "ENABLE" // Allow Forwarding value: Enable
38 #define LINE_ALLOW_FORWARDING_DISABLE "DISABLE" // Allow Forwarding value: Disable
39 #define LINE_CONTACT_TYPE_LOCAL "LOCAL" // Use local contact/IP
40 #define LINE_CONTACT_TYPE_NAT_MAPPED "NAT_MAPPED" // Use NAT-derived contact/IP
41 
42 #define LINE_PARAM_LINEID "LINEID" // lineID
43 #define LINE_PARAM_URL "URL" // Line Parameter: identity/url
44 #define LINE_PARAM_REGISTRATION "REGISTRATION" // Line Parameter: registration method
45 #define LINE_PARAM_ALLOW_FORWARDING "ALLOW_FORWARDING" // Line Parameter: allow call forwarding
46 #define LINE_PARAM_CONTACT_TYPE "CONTACT_TYPE" // Contact type (LOCAL or NAT_MAPPED)
47 #define LINE_PARAM_CREDENTIAL "CREDENTIAL." // Line Parameter: credential sub key
48 #define LINE_PARAM_CREDENTIAL_REALM "REALM" // Credential Parameter: realm
49 #define LINE_PARAM_CREDENTIAL_USERID "USERID" // Credential Parameter: userid
50 #define LINE_PARAM_CREDENTIAL_PASSTOKEN "PASSTOKEN" // Credential Parameter: Pass token
51 
52 #define DEFAULT_LINE_PARAM_PHONESET_LINE "PHONESET_LINE" // Outbound Line Param: Device line
53 #define DEFAULT_LINE_PARAM_BASE_USER_LINE "USER_LINE." // Outbound Line Param: User line
54 
55 // MACROS
56 // EXTERNAL FUNCTIONS
57 // EXTERNAL VARIABLES
58 // CONSTANTS
59 // STRUCTS
60 // TYPEDEFS
61 // FORWARD DECLARATIONS
62 class OsConfigDb;
63 class SipRefreshMgr;
64 
65 //:Class short description which may consist of multiple lines (note the ':')
66 // Class detailed description which may extend to multiple lines
67 class SipLineMgr : public OsServerTask
68 {
69 /* //////////////////////////// PUBLIC //////////////////////////////////// */
70 public:
71 
72 /* ============================ CREATORS ================================== */
73 
74  SipLineMgr(const char* authenticationScheme = HTTP_DIGEST_AUTHENTICATION);
75  //:Default constructor
76 
77  SipLineMgr(const SipLineMgr& rSipLineMgr);
78  //:Copy constructor
79 
80  virtual
81  ~SipLineMgr();
82  //:Destructor
83 
84 /* ============================ MANIPULATORS ============================== */
85 
86  void StartLineMgr();
87 
88  UtlBoolean initializeRefreshMgr( SipRefreshMgr * refreshMgr );
89 
90  void setDefaultContactUri(const Url& contactUri);
91 
92  void setOwner(const UtlString& owner);
93 
94  UtlBoolean addLine(SipLine& line,
95  UtlBoolean doEnable = TRUE);
96 
97  void deleteLine(const Url& identity);
98 
99  void setDefaultOutboundLine( const Url& outboundLine );
100 
101  UtlBoolean enableLine( const Url& identity );
102 
103  void disableLine(const Url& identity,
104  UtlBoolean onStartup = FALSE,
105  const UtlString& lineId ="");
106 
107  void lineHasBeenUnregistered(const Url& identity);
108 
109  void enableAllLines();
110 
111  UtlBoolean buildAuthenticatedRequest(const SipMessage* response /*[in]*/,
112  const SipMessage* request /*[in]*/,
113  SipMessage* newAuthRequest /*[out]*/);
114 
115  //
116  // Line Manipulators
117  //
118 
120 
121  void setCallHandlingForLine(const Url& identity, UtlBoolean useCallHandling= TRUE);
122 
123  void setAutoEnableForLine(const Url& identity, UtlBoolean isAutoEnable = TRUE);
124 
125  void setStateForLine(const Url& identity, int state);
126 
127  void setVisibilityForLine(const Url& identity, UtlBoolean Visibility = TRUE);
128 
129  void setUserForLine(const Url& identity, const UtlString User);
130 
131  void setUserEnteredUrlForLine(const Url& identity, UtlString sipUrl);
132 
133  UtlBoolean setContactTypeForLine(const Url& identity, LINE_CONTACT_TYPE eContactType) ;
134 
135  UtlBoolean addCredentialForLine(
136  const Url& identity,
137  const UtlString strRealm,
138  const UtlString strUserID,
139  const UtlString strPasswd,
140  const UtlString type);
141 
142  UtlBoolean deleteCredentialForLine(const Url& identity,
143  const UtlString strRealm );
144 
145  //
146  // Listener/Observer Manipulators
147  //
148 
149  void addMessageObserver(OsMsgQ& messageQueue,
150  void* observerData = NULL );
151 
152  UtlBoolean removeMessageObserver(OsMsgQ& messageQueue,
153  void* pObserverData = NULL );
154  //:Removes all SIP message observers for the given message/queue observer
156  // will be removed if the pObserverData is NULL or matches.
158  // queue will be removed. Otherwise, only observers that match
159  // both the message queue and observer data will be removed.
161 
162  void notifyChangeInLineProperties(Url& identity);
163 
164  void notifyChangeInOutboundLine(Url& identity);
165 
166  //
167  // Serialization Manipulators
168  //
169 
170  void storeLine( OsConfigDb* pConfigDb, UtlString strSubKey, SipLine line);
171  //:Stores the specified line to the configuration database under the
172  // passed key.
175  // "USER_LINE.1."
177 
178  UtlBoolean loadLine(OsConfigDb* pConfigDb, UtlString strSubkey, SipLine& line);
179  //:Loads a line from the configuration database given the specified sub key.
182  // "USER_LINE.1."
185 
186  void purgeLines(OsConfigDb* pConfigDb) ;
187  //:Removes all device and user lines from the configuration database.
189 
190 /* ============================ ACCESSORS ================================= */
191 
192  const UtlString& getOwner() const;
193 
194  void getDefaultOutboundLine( UtlString &rOutBoundLine );
195 
196  UtlBoolean getLine(
197  const UtlString& toUrl,
198  const UtlString& localContact,
199  SipLine& sipline ) const;
200  //:Get the line identified by the designated To and Local Contact URLs.
201  //
203  // URLs or NULL if not found.
204 
205  UtlBoolean getLines(
206  int maxLines /*[in]*/,
207  int& actualLines /*[out]*/,
208  SipLine* lines[]/*[in/out]*/ ) const;
209 
210  UtlBoolean getLines (
211  int maxLines /*[in]*/,
212  int& actualLines /*[in/out]*/,
213  SipLine lines[]/*[in/out]*/ ) const;
214 
215  int getNumLines () const;
216  //:Get the current number of lines.
217 
218  int getNumOfCredentialsForLine( const Url& identity ) const;
219 
220  UtlBoolean getCredentialListForLine(
221  const Url& identity,
222  int maxEnteries,
223  int &actualEnteries,
224  UtlString realmList[],
225  UtlString userIdList[],
226  UtlString typeList[],
227  UtlString passTokenList[] );
228 
229  UtlBoolean getCallHandlingForLine( const Url& identity ) const;
230 
231  UtlBoolean getEnableForLine(const Url& identity) const;
232 
233  int getStateForLine(const Url& identity ) const;
234 
235  UtlBoolean getVisibilityForLine(const Url& identity ) const;
236 
237  UtlBoolean getUserForLine(const Url& identity, UtlString &User) const;
238 
239  UtlBoolean getUserEnteredUrlForLine( const Url& identity, UtlString &sipUrl) const;
240 
241  UtlBoolean getCanonicalUrlForLine(const Url& identity, UtlString &sipUrl) const ;
242 
243  UtlBoolean getContactTypeForLine(const Url& identity, LINE_CONTACT_TYPE& eContactType) const ;
244 
245 /* ============================ INQUIRY =================================== */
246 
247  UtlBoolean isUserIdDefined( const SipMessage* request /*[in]*/) const;
248 
249 
250 /* //////////////////////////// PROTECTED ///////////////////////////////// */
251 protected:
252 
253  SipLineMgr& operator=(const SipLineMgr& rhs);
254  //:Assignment operator
255 
256  UtlBoolean handleMessage(OsMsg& eventMessage);
257 
259 
260  void removeFromList(SipLine* line);
261 
262  void addToList(SipLine *line);
263 
265  const SipMessage* request /*[in]*/,
266  const SipMessage* response /*[in]*/,
267  const UtlBoolean& isIncomingRequest = FALSE,
268  const UtlBoolean& fromTempList = FALSE ) const;
269 
270  // temp list for storing credentials for deleted lines
271  void removeFromTempList( SipLine* line );
272 
273  void addToTempList( SipLine *line );
274 
275  void storeCredential(
276  OsConfigDb *pConfigDb,
277  UtlString strSubKey,
278  UtlString strRealm,
279  UtlString strUserId,
280  UtlString strPassToken,
281  UtlString strType );
282  //:Stores a single set of credentials under the passed key
285  // "USER_LINE.1.CREDENTIAL.1."
290 
291  UtlBoolean loadCredential(
292  OsConfigDb* pConfigDb,
293  UtlString strSubKey,
294  SipLine& line) ;
295  //:Loads a credential from the configuration db which is identified by
296  // the specified sub key.
299  // "USER_LINE.1.CREDENTIAL.1."
302 
303 /* //////////////////////////// PRIVATE /////////////////////////////////// */
304 private:
305  void dumpLines();
306 
307  // MsgType categories defined for use by the system
308  enum LineMsgTypes
309  {
310  UNSPECIFIED = 0,
311  START_LINE_MGR
312  };
313 
314  UtlBoolean mIsStarted;
315  UtlString mAuthenticationScheme;
316  UtlString mAuthenticationRealm;
317  OsConfigDb* mpAuthenticationDb;
318  OsConfigDb* mpAuthorizationUserIds;
319  OsConfigDb* mpAuthorizationPasswords;
320 
321  SipRefreshMgr* mpRefreshMgr;
322  UtlString mOwner;
323  Url mOutboundLine;
324  Url mDefaultContactUri;
325 
326  UtlHashBag mMessageObservers;
327  OsRWMutex mObserverMutex;
328 
329  // line list and temp line lists
330  mutable SipLineList sLineList;
331  mutable SipLineList sTempLineList;
332 };
333 
334 /* ============================ INLINE METHODS ============================ */
335 
336 #endif // _SipLineMgr_h_
UtlBoolean getUserForLine(const Url &identity, UtlString &User) const
Definition: SipLineMgr.cpp:1360
UtlBoolean getLines(int maxLines, int &actualLines, SipLine *lines[]) const
returns The line identified by the designated To and Local Contact
Definition: SipLineMgr.cpp:463
void setStateForLine(const Url &identity, int state)
Definition: SipLineMgr.cpp:1304
UtlBoolean buildAuthenticatedRequest(const SipMessage *response, const SipMessage *request, SipMessage *newAuthRequest)
Definition: SipLineMgr.cpp:696
UtlBoolean enableLine(const Url &identity)
Definition: SipLineMgr.cpp:311
LINE_CONTACT_TYPE
Line contact type: Use the local address or a NAT-derived address (e.g.
Definition: SipLine.h:35
void purgeLines(OsConfigDb *pConfigDb)
param: (in) pConfigDb - Configuration database to loaded from. param: (in) strSubKey - ROOT sub key o...
Definition: SipLineMgr.cpp:1447
void StartLineMgr()
Definition: SipLineMgr.cpp:97
#define HTTP_DIGEST_AUTHENTICATION
Definition: HttpMessage.h:96
void addMessageObserver(OsMsgQ &messageQueue, void *observerData=NULL)
Definition: SipLineMgr.cpp:1013
UtlBoolean getContactTypeForLine(const Url &identity, LINE_CONTACT_TYPE &eContactType) const
const UtlString & getOwner() const
param: (in) pConfigDb - Configuration database to be cleared.
Definition: SipLineMgr.cpp:408
UtlBoolean addCredentialForLine(const Url &identity, const UtlString strRealm, const UtlString strUserID, const UtlString strPasswd, const UtlString type)
Definition: SipLineMgr.cpp:1140
void getDefaultOutboundLine(UtlString &rOutBoundLine)
Definition: SipLineMgr.cpp:425
void storeLine(OsConfigDb *pConfigDb, UtlString strSubKey, SipLine line)
Definition: SipLineMgr.cpp:1589
void disableLine(const Url &identity, UtlBoolean onStartup=FALSE, const UtlString &lineId="")
Definition: SipLineMgr.cpp:349
void notifyChangeInLineProperties(Url &identity)
param: messageQueue - All observers dispatching to this message queue
Definition: SipLineMgr.cpp:376
void setDefaultContactUri(const Url &contactUri)
Definition: SipLineMgr.cpp:1114
UtlBoolean getEnableForLine(const Url &identity) const
Definition: SipLineMgr.cpp:1270
UtlBoolean isUserIdDefined(const SipMessage *request) const
Definition: SipLineMgr.cpp:685
UtlBoolean getVisibilityForLine(const Url &identity) const
Definition: SipLineMgr.cpp:1331
Definition: SipLineEvent.h:21
Specialization of HttpMessage to contain and manipulate SIP messages.
Definition: SipMessage.h:343
void removeFromTempList(SipLine *line)
Definition: SipLineMgr.cpp:1109
UtlBoolean setContactTypeForLine(const Url &identity, LINE_CONTACT_TYPE eContactType)
void lineHasBeenUnregistered(const Url &identity)
Definition: SipLineMgr.cpp:295
void addToList(SipLine *line)
Definition: SipLineMgr.cpp:1094
void addToTempList(SipLine *line)
Definition: SipLineMgr.cpp:1104
UtlBoolean removeMessageObserver(OsMsgQ &messageQueue, void *pObserverData=NULL)
Definition: SipLineMgr.cpp:1033
void setUserForLine(const Url &identity, const UtlString User)
Definition: SipLineMgr.cpp:1377
void enableAllLines()
Definition: SipLineMgr.cpp:1729
void deleteLine(const Url &identity)
Definition: SipLineMgr.cpp:254
void removeFromList(SipLine *line)
Definition: SipLineMgr.cpp:1100
int getNumLines() const
Definition: SipLineMgr.cpp:475
SipLineMgr(const char *authenticationScheme=HTTP_DIGEST_AUTHENTICATION)
Definition: SipLineMgr.cpp:54
UtlBoolean getCredentialListForLine(const Url &identity, int maxEnteries, int &actualEnteries, UtlString realmList[], UtlString userIdList[], UtlString typeList[], UtlString passTokenList[])
Definition: SipLineMgr.cpp:1205
void setDefaultOutboundLine(const Url &outboundLine)
Definition: SipLineMgr.cpp:414
void setAutoEnableForLine(const Url &identity, UtlBoolean isAutoEnable=TRUE)
Definition: SipLineMgr.cpp:1256
UtlBoolean loadCredential(OsConfigDb *pConfigDb, UtlString strSubKey, SipLine &line)
param: (in) pConfigDb - Configuration database to saved to. param: (in) strSubKey - ROOT sub key of c...
Definition: SipLineMgr.cpp:1658
void setFirstLineAsDefaultOutBound()
Definition: SipLineMgr.cpp:439
UtlBoolean deleteCredentialForLine(const Url &identity, const UtlString strRealm)
Definition: SipLineMgr.cpp:1171
Definition: SipLineMgr.h:67
UtlBoolean getLine(const UtlString &toUrl, const UtlString &localContact, SipLine &sipline) const
Definition: SipLineMgr.cpp:482
UtlBoolean getCanonicalUrlForLine(const Url &identity, UtlString &sipUrl) const
Definition: SipLineMgr.cpp:1425
void setCallHandlingForLine(const Url &identity, UtlBoolean useCallHandling=TRUE)
Definition: SipLineMgr.cpp:1227
virtual ~SipLineMgr()
Definition: SipLineMgr.cpp:77
UtlBoolean handleMessage(OsMsg &eventMessage)
Definition: SipLineMgr.cpp:108
void setVisibilityForLine(const Url &identity, UtlBoolean Visibility=TRUE)
Definition: SipLineMgr.cpp:1346
UtlBoolean loadLine(OsConfigDb *pConfigDb, UtlString strSubkey, SipLine &line)
param: (in) pConfigDb - Configuration database to save to. param: (in) strSubKey - ROOT sub key of co...
Definition: SipLineMgr.cpp:1490
void setOwner(const UtlString &owner)
Definition: SipLineMgr.cpp:401
void setUserEnteredUrlForLine(const Url &identity, UtlString sipUrl)
Definition: SipLineMgr.cpp:1390
UtlBoolean initializeRefreshMgr(SipRefreshMgr *refreshMgr)
Definition: SipLineMgr.cpp:1119
UtlBoolean getUserEnteredUrlForLine(const Url &identity, UtlString &sipUrl) const
Definition: SipLineMgr.cpp:1404
int getNumOfCredentialsForLine(const Url &identity) const
Definition: SipLineMgr.cpp:1190
UtlBoolean addLine(SipLine &line, UtlBoolean doEnable=TRUE)
Definition: SipLineMgr.cpp:226
void notifyChangeInOutboundLine(Url &identity)
Definition: SipLineMgr.cpp:389
Definition: SipLineList.h:33
URL parser and constructor.
Definition: Url.h:90
UtlBoolean getCallHandlingForLine(const Url &identity) const
Definition: SipLineMgr.cpp:1240
void storeCredential(OsConfigDb *pConfigDb, UtlString strSubKey, UtlString strRealm, UtlString strUserId, UtlString strPassToken, UtlString strType)
Definition: SipLineMgr.cpp:1699
Definition: SipLine.h:56
Definition: SipRefreshMgr.h:46
SipLineMgr & operator=(const SipLineMgr &rhs)
int getStateForLine(const Url &identity) const
Definition: SipLineMgr.cpp:1288
SipLine * getLineforAuthentication(const SipMessage *request, const SipMessage *response, const UtlBoolean &isIncomingRequest=FALSE, const UtlBoolean &fromTempList=FALSE) const
Definition: SipLineMgr.cpp:541
void queueMessageToObservers(SipLineEvent &event)
Definition: SipLineMgr.cpp:1068

sipXtackLib home page