sipxtacklib  Version 3.3
SipContactDb.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 _SipContactDb_h_
13 #define _SipContactDb_h_
14 
15 // SYSTEM INCLUDES
16 //#include <...>
17 #include <utl/UtlString.h>
18 #include <utl/UtlHashMap.h>
19 #include <os/OsMutex.h>
20 #include <os/OsSocket.h>
21 #include "tapi/sipXtapi.h"
22 
23 // APPLICATION INCLUDES
24 // DEFINES
25 // MACROS
26 // EXTERNAL FUNCTIONS
27 // EXTERNAL VARIABLES
28 // CONSTANTS
29 // STRUCTS
30 // TYPEDEFS
31 
32 
33 
34 // FORWARD DECLARATIONS
35 
37 {
38 /* //////////////////////////// PUBLIC //////////////////////////////////// */
39 public:
40 
41 /* ============================ CREATORS ================================== */
42  SipContactDb();
43 
44  virtual
45  ~SipContactDb();
46 
56  const bool addContact(SIPX_CONTACT_ADDRESS& contact);
57 
58 
65  const bool updateContact(SIPX_CONTACT_ADDRESS& contact);
66 
73  const bool deleteContact(const SIPX_CONTACT_ID id);
74 
81 
87  SIPX_CONTACT_ADDRESS* find(const UtlString szIpAddress, const int port, SIPX_CONTACT_TYPE type);
88 
92  SIPX_CONTACT_ADDRESS* findByType(SIPX_CONTACT_TYPE type, SIPX_TRANSPORT_TYPE transportType, UtlString sCustomTransport = "") ;
93 
98  SIPX_TRANSPORT_TYPE findTransportType(const char* transportName) ;
99 
100  /*
101  * Find the local contact from a contact id.
102  */
104 
113  void getAll(SIPX_CONTACT_ADDRESS* contacts[], int& actualNum) const;
114 
115 
125  void getAllForAdapter(const SIPX_CONTACT_ADDRESS* contacts[],
126  const char* szAdapter,
127  int& actualNum,
128  SIPX_CONTACT_TYPE typeFilter = CONTACT_ALL) const;
129 
130  const bool getRecordForAdapter(SIPX_CONTACT_ADDRESS& contact,
131  const char* szAdapter,
132  const SIPX_CONTACT_TYPE contactFilter) const;
133 
134  const bool getRecordForAdapter(SIPX_CONTACT_ADDRESS& contact,
135  const char* szAdapter,
136  const SIPX_CONTACT_TYPE contactFilter,
137  const SIPX_TRANSPORT_TYPE transportFilter) const;
138 
139 
140  void replicateForTransport(const SIPX_TRANSPORT_TYPE originalTransport,
141  const SIPX_TRANSPORT_TYPE newTransport,
142  const char* szTransport,
143  const char* szRoutingID);
144 
145  void removeForTransport(const SIPX_TRANSPORT_TYPE transport);
146 
147  void dump(UtlString& output) ;
148 
149 /* ============================ MANIPULATORS ============================== */
150 
151  void enableTurn(bool bEnable) ;
152 
153 
154 /* ============================ ACCESSORS ================================= */
155 
156 
157 /* ============================ INQUIRY =================================== */
158 
159 
160 /* //////////////////////////// PROTECTED ///////////////////////////////// */
161 protected:
162 
163 
164 
165 /* //////////////////////////// PRIVATE /////////////////////////////////// */
166 private:
167 
169  SipContactDb(const SipContactDb& rSipContactDb);
170 
171  //** Disabled assignment operator */
172  SipContactDb& operator=(const SipContactDb& rhs);
173 
175  const bool isDuplicate(const SIPX_CONTACT_ID id);
176 
178  const bool isDuplicate(const UtlString& ipAddress, const int port, SIPX_CONTACT_TYPE type, SIPX_TRANSPORT_TYPE transportType);
179 
188  const bool assignContactId(SIPX_CONTACT_ADDRESS& contact);
189 
191  UtlHashMap mContacts;
192 
193  int mNextContactId;
194 
195  mutable OsMutex mLock;
196 
197  bool mbTurnEnabled ;
198 };
199 
200 /* ============================ INLINE METHODS ============================ */
201 
202 #endif // _SipContactDb_h_
void getAll(SIPX_CONTACT_ADDRESS *contacts[], int &actualNum) const
Populates a CONTACT_ADDRESS array with all of the contacts stored in this DB.
Definition: SipContactDb.cpp:349
SipContactDb()
Definition: SipContactDb.cpp:35
const bool updateContact(SIPX_CONTACT_ADDRESS &contact)
Searches for a similar contact and the datebase and updates the address/port.
Definition: SipContactDb.cpp:97
const bool addContact(SIPX_CONTACT_ADDRESS &contact)
Inserts a contact into the contact table.
Definition: SipContactDb.cpp:64
SIPX_CONTACT_ADDRESS * findByType(SIPX_CONTACT_TYPE type, SIPX_TRANSPORT_TYPE transportType, UtlString sCustomTransport="")
Finds the first contact by a given contact type.
Definition: SipContactDb.cpp:180
void dump(UtlString &output)
Definition: SipContactDb.cpp:657
Definition: SipContactDb.h:36
int SIPX_CONTACT_ID
Type for storing Contact Record identifiers.
Definition: sipXtapi.h:632
void enableTurn(bool bEnable)
Definition: SipContactDb.cpp:488
SIPX_CONTACT_TYPE
SIPX_CONTACT_TYPE is an enumeration of possible address types for use with SIP contacts and SDP conne...
Definition: sipXtapi.h:524
Definition: sipXtapi.h:533
void removeForTransport(const SIPX_TRANSPORT_TYPE transport)
Definition: SipContactDb.cpp:631
SIPX_CONTACT_ADDRESS * getLocalContact(SIPX_CONTACT_ID id)
Definition: SipContactDb.cpp:276
SIPX_TRANSPORT_TYPE
SIPX_TRANSPORT_TYPE defines various protocols use for signaling transport.
Definition: sipXtapi.h:541
const bool deleteContact(const SIPX_CONTACT_ID id)
Removes a contact record from the DB.
Definition: SipContactDb.cpp:156
void getAllForAdapter(const SIPX_CONTACT_ADDRESS *contacts[], const char *szAdapter, int &actualNum, SIPX_CONTACT_TYPE typeFilter=CONTACT_ALL) const
Populates a CONTACT_ADDRESS array with all of the contacts stored in this DB that match a particular ...
Definition: SipContactDb.cpp:451
SIPX_TRANSPORT_TYPE findTransportType(const char *transportName)
Return a transport type given the specified transport name.
Definition: SipContactDb.cpp:224
const bool getRecordForAdapter(SIPX_CONTACT_ADDRESS &contact, const char *szAdapter, const SIPX_CONTACT_TYPE contactFilter) const
Definition: SipContactDb.cpp:372
SIPX_CONTACT_ADDRESS * find(SIPX_CONTACT_ID id)
Finds a contact in the DB, by SIPX_CONTACT_ID.
Definition: SipContactDb.cpp:163
The CONTACT_ADDRESS structure includes contact information (IP-address and port), address source type...
Definition: sipXtapi.h:640
void replicateForTransport(const SIPX_TRANSPORT_TYPE originalTransport, const SIPX_TRANSPORT_TYPE newTransport, const char *szTransport, const char *szRoutingID)
Definition: SipContactDb.cpp:593
sipXtapi main API declarations
virtual ~SipContactDb()
Definition: SipContactDb.cpp:44

sipXtackLib home page