|
1 /* |
|
2 * Copyright (c) 2004 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: NWSessionSlotID implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CPENGNWSESSIONSLOTID2IMP_H |
|
19 #define CPENGNWSESSIONSLOTID2IMP_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <E32Base.h> |
|
23 |
|
24 |
|
25 |
|
26 // CONSTANTS |
|
27 _LIT( KPEngMatchSymbolWildAny, "*" ); |
|
28 enum TPEngNWSSIDMatchMode |
|
29 { |
|
30 EPEngMMExact = 0, |
|
31 EPEngMMWildAny = 1 |
|
32 }; |
|
33 |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 class RWriteStream; |
|
37 class RReadStream; |
|
38 class CPEngSessionSlotId; |
|
39 |
|
40 |
|
41 |
|
42 /** |
|
43 * NWSessionSlotID implementation. |
|
44 * |
|
45 * @since 3.0 |
|
46 */ |
|
47 NONSHARABLE_CLASS( CPEngNWSessionSlotID2Imp ) : public CBase |
|
48 { |
|
49 public: /* Construction */ |
|
50 |
|
51 |
|
52 /** |
|
53 * Instantiates CPEngNWSessionSlotID2Imp object. |
|
54 * |
|
55 * @return New CPEngNWSessionSlotID2Imp instance. |
|
56 */ |
|
57 static CPEngNWSessionSlotID2Imp* NewL(); |
|
58 |
|
59 |
|
60 /** |
|
61 * Cloness CPEngNWSessionSlotID2Imp object. |
|
62 * |
|
63 * @return New CPEngNWSessionSlotID2Imp copy instance. |
|
64 */ |
|
65 CPEngNWSessionSlotID2Imp* CloneL() const; |
|
66 |
|
67 |
|
68 /** |
|
69 * Reset. |
|
70 */ |
|
71 void Reset(); |
|
72 |
|
73 |
|
74 /** |
|
75 * Destructor. |
|
76 */ |
|
77 ~CPEngNWSessionSlotID2Imp(); |
|
78 |
|
79 |
|
80 |
|
81 protected: |
|
82 |
|
83 /** |
|
84 * C++ constructor. |
|
85 */ |
|
86 CPEngNWSessionSlotID2Imp(); |
|
87 |
|
88 /** |
|
89 * CSymbian OS constructor.. |
|
90 */ |
|
91 void ConstructL(); |
|
92 |
|
93 |
|
94 //----------------------------------------------------------------------- |
|
95 public: /* NWSessionSlotID implementation */ |
|
96 |
|
97 /** |
|
98 * Sets the NWSessionSlotID sub-part. |
|
99 * |
|
100 * @param aAddress Service address to use. |
|
101 * @param aUserId User id to use. |
|
102 * @param aAppId AppId to use. |
|
103 * @param aMatchMode The match mode for sub-part. |
|
104 */ |
|
105 void SetServiceAddressL( const TDesC& aAddress, TPEngNWSSIDMatchMode aMatchMode ); |
|
106 void SetUserIdL( const TDesC& aUserId, TPEngNWSSIDMatchMode aMatchMode ); |
|
107 void SetAppIdL( const TDesC& aAppId, TPEngNWSSIDMatchMode aMatchMode ); |
|
108 void SetAllL( const CPEngSessionSlotId& aBasePart, const TDesC& aAppId ); |
|
109 |
|
110 |
|
111 /** |
|
112 * Fragment access. |
|
113 * |
|
114 * Return pointer descriptor presenting |
|
115 * requested NWSessionSlotID sub-part. |
|
116 * |
|
117 * @return Requested sub-part. |
|
118 */ |
|
119 TPtrC ServiceAddress() const; |
|
120 TPtrC UserId() const; |
|
121 TPtrC AppId() const; |
|
122 |
|
123 |
|
124 /** |
|
125 * Base part access |
|
126 */ |
|
127 const CPEngSessionSlotId& BasePart() const; |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 //----------------------------------------------------------------------- |
|
134 public: /* Match support */ |
|
135 |
|
136 /** |
|
137 * Tests is certain sub-part defined as wild. |
|
138 * |
|
139 * @return ETrue if requested sub-part is defined as wild. |
|
140 * Else EFalse. |
|
141 */ |
|
142 TBool IsServiceAddressWild() const; |
|
143 TBool IsUserIdWild() const; |
|
144 TBool IsAppIdWild() const; |
|
145 TBool IsWild() const; |
|
146 |
|
147 |
|
148 /** |
|
149 * Tests is all NWSessionSlotID sub-parts defined. |
|
150 * |
|
151 * @return If any of sub parts isn't defined or |
|
152 * is defined as wild, returns EFalse. Else ETrue. |
|
153 */ |
|
154 TBool IsFullyDefined() const; |
|
155 |
|
156 |
|
157 /** |
|
158 * Pattern-matches NWSessionSlotIDs. |
|
159 * |
|
160 * @param aIdToMatch The NWSessionSlotID to match. |
|
161 * @return KErrNone if NWSessionSlotIDs match. |
|
162 * Else KErrNotFound. |
|
163 */ |
|
164 TInt MatchFullId( const CPEngNWSessionSlotID2Imp& aIdToMatch ) const; |
|
165 |
|
166 |
|
167 /** |
|
168 * Pattern-matches NWSessionSlotIDs base parts. |
|
169 * (ServiceAddress and UserId). |
|
170 * |
|
171 * @param aIdToMatch The NWSessionSlotID which base part to match. |
|
172 * @return KErrNone if NWSessionSlotIDs match. |
|
173 * Else KErrNotFound. |
|
174 */ |
|
175 TInt MatchBasePart( const CPEngNWSessionSlotID2Imp& aIdToMatch ) const; |
|
176 TInt MatchBasePart( const CPEngSessionSlotId& aBasePartToMatch ) const; |
|
177 |
|
178 |
|
179 |
|
180 /** |
|
181 * Pattern-matches NWSessionSlotIDs AppId parts. |
|
182 * (AppId). |
|
183 * |
|
184 * @param aIdToMatch The NWSessionSlotID which AppId part to match. |
|
185 * @return KErrNone if NWSessionSlotIDs match. |
|
186 * Else KErrNotFound. |
|
187 */ |
|
188 TInt MatchAppIdPart( const CPEngNWSessionSlotID2Imp& aIdToMatch ) const; |
|
189 TInt MatchAppIdPart( const TDesC& aAppId ) const; |
|
190 |
|
191 //----------------------------------------------------------------------- |
|
192 public: /* Serialized presentation */ |
|
193 |
|
194 /** |
|
195 * Packs NWSessionSlotIDs state to buffer and |
|
196 * returns buffer to caller. |
|
197 * @return NWSessionSlotID state buffer. |
|
198 */ |
|
199 HBufC8* PackFullLC() const; |
|
200 |
|
201 |
|
202 /** |
|
203 * Initializes NWSessionSlotID state from a package |
|
204 * previously created with PackFullLC(). |
|
205 * |
|
206 * @param aPack NWSessionSlotID state package. |
|
207 */ |
|
208 void UnPackFullL( const TDesC8& aPack ); |
|
209 |
|
210 |
|
211 /** |
|
212 * Externalizes the data. |
|
213 * |
|
214 * @param aStream Stream where to write. |
|
215 */ |
|
216 void ExternalizeL( RWriteStream& aStream ) const; |
|
217 |
|
218 |
|
219 /** |
|
220 * Internalizes the data. |
|
221 * |
|
222 * @param aStream Stream where to read from. |
|
223 */ |
|
224 void InternalizeL( RReadStream& aStream ); |
|
225 |
|
226 |
|
227 |
|
228 private: //Data |
|
229 |
|
230 //OWN: NWSessionSlotID sub-parts |
|
231 CPEngSessionSlotId* iBasePart; |
|
232 HBufC* iAppId; |
|
233 |
|
234 //OWN: NWSessionSlotID part wild definitions |
|
235 TInt iServiceAddressMatchMode; |
|
236 TInt iUserIdMatchMode; |
|
237 TInt iAppIdMatchMode; |
|
238 |
|
239 }; |
|
240 |
|
241 #endif //CPENGNWSESSIONSLOTID2IMP_H |
|
242 |
|
243 // End of File |