|
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: TestUtils for SAP settings store module tests |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // Include Files |
|
20 #include <E32Math.h> |
|
21 #include "f32file.h" |
|
22 #include "IMPSSAPSettingsStoreTestUtils.h" |
|
23 #include "CIMPSSAPSettingsStore.h" |
|
24 #include "CIMPSSAPSettings.h" |
|
25 #include "CIMPSSAPSettingsList.h" |
|
26 #include "CIMPSSAPSettingsListItem.h" |
|
27 |
|
28 |
|
29 // CONSTANTS AND MACROS |
|
30 //SAP strings and consts to use in filling |
|
31 _LIT( KSAPName, "SAPName" ); |
|
32 _LIT( KDefaultSAPName, "Default SAP" ); |
|
33 _LIT( KSAPAddres, "SAPAddr" ); |
|
34 _LIT( KSAPUserId, "SAPUserId" ); |
|
35 _LIT( KSAPUserPassword, "SAPUserPwd" ); |
|
36 _LIT( KHTTPProxyAddres, "ProxyAddr" ); |
|
37 _LIT( KHTTPProxyUserId, "ProxyUserId" ); |
|
38 _LIT( KHTTPProxyUserPassword, "ProxyUserPwd" ); |
|
39 _LIT( KCLientId, "CLientId" ); |
|
40 |
|
41 _LIT( KServerAuthenticationUsername, "SAUsername" ); |
|
42 _LIT( KServerAuthenticationPassword, "SAPassword" ); |
|
43 _LIT( KServerAcceptedContentType, "application/vnd" ); |
|
44 |
|
45 _LIT( KKey8, "Key8" ); |
|
46 _LIT( KKey16, "Key16" ); |
|
47 _LIT( KKeyInt, "KeyInt" ); |
|
48 |
|
49 _LIT8( KOpaque8, "Value8" ); |
|
50 _LIT( KOpaque16, "Value16" ); |
|
51 |
|
52 const TInt KHighlevelServices = EIMPSServicesIM + EIMPSServicesPEC; |
|
53 |
|
54 const TInt KAuthorizationMode = EIMPSAuthModeUnspecified; |
|
55 |
|
56 const TInt KSAPPort = 100; |
|
57 const TInt KHTTPProxyPort = 200; |
|
58 const TInt KAP = 300; |
|
59 |
|
60 const TInt KOpaqueInt = 1234; |
|
61 |
|
62 //format string for SAP naming |
|
63 _LIT( KNumberFormat, ": %d" ); |
|
64 |
|
65 |
|
66 //local data types |
|
67 struct TSAPName |
|
68 { |
|
69 const TText* iName; |
|
70 }; |
|
71 |
|
72 //Pre defined string array for SAP names |
|
73 //NOTE! This must have atleast two items |
|
74 LOCAL_D TSAPName const KSAPNames[] = |
|
75 { |
|
76 { _S( "abcd1" ) }, |
|
77 { _S( "AAaaa" ) }, |
|
78 { _S( "abcd2" ) }, |
|
79 { _S( "AAAaa" ) }, |
|
80 { _S( "Aaaaa" ) }, |
|
81 { _S( "abcd0" ) }, |
|
82 { _S( "abcde" ) }, |
|
83 { _S( "kiiii" ) }, |
|
84 { _S( "+*?=)" ) }, |
|
85 { _S( "kkkkk" ) }, |
|
86 { _S( "Oooyy" ) }, |
|
87 { _S( "Öööyy" ) }, |
|
88 { _S( "Äääyy" ) }, |
|
89 { 0 } |
|
90 }; |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 //--------------------------------------------------------------- |
|
96 // METHODS |
|
97 //--------------------------------------------------------------- |
|
98 // |
|
99 IMPSSAPSettingsStoreTestUtils::IMPSSAPSettingsStoreTestUtils() |
|
100 { |
|
101 } |
|
102 |
|
103 IMPSSAPSettingsStoreTestUtils::~IMPSSAPSettingsStoreTestUtils() |
|
104 { |
|
105 } |
|
106 |
|
107 |
|
108 //--------------------------------------------------------------- |
|
109 // Store deletion |
|
110 //--------------------------------------------------------------- |
|
111 // |
|
112 /*void IMPSSAPSettingsStoreTestUtils::DeleteStoresL( TUint aStoreId ) |
|
113 { |
|
114 DeleteNormalStoreL( aStoreId ); |
|
115 DeleteDefaultStoresL( aStoreId ); |
|
116 } |
|
117 |
|
118 |
|
119 void IMPSSAPSettingsStoreTestUtils::DeleteNormalStoreL( TUint aStoreId ) |
|
120 { |
|
121 |
|
122 { |
|
123 TFileName fileName; |
|
124 AppendDbName( fileName, aStoreId ); |
|
125 DoDeleteNormalFileL( fileName ); |
|
126 } |
|
127 |
|
128 { |
|
129 TFileName fileName; |
|
130 AppendIniName( fileName, aStoreId ); |
|
131 DoDeleteNormalFileL( fileName ); |
|
132 } |
|
133 |
|
134 } |
|
135 */ |
|
136 /* |
|
137 void IMPSSAPSettingsStoreTestUtils::DeleteDefaultStoresL( TUint aStoreId ) |
|
138 { |
|
139 TFileName fileNameSearch; |
|
140 |
|
141 { |
|
142 TFileName dbFileName; |
|
143 AppendDbName( dbFileName, aStoreId, ETrue ); |
|
144 fileNameSearch.Append( TParsePtrC( dbFileName ).Path() ); |
|
145 fileNameSearch.Append( TParsePtrC( dbFileName ).NameAndExt() ); |
|
146 } |
|
147 DoDeleteDefaultFilesL( fileNameSearch ); |
|
148 |
|
149 fileNameSearch.Zero(); |
|
150 { |
|
151 TFileName iniFileName; |
|
152 AppendIniName( iniFileName, aStoreId, ETrue ); |
|
153 fileNameSearch.Append( TParsePtrC( iniFileName ).Path() ); |
|
154 fileNameSearch.Append( TParsePtrC( iniFileName ).NameAndExt() ); |
|
155 } |
|
156 |
|
157 |
|
158 DoDeleteDefaultFilesL( fileNameSearch ); |
|
159 } |
|
160 |
|
161 */ |
|
162 |
|
163 /* |
|
164 void IMPSSAPSettingsStoreTestUtils::UseDbL( TUint aStoreId, |
|
165 const TDesC* aSapDbToUse, |
|
166 const TDesC* aIniFileToUse ) |
|
167 { |
|
168 DeleteNormalStoreL( aStoreId ); |
|
169 |
|
170 if( aSapDbToUse ) |
|
171 { |
|
172 TFileName sourceFile; |
|
173 sourceFile.Append( KSapDb_TestFileFolder ); |
|
174 sourceFile.Append( *aSapDbToUse ); |
|
175 |
|
176 TFileName destinationFile; |
|
177 AppendDbName( destinationFile, aStoreId, ETrue ); |
|
178 CopyFileToNameL( sourceFile, destinationFile ); |
|
179 } |
|
180 |
|
181 if( aIniFileToUse ) |
|
182 { |
|
183 TFileName sourceFile; |
|
184 sourceFile.Append( KSapDb_TestFileFolder ); |
|
185 sourceFile.Append( *aIniFileToUse ); |
|
186 |
|
187 TFileName destinationFile; |
|
188 AppendIniName( destinationFile, aStoreId, ETrue ); |
|
189 CopyFileToNameL( sourceFile, destinationFile ); |
|
190 } |
|
191 } |
|
192 |
|
193 |
|
194 void IMPSSAPSettingsStoreTestUtils::UseDefaultDbL( TUint aStoreId, |
|
195 const TDesC& aSapDbToUse, |
|
196 const TDesC* aIniFileToUse ) |
|
197 { |
|
198 DeleteDefaultStoresL(); |
|
199 |
|
200 { |
|
201 TFileName sourceFile; |
|
202 sourceFile.Append( KSapDb_TestFileFolder ); |
|
203 sourceFile.Append( aSapDbToUse ); |
|
204 |
|
205 TFileName destinationFile; |
|
206 destinationFile.Append( KDbDefaultFilesFolder ); |
|
207 AppendDbName( destinationFile, aStoreId, EFalse ); |
|
208 CopyFileToNameL( sourceFile, destinationFile ); |
|
209 } |
|
210 |
|
211 if( aIniFileToUse ) |
|
212 { |
|
213 TFileName sourceFile; |
|
214 sourceFile.Append( KSapDb_TestFileFolder ); |
|
215 sourceFile.Append( *aIniFileToUse ); |
|
216 |
|
217 TFileName destinationFile; |
|
218 destinationFile.Append( KDbDefaultFilesFolder ); |
|
219 AppendIniName( destinationFile, aStoreId, EFalse ); |
|
220 CopyFileToNameL( sourceFile, destinationFile ); |
|
221 } |
|
222 } |
|
223 |
|
224 |
|
225 //--------------------------------------------------------------- |
|
226 // Store size print |
|
227 //--------------------------------------------------------------- |
|
228 // |
|
229 void IMPSSAPSettingsStoreTestUtils::PrintStoreSizesL( TUint aStoreId ) |
|
230 { |
|
231 RFs fs; |
|
232 User::LeaveIfError( fs.Connect() ); |
|
233 CleanupClosePushL( fs ); |
|
234 |
|
235 TFileName fileName; |
|
236 fileName.Append( KDbFileNameHead ); |
|
237 fileName.AppendNum( aStoreId ); |
|
238 fileName.Append( KDbFileNameTail ); |
|
239 |
|
240 TParsePtr parse( fileName ); |
|
241 TPtrC fileNameAndExt = parse.NameAndExt(); |
|
242 |
|
243 TEntry entry; |
|
244 TInt err; |
|
245 |
|
246 err = fs.Entry( fileName, entry ); |
|
247 if( err == KErrNone ) |
|
248 { |
|
249 RDebug::Print( _L("%S size: %d bytes"), &fileNameAndExt, entry.iSize ); |
|
250 } |
|
251 |
|
252 if( err == KErrNotFound ) |
|
253 { |
|
254 RDebug::Print( _L("File not found.") ); |
|
255 err = KErrNone; |
|
256 } |
|
257 User::LeaveIfError( err ); |
|
258 |
|
259 CleanupStack::PopAndDestroy(); //fs |
|
260 } |
|
261 |
|
262 */ |
|
263 |
|
264 //--------------------------------------------------------------- |
|
265 // SAP name handling |
|
266 //--------------------------------------------------------------- |
|
267 // |
|
268 void IMPSSAPSettingsStoreTestUtils::UnigueSAPNameL( TUint& aNameIndex, |
|
269 CIMPSSAPSettings& aSAP ) |
|
270 { |
|
271 aNameIndex++; |
|
272 HBufC* name = HBufC::NewLC( aSAP.SAPName().Length() + 10 ); |
|
273 TPtr namePtr( name->Des() ); |
|
274 |
|
275 namePtr.Copy( aSAP.SAPName() ); |
|
276 if ( namePtr.Length() > 4 ) |
|
277 { |
|
278 namePtr.Delete( namePtr.Length() - 4, 4 ); |
|
279 } |
|
280 namePtr.AppendFormat( KNumberFormat, aNameIndex ); |
|
281 |
|
282 aSAP.SetSAPNameL( namePtr ); |
|
283 |
|
284 CleanupStack::PopAndDestroy(); //name |
|
285 } |
|
286 |
|
287 |
|
288 |
|
289 //--------------------------------------------------------------- |
|
290 // SAP add |
|
291 //--------------------------------------------------------------- |
|
292 // |
|
293 void IMPSSAPSettingsStoreTestUtils::AddSAPSettingsL( CIMPSSAPSettingsStore& aStoreToAdd, |
|
294 TInt aHowMany, |
|
295 TUint32& aFirstUid, |
|
296 TUint32& aLastUid, |
|
297 TIMPSAccessGroup aGroup ) |
|
298 { |
|
299 __ASSERT_ALWAYS( ( aHowMany >= 2 ), User::Panic( _L( "Add count" ), 1 ) ); |
|
300 |
|
301 CIMPSSAPSettings* settings = CIMPSSAPSettings::NewL(); |
|
302 CleanupStack::PushL( settings ); |
|
303 |
|
304 TBuf< 15 > sapName; |
|
305 |
|
306 for ( TInt ii( 0 ); ii < aHowMany; ii++ ) |
|
307 { |
|
308 sapName.Zero(); |
|
309 sapName.Copy( KSAPName ); |
|
310 sapName.AppendFormat( KNumberFormat, ii ); |
|
311 |
|
312 settings->Reset(); |
|
313 IMPSSAPSettingsStoreTestUtils::FillContainerL( *settings, sapName ); |
|
314 |
|
315 TUint32 uid = aStoreToAdd.StoreNewSAPL( settings, aGroup ); |
|
316 |
|
317 if ( ii == 0 ) |
|
318 { |
|
319 aFirstUid = uid; //first id |
|
320 } |
|
321 |
|
322 aLastUid = uid; //last id |
|
323 } |
|
324 |
|
325 CleanupStack::PopAndDestroy(); //settings |
|
326 } |
|
327 |
|
328 |
|
329 |
|
330 //--------------------------------------------------------------- |
|
331 // SAP add |
|
332 //--------------------------------------------------------------- |
|
333 // |
|
334 void IMPSSAPSettingsStoreTestUtils::AddSAPSettingsL( CIMPSSAPSettingsStore& aStoreToAdd, |
|
335 TInt aHowMany, |
|
336 TIMPSAccessGroup aGroup ) |
|
337 { |
|
338 TUint32 firstUid = 0; |
|
339 TUint32 lastUid = 0; |
|
340 |
|
341 AddSAPSettingsL( aStoreToAdd, aHowMany, firstUid, lastUid, aGroup ); |
|
342 } |
|
343 |
|
344 |
|
345 |
|
346 //--------------------------------------------------------------- |
|
347 // SAP add |
|
348 //--------------------------------------------------------------- |
|
349 // |
|
350 TInt IMPSSAPSettingsStoreTestUtils::AddSAPSettingsWithLiteralNamesL( CIMPSSAPSettingsStore& aStoreToAdd, |
|
351 TUint32& aFirstUid, |
|
352 TUint32& aLastUid, |
|
353 TIMPSAccessGroup aGroup ) |
|
354 { |
|
355 CIMPSSAPSettings* settings = CIMPSSAPSettings::NewL(); |
|
356 CleanupStack::PushL( settings ); |
|
357 TInt ii; |
|
358 |
|
359 for ( ii = 0 ; KSAPNames[ ii ].iName != NULL; ii++ ) |
|
360 { |
|
361 settings->Reset(); |
|
362 const TPtrC name = KSAPNames[ ii ].iName; |
|
363 FillContainerL( *settings, name ); |
|
364 |
|
365 RDebug::Print( _L( "Storing literal name: %S " ), &name ); |
|
366 TUint32 uid = aStoreToAdd.StoreNewSAPL( settings, aGroup ); |
|
367 |
|
368 if ( ii == 0 ) |
|
369 { |
|
370 aFirstUid = uid; //first id |
|
371 } |
|
372 |
|
373 aLastUid = uid; //last id |
|
374 } |
|
375 |
|
376 CleanupStack::PopAndDestroy(); //settings |
|
377 return ii; |
|
378 } |
|
379 |
|
380 |
|
381 //--------------------------------------------------------------- |
|
382 // SAP deletion |
|
383 //--------------------------------------------------------------- |
|
384 // |
|
385 TInt IMPSSAPSettingsStoreTestUtils::DeleteAllSAPSettingsL( CIMPSSAPSettingsStore& aStoreToClear ) |
|
386 { |
|
387 TInt deleteCount = 0; |
|
388 CIMPSSAPSettingsList* list = CIMPSSAPSettingsList::NewLC(); |
|
389 aStoreToClear.PopulateSAPSettingsListL( *list, EIMPSAccessFilterAll ); |
|
390 |
|
391 RDebug::Print( _L( "delete all SAPCount: %d" ), aStoreToClear.SAPCountL( EIMPSAccessFilterAll ) ); |
|
392 |
|
393 if ( aStoreToClear.SAPCountL( EIMPSAccessFilterAll ) >= 1 ) |
|
394 { |
|
395 //clear the store |
|
396 const TInt listCount = list->Count(); |
|
397 for ( TInt ii( 0 ); ii < listCount ; ii++ ) |
|
398 { |
|
399 aStoreToClear.DeleteSAPL( ( *list )[ ii ]->Uid() ); |
|
400 deleteCount++; |
|
401 } |
|
402 } |
|
403 |
|
404 CleanupStack::PopAndDestroy(); // list |
|
405 return deleteCount; |
|
406 } |
|
407 |
|
408 |
|
409 |
|
410 //--------------------------------------------------------------- |
|
411 // SAP fill |
|
412 //--------------------------------------------------------------- |
|
413 // |
|
414 void IMPSSAPSettingsStoreTestUtils::RandomFillKey( TDes& aBuffer, TInt64& aSeed ) |
|
415 { |
|
416 aBuffer.Zero(); |
|
417 for ( TInt i( 0 ); i < aBuffer.MaxLength(); i++ ) |
|
418 { |
|
419 TChar ch = Math::Rand( aSeed ) % 200 + 32; |
|
420 aBuffer.Append( ch ); |
|
421 } |
|
422 } |
|
423 |
|
424 |
|
425 void IMPSSAPSettingsStoreTestUtils::FillContainerL( CIMPSSAPSettings& aSettings, |
|
426 const TDesC& aName ) |
|
427 { |
|
428 if ( aName.Length() == 0 ) |
|
429 { |
|
430 aSettings.SetSAPNameL( KSAPName ); |
|
431 } |
|
432 else |
|
433 { |
|
434 aSettings.SetSAPNameL( aName ); |
|
435 } |
|
436 |
|
437 aSettings.SetSAPAddressL( KSAPAddres ); |
|
438 aSettings.SetSAPPort( KSAPPort ); |
|
439 aSettings.SetSAPUserIdL( KSAPUserId ); |
|
440 aSettings.SetSAPUserPasswordL( KSAPUserPassword ); |
|
441 |
|
442 aSettings.SetHTTPProxyAddressL( KHTTPProxyAddres ); |
|
443 aSettings.SetHTTPProxyUserIdL( KHTTPProxyUserId ); |
|
444 aSettings.SetHTTPProxyUserPasswordL( KHTTPProxyUserPassword ); |
|
445 aSettings.SetHTTPProxyPort( KHTTPProxyPort ); |
|
446 |
|
447 aSettings.SetAccessPoint( KAP ); |
|
448 aSettings.SetClientIdL( KCLientId ); |
|
449 |
|
450 aSettings.SetHighLevelServices( KHighlevelServices ); |
|
451 aSettings.SetAuthorizationMode( KAuthorizationMode ); |
|
452 aSettings.SetServerAcceptedContentTypeL( KServerAcceptedContentType ); |
|
453 aSettings.SetServerAuthenticationNameL( KServerAuthenticationUsername ); |
|
454 aSettings.SetServerAuthenticationPasswordL( KServerAuthenticationPassword ); |
|
455 |
|
456 aSettings.SetOpaqueDesC8( KKey8, KOpaque8 ); |
|
457 aSettings.SetOpaqueDesC16( KKey16, KOpaque16 ); |
|
458 aSettings.SetOpaqueInt( KKeyInt, KOpaqueInt ); |
|
459 aSettings.SetAccessGroup( EIMPSIMAccessGroup ); |
|
460 |
|
461 } |
|
462 |
|
463 //--------------------------------------------------------------- |
|
464 // SAP fill |
|
465 //--------------------------------------------------------------- |
|
466 // |
|
467 void IMPSSAPSettingsStoreTestUtils::FillContainerPartiallyL( CIMPSSAPSettings& aSettings, |
|
468 const TDesC& aName ) |
|
469 { |
|
470 if ( aName.Length() == 0 ) |
|
471 { |
|
472 aSettings.SetSAPNameL( KSAPName ); |
|
473 } |
|
474 else |
|
475 { |
|
476 aSettings.SetSAPNameL( aName ); |
|
477 } |
|
478 |
|
479 aSettings.SetSAPAddressL( KSAPAddres ); |
|
480 aSettings.SetSAPUserPasswordL( KSAPUserPassword ); |
|
481 |
|
482 aSettings.SetHTTPProxyUserIdL( KHTTPProxyUserId ); |
|
483 aSettings.SetHTTPProxyPort( KHTTPProxyPort ); |
|
484 aSettings.SetHTTPProxyUserPasswordL( KHTTPProxyUserPassword ); |
|
485 aSettings.SetAccessGroup( EIMPSIMAccessGroup ); |
|
486 } |
|
487 |
|
488 |
|
489 //--------------------------------------------------------------- |
|
490 // SAP fill |
|
491 //--------------------------------------------------------------- |
|
492 // |
|
493 void IMPSSAPSettingsStoreTestUtils::FillContainerLongDataL( CIMPSSAPSettings& aSettings ) |
|
494 { |
|
495 TTime seedtime; |
|
496 seedtime.HomeTime(); |
|
497 |
|
498 TInt64 seed = seedtime.Int64(); |
|
499 |
|
500 HBufC* buf = HBufC::NewLC( 128 ); |
|
501 TPtr tmp = buf->Des(); |
|
502 RandomFillKey( tmp, seed ); |
|
503 |
|
504 aSettings.SetSAPNameL( *buf ); |
|
505 |
|
506 aSettings.SetSAPAddressL( *buf ); |
|
507 aSettings.SetSAPPort( KMaxTInt32 ); |
|
508 aSettings.SetSAPUserIdL( *buf ); |
|
509 aSettings.SetSAPUserPasswordL( *buf ); |
|
510 |
|
511 aSettings.SetHTTPProxyAddressL( *buf ); |
|
512 aSettings.SetHTTPProxyUserIdL( *buf ); |
|
513 aSettings.SetHTTPProxyUserPasswordL( *buf ); |
|
514 aSettings.SetHTTPProxyPort( KMaxTInt32 ); |
|
515 |
|
516 aSettings.SetAccessPoint( KMaxTUint ); |
|
517 aSettings.SetClientIdL( *buf ); |
|
518 |
|
519 aSettings.SetServerAcceptedContentTypeL( *buf ); |
|
520 aSettings.SetServerAuthenticationNameL( *buf ); |
|
521 aSettings.SetServerAuthenticationPasswordL( *buf ); |
|
522 |
|
523 aSettings.SetAccessGroup( EIMPSIMAccessGroup ); |
|
524 |
|
525 CleanupStack::PopAndDestroy(); //buf |
|
526 } |
|
527 |
|
528 |
|
529 //--------------------------------------------------------------- |
|
530 // SAP fill |
|
531 //--------------------------------------------------------------- |
|
532 // |
|
533 void IMPSSAPSettingsStoreTestUtils::FillContainerEvenLongerDataL( CIMPSSAPSettings& aSettings ) |
|
534 { |
|
535 TTime seedtime; |
|
536 seedtime.HomeTime(); |
|
537 TInt64 seed = seedtime.Int64(); |
|
538 |
|
539 HBufC* buf = HBufC::NewLC( 300 ); |
|
540 TPtr tmp = buf->Des(); |
|
541 RandomFillKey( tmp, seed ); |
|
542 |
|
543 aSettings.SetSAPNameL( *buf ); |
|
544 aSettings.SetSAPAddressL( *buf ); |
|
545 aSettings.SetSAPPort( KMaxTInt32 ); |
|
546 aSettings.SetSAPUserIdL( *buf ); |
|
547 aSettings.SetSAPUserPasswordL( *buf ); |
|
548 |
|
549 aSettings.SetHTTPProxyAddressL( *buf ); |
|
550 aSettings.SetHTTPProxyUserIdL( *buf ); |
|
551 aSettings.SetHTTPProxyUserPasswordL( *buf ); |
|
552 aSettings.SetHTTPProxyPort( KMaxTInt32 ); |
|
553 |
|
554 aSettings.SetAccessPoint( KMaxTUint ); |
|
555 aSettings.SetClientIdL( *buf ); |
|
556 |
|
557 aSettings.SetServerAcceptedContentTypeL( *buf ); |
|
558 aSettings.SetServerAuthenticationNameL( *buf ); |
|
559 aSettings.SetServerAuthenticationPasswordL( *buf ); |
|
560 aSettings.SetAccessGroup( EIMPSIMAccessGroup ); |
|
561 |
|
562 CleanupStack::PopAndDestroy(); //buf |
|
563 } |
|
564 |
|
565 |
|
566 //--------------------------------------------------------------- |
|
567 // SAP data check |
|
568 //--------------------------------------------------------------- |
|
569 // |
|
570 TBool IMPSSAPSettingsStoreTestUtils::Equals( CIMPSSAPSettings& aFirst, |
|
571 CIMPSSAPSettings& aSecond ) |
|
572 { |
|
573 |
|
574 if ( aFirst.SAPName().Compare( aSecond.SAPName() ) != 0 ) |
|
575 { |
|
576 return EFalse; |
|
577 } |
|
578 |
|
579 if ( aFirst.SAPAddress().Compare( aSecond.SAPAddress() ) != 0 ) |
|
580 { |
|
581 return EFalse; |
|
582 } |
|
583 |
|
584 if ( aFirst.HTTPProxyAddress().Compare( aSecond.HTTPProxyAddress() ) != 0 ) |
|
585 { |
|
586 return EFalse; |
|
587 } |
|
588 |
|
589 if ( aFirst.SAPUserId().Compare( aSecond.SAPUserId() ) != 0 ) |
|
590 { |
|
591 return EFalse; |
|
592 } |
|
593 |
|
594 if ( aFirst.SAPUserPassword().Compare( aSecond.SAPUserPassword() ) != 0 ) |
|
595 { |
|
596 return EFalse; |
|
597 } |
|
598 |
|
599 if ( aFirst.HTTPProxyUserId().Compare( aSecond.HTTPProxyUserId() ) != 0 ) |
|
600 { |
|
601 return EFalse; |
|
602 } |
|
603 |
|
604 if ( aFirst.HTTPProxyUserPassword().Compare( aSecond.HTTPProxyUserPassword() ) != 0 ) |
|
605 { |
|
606 return EFalse; |
|
607 } |
|
608 |
|
609 if ( aFirst.SAPPort() != aSecond.SAPPort() ) |
|
610 { |
|
611 return EFalse; |
|
612 } |
|
613 |
|
614 if ( aFirst.HTTPProxyPort() != aSecond.HTTPProxyPort() ) |
|
615 { |
|
616 return EFalse; |
|
617 } |
|
618 |
|
619 if ( aFirst.AccessPoint() != aSecond.AccessPoint() ) |
|
620 { |
|
621 return EFalse; |
|
622 } |
|
623 |
|
624 if ( aFirst.ClientId().Compare( aSecond.ClientId() ) != 0 ) |
|
625 { |
|
626 return EFalse; |
|
627 } |
|
628 |
|
629 if ( aFirst.HighLevelServices() != aSecond.HighLevelServices() ) |
|
630 { |
|
631 return EFalse; |
|
632 } |
|
633 |
|
634 if ( aFirst.AuthorizationMode() != aSecond.AuthorizationMode() ) |
|
635 { |
|
636 return EFalse; |
|
637 } |
|
638 |
|
639 if ( aFirst.ServerAuthenticationName().Compare( aSecond.ServerAuthenticationName() ) != 0 ) |
|
640 { |
|
641 return EFalse; |
|
642 } |
|
643 |
|
644 if ( aFirst.ServerAuthenticationPassword().Compare( aSecond.ServerAuthenticationPassword() ) != 0 ) |
|
645 { |
|
646 return EFalse; |
|
647 } |
|
648 |
|
649 if ( aFirst.Protection() != aSecond.Protection() ) |
|
650 { |
|
651 return EFalse; |
|
652 } |
|
653 |
|
654 return ETrue; |
|
655 } |
|
656 |
|
657 |
|
658 /* |
|
659 |
|
660 //--------------------------------------------------------------- |
|
661 // Store name access |
|
662 //--------------------------------------------------------------- |
|
663 // |
|
664 void IMPSSAPSettingsStoreTestUtils::AppendDbName( TFileName& aFileName, |
|
665 TUint aStoreId, |
|
666 TBool aFullPath ) |
|
667 { |
|
668 if( aFullPath ) |
|
669 { |
|
670 aFileName.Append( KDbFilesFolder ); |
|
671 } |
|
672 |
|
673 aFileName.Append( KDbFileNameHead ); |
|
674 aFileName.AppendNum( (TUint) aStoreId ); |
|
675 aFileName.Append( KDbFileNameTail ); |
|
676 } |
|
677 |
|
678 |
|
679 |
|
680 void IMPSSAPSettingsStoreTestUtils::AppendIniName( TFileName& aFileName, |
|
681 TUint aStoreId, |
|
682 TBool aFullPath ) |
|
683 { |
|
684 if( aFullPath ) |
|
685 { |
|
686 aFileName.Append( KDbFilesFolder ); |
|
687 } |
|
688 |
|
689 aFileName.Append( KDbIniFileNameHead ); |
|
690 aFileName.AppendNum( (TUint) aStoreId ); |
|
691 aFileName.Append( KDbIniFileNameTail ); |
|
692 } |
|
693 |
|
694 |
|
695 //--------------------------------------------------------------- |
|
696 // Raw file copy & delete |
|
697 //--------------------------------------------------------------- |
|
698 // |
|
699 void IMPSSAPSettingsStoreTestUtils::CopyFileToNameL( const TDesC& aSourceFile, |
|
700 const TDesC& aDestinationFile ) |
|
701 { |
|
702 RFs fs; |
|
703 User::LeaveIfError( fs.Connect() ); |
|
704 CleanupClosePushL( fs ); |
|
705 |
|
706 CFileMan* fileMan = CFileMan::NewL( fs ); |
|
707 CleanupStack::PushL( fileMan ); |
|
708 |
|
709 RDebug::Print( _L("Copying [%S] to [%S]"), &aSourceFile, &aDestinationFile ); |
|
710 User::LeaveIfError( fileMan->Copy( aSourceFile, aDestinationFile ) ); |
|
711 |
|
712 //make sure the file is now there |
|
713 TEntry entry; |
|
714 User::LeaveIfError( fs.Entry( aDestinationFile, entry ) ); |
|
715 |
|
716 CleanupStack::PopAndDestroy( 2 ); //fileMan, fs |
|
717 } |
|
718 |
|
719 |
|
720 |
|
721 void IMPSSAPSettingsStoreTestUtils::DoDeleteDefaultFilesL( const TDesC& aDefFileSearchName ) |
|
722 { |
|
723 RFs fs; |
|
724 User::LeaveIfError( fs.Connect() ); |
|
725 CleanupClosePushL( fs ); |
|
726 |
|
727 CFileMan* fileMan = CFileMan::NewL( fs ); |
|
728 CleanupStack::PushL( fileMan ); |
|
729 |
|
730 |
|
731 TFindFile defaultDbFinder( fs ); |
|
732 TInt defaultFound = defaultDbFinder.FindByDir( aDefFileSearchName, KNullDesC ); |
|
733 while( defaultFound == KErrNone ) |
|
734 { |
|
735 //default file found somewhere |
|
736 //try to delete it if ok |
|
737 TParsePtrC driveCheck( defaultDbFinder.File() ); |
|
738 if( driveCheck.Drive().Compare( _L("C:") ) != 0 ) |
|
739 { |
|
740 //found default db from somewhere else than C: |
|
741 if( driveCheck.Drive().Compare( _L("Z:") ) == 0 ) |
|
742 { |
|
743 //found default from Z: ==> can't be removed EPOC code |
|
744 RDebug::Print( _L("NOTE!! Default file [%S] found from ROM!!"), &defaultDbFinder.File() ); |
|
745 RDebug::Print( _L("NOTE!! Default file [%S] found from ROM!!"), &defaultDbFinder.File() ); |
|
746 User::Panic( _L("Def DB on ROM"), 1 ); |
|
747 } |
|
748 |
|
749 TInt err = fileMan->Delete( defaultDbFinder.File() ); |
|
750 if( err != KErrNone ) |
|
751 { |
|
752 RDebug::Print( _L("IMPSSAPSettingsStoreTestUtils:: Default file to delete [%S] failed: %d"), |
|
753 &defaultDbFinder.File(), err ); |
|
754 User::LeaveIfError( err ); |
|
755 } |
|
756 } |
|
757 |
|
758 defaultFound = defaultDbFinder.Find(); |
|
759 } |
|
760 |
|
761 CleanupStack::PopAndDestroy( 2 ); //fileMan, fs |
|
762 } |
|
763 |
|
764 |
|
765 void IMPSSAPSettingsStoreTestUtils::DoDeleteNormalFileL( const TDesC& aFile ) |
|
766 { |
|
767 RFs fs; |
|
768 User::LeaveIfError( fs.Connect() ); |
|
769 CleanupClosePushL( fs ); |
|
770 CFileMan* fileMan = CFileMan::NewL( fs ); |
|
771 CleanupStack::PushL( fileMan ); |
|
772 |
|
773 TInt err = fileMan->Attribs( aFile, |
|
774 KEntryAttNormal, |
|
775 KEntryAttReadOnly | KEntryAttArchive | KEntryAttSystem, |
|
776 TTime(0), |
|
777 0 ); |
|
778 |
|
779 if( (err != KErrNone) && (err != KErrNotFound) ) |
|
780 { |
|
781 RDebug::Print( _L("IMPSSAPSettingsStoreTestUtils::Normal delete [%S] failed: %d"), &aFile, err ); |
|
782 User::LeaveIfError( err ); |
|
783 } |
|
784 |
|
785 err = fileMan->Delete( aFile ); |
|
786 if( (err != KErrNone) && (err != KErrNotFound) ) |
|
787 { |
|
788 RDebug::Print( _L("IMPSSAPSettingsStoreTestUtils::Normal delete [%S] failed: %d"), &aFile, err ); |
|
789 User::LeaveIfError( err ); |
|
790 } |
|
791 |
|
792 CleanupStack::PopAndDestroy( 2 ); //fileMan, fs |
|
793 } |
|
794 */ |