|
1 /* |
|
2 * Copyright (c) 2005 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 // INCLUDE FILES |
|
19 #include "CPEngSessionSlotId.h" |
|
20 #include "PEngCoreUtilsTools.h" |
|
21 |
|
22 // CONSTANTS |
|
23 |
|
24 |
|
25 // ============================ LOCAL FUNCTIONS =============================== |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CopyBufferL() |
|
28 // ----------------------------------------------------------------------------- |
|
29 void CopyBufferL( HBufC*& aDest, const HBufC* aSource ) |
|
30 { |
|
31 if ( aSource ) |
|
32 { |
|
33 aDest = aSource->AllocL(); |
|
34 } |
|
35 } |
|
36 |
|
37 |
|
38 |
|
39 // ============================ MEMBER FUNCTIONS =============================== |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CPEngSessionSlotId::CPEngSessionSlotId |
|
43 // C++ default constructor can NOT contain any code, that |
|
44 // might leave. |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CPEngSessionSlotId::CPEngSessionSlotId() |
|
48 { |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CPEngSessionSlotId::NewL() |
|
53 // Two-phased constructor. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 EXPORT_C CPEngSessionSlotId* CPEngSessionSlotId::NewL() |
|
57 { |
|
58 CPEngSessionSlotId* self = new ( ELeave ) CPEngSessionSlotId(); |
|
59 return self; |
|
60 } |
|
61 |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CPEngSessionSlotId::NewLC() |
|
65 // Two-phased constructor. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 EXPORT_C CPEngSessionSlotId* CPEngSessionSlotId::NewLC() |
|
69 { |
|
70 CPEngSessionSlotId* self = new ( ELeave ) CPEngSessionSlotId(); |
|
71 CleanupStack::PushL( self ); |
|
72 return self; |
|
73 } |
|
74 |
|
75 // Destructor |
|
76 CPEngSessionSlotId::~CPEngSessionSlotId() |
|
77 { |
|
78 delete iServiceAddress; |
|
79 delete iUserId; |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CPEngSessionSlotId::CloneL() |
|
84 // Two-phased clone constructor. |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 EXPORT_C CPEngSessionSlotId* CPEngSessionSlotId::CloneL() const |
|
88 { |
|
89 CPEngSessionSlotId* clone = CloneLC(); |
|
90 CleanupStack::Pop( clone ); |
|
91 return clone; |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CPEngSessionSlotId::CloneLC() |
|
96 // Two-phased clone constructor. |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 EXPORT_C CPEngSessionSlotId* CPEngSessionSlotId::CloneLC() const |
|
100 { |
|
101 CPEngSessionSlotId* clone = new ( ELeave ) CPEngSessionSlotId(); |
|
102 CleanupStack::PushL( clone ); |
|
103 |
|
104 clone->CopyL( *this ); |
|
105 |
|
106 return clone; |
|
107 } |
|
108 |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CPEngSessionSlotId::CopyL() |
|
112 // Copy operation. |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 EXPORT_C void CPEngSessionSlotId::CopyL( const CPEngSessionSlotId& aSource ) |
|
116 { |
|
117 CopyBufferL( iServiceAddress, aSource.iServiceAddress ); |
|
118 CopyBufferL( iUserId, aSource.iUserId ); |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CPEngSessionSlotId::Reset() |
|
123 // Reset operation. |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 EXPORT_C void CPEngSessionSlotId::Reset() |
|
127 { |
|
128 delete iServiceAddress; |
|
129 delete iUserId; |
|
130 |
|
131 iServiceAddress = NULL; |
|
132 iUserId = NULL; |
|
133 } |
|
134 |
|
135 |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CPEngSessionSlotId::SetServiceAddressL() |
|
139 // Mutator |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 EXPORT_C void CPEngSessionSlotId::SetServiceAddressL( const TDesC& aAddress ) |
|
143 { |
|
144 DoSetDescriptorL( iServiceAddress, aAddress ); |
|
145 } |
|
146 |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CPEngSessionSlotId::SetUserIdL() |
|
150 // Mutator |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 EXPORT_C void CPEngSessionSlotId::SetUserIdL( const TDesC& aUserId ) |
|
154 { |
|
155 DoSetDescriptorL( iUserId, aUserId ); |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CPEngSessionSlotId::ServiceAddress() |
|
160 // Accessor |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 EXPORT_C TPtrC CPEngSessionSlotId::ServiceAddress() const |
|
164 { |
|
165 return DoGetDescriptor( iServiceAddress ); |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // CPEngSessionSlotId::UserId() |
|
170 // Accessor |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 EXPORT_C TPtrC CPEngSessionSlotId::UserId() const |
|
174 { |
|
175 return DoGetDescriptor( iUserId ); |
|
176 } |
|
177 |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // CPEngSessionSlotId::Match() |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 EXPORT_C TInt CPEngSessionSlotId::Match( const CPEngSessionSlotId& aIdToMatch ) const |
|
184 { |
|
185 //Use ServiceAddress() and UserId() accessors to avoid NULL pointer problems |
|
186 if ( aIdToMatch.ServiceAddress().Compare( ServiceAddress() ) != KErrNone ) |
|
187 { |
|
188 return KErrNotFound; |
|
189 } |
|
190 |
|
191 if ( aIdToMatch.UserId().Compare( UserId() ) != KErrNone ) |
|
192 { |
|
193 return KErrNotFound; |
|
194 } |
|
195 |
|
196 return KErrNone; |
|
197 } |
|
198 |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CPEngSessionSlotId::PackLC() |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 EXPORT_C HBufC8* CPEngSessionSlotId::PackLC() const |
|
205 { |
|
206 HBufC8* packBuffer = HBufC8::NewLC( Size() ); |
|
207 TPtr8 pack( packBuffer->Des() ); |
|
208 |
|
209 RDesWriteStream ws; |
|
210 ws.Open( pack ); // CSI: 65 # |
|
211 CleanupClosePushL( ws ); |
|
212 |
|
213 ExternalizeL( ws ); |
|
214 |
|
215 ws.CommitL(); |
|
216 CleanupStack::PopAndDestroy(); //ws |
|
217 |
|
218 |
|
219 packBuffer = packBuffer->ReAllocL( packBuffer->Length() ); |
|
220 CleanupStack::Pop(); |
|
221 CleanupStack::PushL( packBuffer ); //Due realloc |
|
222 |
|
223 return packBuffer; |
|
224 } |
|
225 |
|
226 // ----------------------------------------------------------------------------- |
|
227 // CPEngSessionSlotId::UnPackFullL() |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 EXPORT_C void CPEngSessionSlotId::UnPackL( const TDesC8& aPack ) |
|
231 { |
|
232 RDesReadStream rs; |
|
233 rs.Open( aPack ); // CSI: 65 # |
|
234 CleanupClosePushL( rs ); |
|
235 |
|
236 InternalizeL( rs ); |
|
237 |
|
238 CleanupStack::PopAndDestroy(); //rs |
|
239 } |
|
240 |
|
241 |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CPEngSessionSlotId::ExternalizeL() |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 EXPORT_C void CPEngSessionSlotId::ExternalizeL( RWriteStream& aStream ) const |
|
248 { |
|
249 ExternalizeBufferL( iServiceAddress, aStream ); |
|
250 ExternalizeBufferL( iUserId, aStream ); |
|
251 } |
|
252 |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // CPEngSessionSlotId::InternalizeL() |
|
256 // ----------------------------------------------------------------------------- |
|
257 // |
|
258 EXPORT_C void CPEngSessionSlotId::InternalizeL( RReadStream& aStream ) |
|
259 { |
|
260 delete iServiceAddress; |
|
261 iServiceAddress = NULL; |
|
262 iServiceAddress = InternalizeBufferL( aStream ); |
|
263 |
|
264 |
|
265 delete iUserId; |
|
266 iUserId = NULL; |
|
267 iUserId = InternalizeBufferL( aStream ); |
|
268 } |
|
269 |
|
270 |
|
271 // ----------------------------------------------------------------------------- |
|
272 // CPEngSessionSlotId::Size() |
|
273 // ----------------------------------------------------------------------------- |
|
274 // |
|
275 EXPORT_C TInt CPEngSessionSlotId::Size() const |
|
276 { |
|
277 TInt size = BufferExternalizeSizeInBytes( iServiceAddress ); |
|
278 size += BufferExternalizeSizeInBytes( iUserId ); |
|
279 return size; |
|
280 } |
|
281 |
|
282 |
|
283 // End of File |
|
284 |
|
285 |