|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Candidate pair |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CNATFWCANDIDATEPAIR_H |
|
22 #define CNATFWCANDIDATEPAIR_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include "natfwconnectivityapidefs.h" |
|
26 |
|
27 class CNATFWCandidate; |
|
28 class CNATFWCredentials; |
|
29 |
|
30 /** |
|
31 * A pairing containing a local candidate and a remote candidate. |
|
32 * |
|
33 * Used with the ICE protocol when making NAT connectivity checks. |
|
34 * |
|
35 * @lib natconfw.lib |
|
36 * @since S60 v3.2 |
|
37 */ |
|
38 class CNATFWCandidatePair : public CBase |
|
39 { |
|
40 |
|
41 public: |
|
42 |
|
43 /** |
|
44 * Two-phased constructor. |
|
45 */ |
|
46 IMPORT_C static CNATFWCandidatePair* NewL(); |
|
47 |
|
48 /** |
|
49 * Two-phased constructor. |
|
50 */ |
|
51 IMPORT_C static CNATFWCandidatePair* NewLC(); |
|
52 |
|
53 /** |
|
54 * Two-phased copy constructor. |
|
55 * @param aPair The pair to copy |
|
56 */ |
|
57 IMPORT_C static CNATFWCandidatePair* NewL( |
|
58 const CNATFWCandidatePair& aPair ); |
|
59 |
|
60 /** |
|
61 * Two-phased copy constructor. |
|
62 * @param aPair The pair to copy |
|
63 */ |
|
64 IMPORT_C static CNATFWCandidatePair* NewLC( |
|
65 const CNATFWCandidatePair& aPair ); |
|
66 |
|
67 /** |
|
68 * Two-phased constructor. |
|
69 * @param aLocalCand Local candidate |
|
70 * @param aRemoteCand Remote candidate |
|
71 */ |
|
72 IMPORT_C static CNATFWCandidatePair* NewL( |
|
73 const CNATFWCandidate& aLocalCand, |
|
74 const CNATFWCandidate& aRemoteCand ); |
|
75 |
|
76 /** |
|
77 * Two-phased constructor. |
|
78 * @param aLocalCand Local candidate |
|
79 * @param aRemoteCand Remote candidate |
|
80 */ |
|
81 IMPORT_C static CNATFWCandidatePair* NewLC( |
|
82 const CNATFWCandidate& aLocalCand, |
|
83 const CNATFWCandidate& aRemoteCand ); |
|
84 |
|
85 /** |
|
86 * Destructor. |
|
87 */ |
|
88 virtual ~CNATFWCandidatePair(); |
|
89 |
|
90 /** |
|
91 * Returns foundation of the candidate pair. |
|
92 * |
|
93 * @since S60 v3.2 |
|
94 * @return Foundation of candidate pair |
|
95 */ |
|
96 IMPORT_C const TDesC8& Foundation() const; |
|
97 |
|
98 /** |
|
99 * Sets local candidate. |
|
100 * |
|
101 * @since S60 v3.2 |
|
102 * @param aCandidate Local candidate to set |
|
103 */ |
|
104 IMPORT_C void SetLocalCandidateL( const CNATFWCandidate& aCandidate ); |
|
105 |
|
106 /** |
|
107 * Gets local candidate. |
|
108 * |
|
109 * @since S60 v3.2 |
|
110 * @return Local candidate |
|
111 */ |
|
112 IMPORT_C const CNATFWCandidate& LocalCandidate() const; |
|
113 |
|
114 /** |
|
115 * Sets remote candidate. |
|
116 * |
|
117 * @since S60 v3.2 |
|
118 * @param aCandidate Remote candidate |
|
119 */ |
|
120 IMPORT_C void SetRemoteCandidateL( const CNATFWCandidate& aCandidate ); |
|
121 |
|
122 /** |
|
123 * Gets remote candidate. |
|
124 * |
|
125 * @since S60 v3.2 |
|
126 * @return Remote candidate |
|
127 */ |
|
128 IMPORT_C const CNATFWCandidate& RemoteCandidate() const; |
|
129 |
|
130 /** |
|
131 * Sets pair priority. |
|
132 * |
|
133 * @since S60 v3.2 |
|
134 * @param aPriority new pair priority |
|
135 */ |
|
136 IMPORT_C void SetPriority( const TUint64 aPriority ); |
|
137 |
|
138 /** |
|
139 * Gets pair priority. |
|
140 * |
|
141 * @since S60 v3.2 |
|
142 * @return Pair priority |
|
143 */ |
|
144 IMPORT_C TUint64 Priority() const; |
|
145 |
|
146 /** |
|
147 * Sets the candidate pair as selected. |
|
148 * |
|
149 * @since S60 v3.2 |
|
150 * @param aSelected ETrue if selected |
|
151 */ |
|
152 IMPORT_C void SetSelected( TBool aSelected ); |
|
153 |
|
154 /** |
|
155 * Gets pair selected status (true/false). |
|
156 * |
|
157 * @since S60 v3.2 |
|
158 * @return Whether candidate pair is selected by ICE algorithm |
|
159 */ |
|
160 IMPORT_C TBool Selected() const; |
|
161 |
|
162 /** |
|
163 * Implements TLinearOrder (descending order) using priority |
|
164 * in comparison. |
|
165 * |
|
166 * @since S60 v3.2 |
|
167 */ |
|
168 IMPORT_C static TInt PriorityOrder( |
|
169 const CNATFWCandidatePair& aA, const CNATFWCandidatePair& aB ); |
|
170 |
|
171 /** |
|
172 * Implements TIdentityRelation regarding all fields. |
|
173 * |
|
174 * @since S60 v3.2 |
|
175 * @param aItem1 The first item for comparison |
|
176 * @param aItem2 The second item for comparison |
|
177 * @return ETrue if candidate pairs match |
|
178 */ |
|
179 IMPORT_C static TBool Compare( |
|
180 const CNATFWCandidatePair& aItem1, |
|
181 const CNATFWCandidatePair& aItem2 ); |
|
182 |
|
183 /** |
|
184 * Implements TIdentityRelation regarding transport addresses. |
|
185 * |
|
186 * @since S60 v3.2 |
|
187 * @param aItem1 The first item for comparison |
|
188 * @param aItem2 The second item for comparison |
|
189 * @return ETrue if candidate pairs match |
|
190 */ |
|
191 IMPORT_C static TBool MatchAddresses( |
|
192 const CNATFWCandidatePair& aItem1, |
|
193 const CNATFWCandidatePair& aItem2 ); |
|
194 |
|
195 /** |
|
196 * Makes a copy of candidate pair. |
|
197 * |
|
198 * @since S60 v3.2 |
|
199 * @param aPair The pair to copy |
|
200 */ |
|
201 IMPORT_C void CopyL( const CNATFWCandidatePair& aPair ); |
|
202 |
|
203 IMPORT_C TBool operator==(const CNATFWCandidatePair& aCandidate) const; |
|
204 |
|
205 IMPORT_C TBool operator!=(const CNATFWCandidatePair& aCandidate) const; |
|
206 |
|
207 private: |
|
208 |
|
209 CNATFWCandidatePair(); |
|
210 |
|
211 void ConstructL(); |
|
212 |
|
213 void ConstructL( const CNATFWCandidatePair& aPair ); |
|
214 |
|
215 void ConstructL( |
|
216 const CNATFWCandidate& aLocalCand, |
|
217 const CNATFWCandidate& aRemoteCand ); |
|
218 |
|
219 void UpdateFoundationL(); |
|
220 |
|
221 protected: // data |
|
222 |
|
223 /** |
|
224 * Priority of candidate pair |
|
225 */ |
|
226 TUint64 iPairPriority; |
|
227 |
|
228 /** |
|
229 * Foundation of candidate pair |
|
230 * Own. |
|
231 */ |
|
232 RBuf8 iFoundation; |
|
233 |
|
234 /** |
|
235 * Local candidate |
|
236 * Own. |
|
237 */ |
|
238 CNATFWCandidate* iLocalCand; |
|
239 |
|
240 /** |
|
241 * Remote candidate |
|
242 * Own. |
|
243 */ |
|
244 CNATFWCandidate* iRemoteCand; |
|
245 |
|
246 /** |
|
247 * Indicates whether the pair is selected |
|
248 */ |
|
249 TBool iSelected; |
|
250 |
|
251 }; |
|
252 |
|
253 |
|
254 #endif // CNATFWCANDIDATEPAIR_H |