sipxtacklib  Version 3.3
SipLine.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 #if !defined(AFX_SIPLINE_H__6AD8439B_AA8A_4F09_B5C4_44A3BA9C7AC6__INCLUDED_)
12 #define AFX_SIPLINE_H__6AD8439B_AA8A_4F09_B5C4_44A3BA9C7AC6__INCLUDED_
13 
14 // SYSTEM INCLUDES
15 //#include <...>
16 
17 // APPLICATION INCLUDES
18 #include <utl/UtlHashBag.h>
19 #include "HttpMessage.h"
20 #include "net/Url.h"
21 
22 
23 // DEFINES
24 // MACROS
25 // EXTERNAL FUNCTIONS
26 // EXTERNAL VARIABLES
27 // CONSTANTS
28 // STRUCTS
29 // TYPEDEFS
30 
35 typedef enum LINE_CONTACT_TYPE
36 {
41 
42 //STATE TRANSITION//
43 /*
44  |----1/2refresh time--|
45  |--------------refresh time-------------|
46  --------- ------------ -------- ---------
47  | TRYING| ---------> |REGISTERED| --------->|FAILED| -------->|EXPIRED|
48  --------- ------------ -------- ---------
49  | | ^ ^
50  | |___| |
51  | |
52  |______________________failed the first time____________________|
53 
54 */
55 
56 class SipLine
57 {
58 public:
59 
60  //utility functions
62  {
64  LINE_STATE_REGISTERED, //sucessfull registeration , registration no expried on server
65  LINE_STATE_DISABLED, //not registering
66  LINE_STATE_FAILED, //failed registration
67  LINE_STATE_PROVISIONED, //dont send registration , but enabled because server provisioned it.
68  LINE_STATE_TRYING, //registration message sent , awaiting response
69  LINE_STATE_EXPIRED //registration expried on server
70  };
71 
72  SipLine(Url userEnteredUrl = "",
73  Url identityUri = "",
74  UtlString user ="",
75  UtlBoolean visible = TRUE,
76  int state = LINE_STATE_REGISTERED,
77  UtlBoolean isAutoEnabled = TRUE,
78  UtlBoolean useCallHandling = FALSE);
79 
80  virtual ~SipLine();
81  SipLine(const SipLine& rSipLine);
82  SipLine& operator=(const SipLine& rSipLine);
83 
84 
85  UtlBoolean isDeviceLine() ;
86  //: Determine if this line is a device line. Presently, a line is
87  // considered a device line if it's user is "Device"
88 
89  UtlBoolean IsDuplicateRealm(const UtlString realm , const UtlString scheme = HTTP_DIGEST_AUTHENTICATION);
90 
91  UtlString& getLineId();
92 
93 
94  int getState() ;
95  void setState(int state) ;
96 
97  //who does the line belong to
98  UtlString& getUser();
99  void setUser(const UtlString user);
100 
101  //line identily or name - just the Uri
102  void getIdentityAndUrl(Url &identity, Url &userEnteredUrl) ;
103  void setIdentityAndUrl(Url identity, Url userEnteredUrl) ;
105  Url& getIdentity() ;
106  Url& getCanonicalUrl() ;
107 
108  //if line will get enabled after reboot - ( ie it is persitant)
109  void setAutoEnableStatus( UtlBoolean isAutoEnabled);
110  UtlBoolean getAutoEnableStatus();
111 
112  //to use the call handling of the owner or not
113  UtlBoolean getCallHandling();
114  void setCallHandling( UtlBoolean useCallHandling = TRUE);
115 
116  //if line is visible in the line list to the user
117  UtlBoolean getVisibility();
118  void setVisibility( UtlBoolean isEnable = TRUE);
119 
120  //for use from GUI
121  int GetNumOfCredentials();
122 
123  UtlBoolean addCredentials(const UtlString& strRealm,
124  const UtlString& strUserID,
125  const UtlString& strPassword,
126  const UtlString& Type);
127 
128  UtlBoolean getCredentials(const UtlString& type /*[in]*/,
129  const UtlString& realm /*[in]*/,
130  UtlString* userID /*[out]*/,
131  UtlString* MD5_token /*[out]*/);
132 
133  UtlBoolean getDuplicateCredentials(const UtlString& type /*[in]*/,
134  const UtlString& realm /*[in]*/);
135 
136  UtlBoolean getAllCredentials( int MaxEnteries/*[in]*/ ,
137  int& actualEnteries /*[out/int]*/,
138  UtlString realms[]/*[out/int]*/,
139  UtlString UserId[]/*[out/int]*/,
140  UtlString type[]/*[out/int]*/,
141  UtlString passtoken[]/*[out/int]*/);
142 
143  //removes credetials for a particular realm
144  UtlBoolean removeCredential(const UtlString* realm);
145  //removes all credentials for this line
146  void removeAllCredentials();
147 
148  void setPreferredContactUri(const Url& preferredContactUri) ;
149  //: Set the preferred host/ip for the contact in subsequent registers
150  UtlBoolean getPreferredContactUri(Url& preferredContactUri) const ;
151  //: Get Preferred host/ip for the contact in subsequent registers
152 
154  void setContactType(LINE_CONTACT_TYPE eContactType) ;
155 
156 protected:
157 
158  UtlBoolean mIsVisible;
159  UtlBoolean mIsAutoEnabled;
161  Url mIdentity; //line key which is the canonical URL stripped of display name, angle brackets and field parameters (basically the URI).
162  Url mUserEnteredUrl; //user entered URL string (could be incomplete "sip:444@")
163  Url mCanonicalUrl; //The canonical URL which is the URL string with the host and port filled in if they were missing.
166  UtlString mUser;
167  UtlString mLineId;
170 
171  UtlHashBag mCredentials;
172 
173  void copyCredentials(const SipLine& rSipLine);
174  void generateLineID(UtlString& lineId);
175 };
176 
177 #endif // !defined(AFX_SIPLINE_H__6AD8439B_AA8A_4F09_B5C4_44A3BA9C7AC6__INCLUDED_)
Definition: SipLine.h:63
UtlBoolean getCallHandling()
Definition: SipLine.cpp:269
LineStates
Definition: SipLine.h:61
LINE_CONTACT_TYPE
Line contact type: Use the local address or a NAT-derived address (e.g.
Definition: SipLine.h:35
Definition: SipLine.h:68
#define HTTP_DIGEST_AUTHENTICATION
Definition: HttpMessage.h:96
UtlBoolean removeCredential(const UtlString *realm)
Definition: SipLine.cpp:390
UtlHashBag mCredentials
Definition: SipLine.h:171
Url mCanonicalUrl
Definition: SipLine.h:163
UtlBoolean IsDuplicateRealm(const UtlString realm, const UtlString scheme=HTTP_DIGEST_AUTHENTICATION)
Definition: SipLine.cpp:499
void setUser(const UtlString user)
Definition: SipLine.cpp:195
UtlBoolean mIsUsingCallHandling
Definition: SipLine.h:160
Definition: SipLine.h:66
int getState()
Definition: SipLine.cpp:180
UtlBoolean isDeviceLine()
Definition: SipLine.cpp:174
UtlBoolean getAutoEnableStatus()
Definition: SipLine.cpp:250
UtlString mUser
Definition: SipLine.h:166
int mCurrentState
Definition: SipLine.h:168
Url mUserEnteredUrl
Definition: SipLine.h:162
void setPreferredContactUri(const Url &preferredContactUri)
Definition: SipLine.cpp:417
void setAutoEnableStatus(UtlBoolean isAutoEnabled)
Definition: SipLine.cpp:245
UtlString mLineId
Definition: SipLine.h:167
void setCallHandling(UtlBoolean useCallHandling=TRUE)
Definition: SipLine.cpp:264
void setVisibility(UtlBoolean isEnable=TRUE)
Definition: SipLine.cpp:255
UtlBoolean getPreferredContactUri(Url &preferredContactUri) const
Definition: SipLine.cpp:423
void setIdentityAndUrl(Url identity, Url userEnteredUrl)
Definition: SipLine.cpp:207
Use the local IP address.
Definition: SipLine.h:37
void setContactType(LINE_CONTACT_TYPE eContactType)
Definition: SipLine.cpp:440
int GetNumOfCredentials()
Definition: SipLine.cpp:302
LINE_CONTACT_TYPE getContactType() const
Definition: SipLine.cpp:434
Url mIdentity
Definition: SipLine.h:161
Url & getIdentity()
Definition: SipLine.cpp:235
Definition: SipLine.h:65
UtlBoolean mIsAutoEnabled
Definition: SipLine.h:159
LINE_CONTACT_TYPE meContactType
Type of of contact address (either LOCAL or NAT_MAPPED)
Definition: SipLine.h:164
void setState(int state)
Definition: SipLine.cpp:185
Url & getUserEnteredUrl()
Definition: SipLine.cpp:231
UtlString & getLineId()
Definition: SipLine.cpp:168
Definition: SipLine.h:64
UtlBoolean getCredentials(const UtlString &type, const UtlString &realm, UtlString *userID, UtlString *MD5_token)
Definition: SipLine.cpp:308
void removeAllCredentials()
Definition: SipLine.cpp:410
SipLine & operator=(const SipLine &rSipLine)
Definition: SipLine.cpp:59
UtlBoolean mIsVisible
Definition: SipLine.h:158
UtlBoolean getAllCredentials(int MaxEnteries, int &actualEnteries, UtlString realms[], UtlString UserId[], UtlString type[], UtlString passtoken[])
Definition: SipLine.cpp:446
Url & getCanonicalUrl()
Definition: SipLine.cpp:240
UtlBoolean getVisibility()
Definition: SipLine.cpp:260
UtlBoolean getDuplicateCredentials(const UtlString &type, const UtlString &realm)
Definition: SipLine.cpp:361
SipLine(Url userEnteredUrl="", Url identityUri="", UtlString user="", UtlBoolean visible=TRUE, int state=LINE_STATE_REGISTERED, UtlBoolean isAutoEnabled=TRUE, UtlBoolean useCallHandling=FALSE)
Definition: SipLine.cpp:112
UtlString & getUser()
Definition: SipLine.cpp:190
Definition: SipLine.h:69
void copyCredentials(const SipLine &rSipLine)
Definition: SipLine.cpp:81
Definition: SipLine.h:67
Use the NAT-derived IP address.
Definition: SipLine.h:38
URL parser and constructor.
Definition: Url.h:90
virtual ~SipLine()
Definition: SipLine.cpp:163
UtlBoolean addCredentials(const UtlString &strRealm, const UtlString &strUserID, const UtlString &strPassword, const UtlString &Type)
Definition: SipLine.cpp:274
Definition: SipLine.h:56
void getIdentityAndUrl(Url &identity, Url &userEnteredUrl)
Definition: SipLine.cpp:201
Url mPreferredContactUri
Definition: SipLine.h:169
void generateLineID(UtlString &lineId)
Definition: SipLine.cpp:509

sipXtackLib home page