|
1 /* |
|
2 * Copyright (c) 2006-2009 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 the License "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "tauthcliservstep.h" |
|
20 |
|
21 using namespace AuthServer; |
|
22 |
|
23 |
|
24 void CTAuthcliservStepBase::WaitForServerToReleaseDb() |
|
25 /** |
|
26 Wait for the server to shut down and so |
|
27 release the authentication database. |
|
28 */ |
|
29 { |
|
30 TFullName name; |
|
31 for (;;) |
|
32 { |
|
33 TFindServer find(::KAuthServerName); |
|
34 if (find.Next(name) != KErrNone) |
|
35 { |
|
36 break; |
|
37 } |
|
38 |
|
39 // Wait for server to terminate |
|
40 User::After(1 * 1000 * 1000); |
|
41 } |
|
42 } |
|
43 |
|
44 |
|
45 void CTAuthcliservStepBase::RemoveExistingDbL() |
|
46 /** |
|
47 Remove any existing database file. |
|
48 */ |
|
49 { |
|
50 WaitForServerToReleaseDb(); |
|
51 |
|
52 TDriveUnit sysDrive (RFs::GetSystemDrive()); |
|
53 TDriveName sysDriveName (sysDrive.Name()); |
|
54 |
|
55 TFileName dbName(KDbName); |
|
56 dbName[0] = 'A' + sysDrive; |
|
57 TInt r = iFs.Delete(dbName); |
|
58 User::LeaveIfError(r); |
|
59 |
|
60 //Reset the data 'AllUserID&PinValues' in AuthSvrPolicy.ini & the |
|
61 // individual plugin Db files |
|
62 //_LIT(KInitPinDatabaseValue, ","); |
|
63 TBufC<16> initPinDbBuffer(KInitPinDatabaseValue); |
|
64 TPtr valueToWrite = initPinDbBuffer.Des(); |
|
65 |
|
66 TBuf<64> fileName (sysDriveName); |
|
67 fileName.Append(KAuthSvrPolicyFile); |
|
68 writeToNamedConfig(fileName, KTotalDbTag, valueToWrite); |
|
69 |
|
70 fileName.Copy(sysDriveName); |
|
71 fileName.Append(KPlugin3100File); |
|
72 writeToNamedConfig(fileName, KPinDbTag, valueToWrite); |
|
73 |
|
74 fileName.Copy(sysDriveName); |
|
75 fileName.Append(KPlugin3101File); |
|
76 writeToNamedConfig(fileName, KPinDbTag, valueToWrite); |
|
77 |
|
78 fileName.Copy(sysDriveName); |
|
79 fileName.Append(KPlugin3102File); |
|
80 writeToNamedConfig(fileName, KPinDbTag, valueToWrite); |
|
81 } |
|
82 |
|
83 TInt CTAuthcliservStepBase::writeToNamedConfig(const TDesC &aFileName, const TDesC &aKeyName,const TPtrC &aResult) |
|
84 { |
|
85 |
|
86 TInt retValue = KErrNone; |
|
87 CIniData* file=NULL; |
|
88 TRAPD(r,file=CIniData::NewL(aFileName)); |
|
89 |
|
90 if(r!=KErrNone) |
|
91 { |
|
92 RDebug::Print(_L("Unable to create CIniData object. Error = %d, File = %S"), r, &aFileName); |
|
93 retValue = r; |
|
94 } |
|
95 |
|
96 else |
|
97 { |
|
98 // Look for a key under no named section, retrieve text value |
|
99 |
|
100 TInt ret = KErrNone; //return value from FindVar functions |
|
101 ret=file->SetValue(aKeyName ,aResult); |
|
102 if(ret != KErrNone) |
|
103 { |
|
104 if(ret == KErrNotFound) |
|
105 { |
|
106 RDebug::Print(_L("Key not found. Unable to set value in ini file. Filename: %S, KeyName = %S, value = %S."), &aFileName, &aKeyName, &aResult); |
|
107 } |
|
108 else |
|
109 { |
|
110 RDebug::Print(_L("Unable to set value in ini file. Filename: %S, KeyName = %S, value = %S."), &aFileName, &aKeyName, &aResult); |
|
111 } |
|
112 retValue = ret; |
|
113 } |
|
114 TRAPD(r,file->WriteToFileL()); |
|
115 if (KErrNone != r) |
|
116 { |
|
117 RDebug::Print(_L("Error occurred while writing to the file. Filename = %S, KeyName = %S, value = %S."), &aFileName, &aKeyName, &aResult); |
|
118 } |
|
119 delete file; |
|
120 } |
|
121 return retValue; |
|
122 } |