64 CLOG_WRITE( "CCdcCommsDatStartup::CreateTablesL" ); |
69 CLOG_WRITE( "CCdcCommsDatStartup::CreateTablesL" ); |
65 |
70 |
66 // In all RFS cases CommsDat tables must be checked/created |
71 // In all RFS cases CommsDat tables must be checked/created |
67 cdc->CreateTablesL(); |
72 cdc->CreateTablesL(); |
68 |
73 |
69 // If variant XML file exists, read it and create settings |
74 TFileName fileName; |
70 TFileName fileName( KVariantXmlFile ); |
75 GetInputFileNameL( fileName ); |
71 RFs fs; |
76 |
72 User::LeaveIfError( fs.Connect() ); |
77 // CommsDatCreator feature is supported if input file name |
73 RFile file; |
78 // lenght is not 0. However file name lenght at least 5. (x.xml) |
74 if ( KErrNone == file.Open( fs, fileName, EFileRead ) ) |
79 if( fileName.Length() > 0 ) |
75 { |
80 { |
76 file.Close(); |
|
77 CLOG_WRITE( "CCdcCommsDatStartup::CommsDat generation enabled" ); |
81 CLOG_WRITE( "CCdcCommsDatStartup::CommsDat generation enabled" ); |
78 |
82 |
79 TRAPD(err, cdc->CreateCommsDatL( fileName ) ); |
83 TFileName path( _L("Z:\\private\\10281BC3\\" ) ); |
80 if ( err != KErrNone ) |
84 path.Append( fileName ); |
81 { |
85 |
82 // CommsDat creation leaved so something must be wrong. |
86 CLOG_WRITE( "CCdcCommsDatStartup::CreateCommsDatL begin" ); |
83 // Reset CommsDat and EAP settings. |
87 |
84 ResetCommsDatToDefaultL(); |
88 TRAPD(err, cdc->CreateCommsDatL( path ) ); |
85 ResetEAPSettingsL(); |
89 if(err != KErrNone ) |
86 cdc->CreateTablesL(); |
90 { |
87 User::Leave( err ); |
91 // CommsDat creation leaved so something must be wrong. |
88 } |
92 // Reset CommsDat and EAP settings. |
89 |
93 ResetCommsDatToDefaultL(); |
90 CLOG_WRITE( "CCdcCommsDatStartup::CommsDat generation done" ); |
94 ResetEAPSettingsL(); |
91 } |
95 cdc->CreateTablesL(); |
92 else |
96 User::Leave( err ); |
93 { |
97 } |
94 CLOG_WRITE( "CCdcCommsDatStartup::CommsDat generation disabled" ); |
98 |
95 } |
99 CLOG_WRITE( "CCdcCommsDatStartup::CreateCommsDatL end" ); |
96 fs.Close(); |
100 } |
|
101 else |
|
102 { |
|
103 CLOG_WRITE( "CCdcCommsDatStartup::CommsDat generation disabled" ); |
|
104 } |
|
105 |
|
106 // If nothing has leaved then everything is okay (both in disabled and |
|
107 // enabled cases. |
|
108 SetStartupStatusL( ECommsDatInitialised ); |
97 |
109 |
98 CleanupStack::PopAndDestroy( cdc ); |
110 CleanupStack::PopAndDestroy( cdc ); |
99 CLOG_WRITE( "CCdcCommsDatStartup::DoStartL end" ); |
111 CLOG_WRITE( "CCdcCommsDatStartup::DoStartL end" ); |
100 } |
112 } |
101 |
113 |
102 // ---------------------------------------------------------------------------- |
114 // ---------------------------------------------------------------------------- |
|
115 // CCdcCommsDatStartup::CreateRepositoryL() |
|
116 // ---------------------------------------------------------------------------- |
|
117 // |
|
118 void CCdcCommsDatStartup::CreateRepositoryL() |
|
119 { |
|
120 CLOG_WRITE( "CCdcCommsDatStartup::CreateRepositoryL()" ); |
|
121 |
|
122 TRAPD( err, iRepository = CRepository::NewL( KCRUidCommsDatCreator ) ); |
|
123 |
|
124 // Log is important now, because repository cannot contain the |
|
125 // error value if it cannot be used |
|
126 if( err != KErrNone ) |
|
127 { |
|
128 CLOG_WRITE_FORMAT( "Repository could not created err : %d", err ); |
|
129 User::Leave( err ); |
|
130 } |
|
131 } |
|
132 |
|
133 // ---------------------------------------------------------------------------- |
|
134 // CCdcCommsDatStartup::SetStartupStatusL() |
|
135 // ---------------------------------------------------------------------------- |
|
136 // |
|
137 void CCdcCommsDatStartup::SetStartupStatusL( TInt aResult ) |
|
138 { |
|
139 CLOG_WRITE_FORMAT( "CCdcCommsDatStartup::SetStartupStatusL() %d", aResult ); |
|
140 |
|
141 TInt err = iRepository->Set( KCommsDatCreatorStartupStatus, aResult ); |
|
142 if( err != KErrNone ) |
|
143 { |
|
144 CLOG_WRITE_FORMAT( |
|
145 "Value could not write to repository err : %d", err ); |
|
146 User::Leave( err ); |
|
147 } |
|
148 |
|
149 CLOG_WRITE_FORMAT( "CCdcCommsDatStartup::SetStartupStatusL() %d", aResult ); |
|
150 } |
|
151 |
|
152 // ---------------------------------------------------------------------------- |
|
153 // CCdcCommsDatStartup::GetInputFileNameL() |
|
154 // ---------------------------------------------------------------------------- |
|
155 // |
|
156 void CCdcCommsDatStartup::GetInputFileNameL( TFileName &aFileName ) |
|
157 { |
|
158 CLOG_WRITE( "CCdcCommsDatStartup::GetInputFileNameL()" ); |
|
159 |
|
160 TInt err = iRepository->Get( KCommsDatCreatorInputFileName, aFileName ); |
|
161 if( err != KErrNone ) |
|
162 { |
|
163 CLOG_WRITE_FORMAT( |
|
164 "Value could not red from repository err : %d", err ); |
|
165 User::Leave( err ); |
|
166 } |
|
167 |
|
168 CLOG_WRITE( "Input filename red" ); |
|
169 |
|
170 HBufC *fileName = aFileName.AllocLC(); |
|
171 |
|
172 CLOG_WRITE_FORMAT( "Input filename value : %S", fileName ); |
|
173 |
|
174 CleanupStack::PopAndDestroy( fileName ); |
|
175 |
|
176 // Check if file exists. If it doesn't reset filename. |
|
177 RFs fs; |
|
178 err = fs.Connect();//check |
|
179 |
|
180 if( err == KErrNone ) |
|
181 { |
|
182 RFile file; |
|
183 |
|
184 TFileName path( _L("Z:\\private\\10281BC3\\" ) ); |
|
185 path.Append( aFileName ); |
|
186 |
|
187 err = file.Open(fs, path, EFileRead); |
|
188 if( err != KErrNone ) |
|
189 { |
|
190 CLOG_WRITE( "CCdcCommsDatStartup::GetInputFileNameL() File does not exist"); |
|
191 aFileName.Zero(); |
|
192 } |
|
193 else |
|
194 { |
|
195 file.Close(); |
|
196 } |
|
197 fs.Close(); |
|
198 } |
|
199 |
|
200 CLOG_WRITE( "CCdcCommsDatStartup::GetInputFileNameL()" ); |
|
201 } |
|
202 |
|
203 // ---------------------------------------------------------------------------- |
103 // CCdcCommsDatStartup::CheckCreatorUIdL() |
204 // CCdcCommsDatStartup::CheckCreatorUIdL() |
104 // ---------------------------------------------------------------------------- |
205 // ---------------------------------------------------------------------------- |
105 // |
206 // |
106 void CCdcCommsDatStartup::CheckCreatorUIdL() |
207 void CCdcCommsDatStartup::CheckCreatorUIdL() |
107 { |
208 { |
108 // UID of MainRfs |
209 // UID of MainRfs |
109 const TUid KCreatorUid = { 0x102073EA }; |
210 const TUid KCreatorUid = { 0x102073EA }; |
110 |
211 |
111 CLOG_WRITE( "CCdcCommsDatStartup::CheckCreatorUIdL" ); |
212 CLOG_WRITE( "CCdcCommsDatStartup::CheckCreatorUIdL" ); |
112 |
213 |
113 TUid creatorId = User::CreatorSecureId(); |
214 TUid creatorId = User::CreatorIdentity(); |
114 |
215 |
115 CLOG_WRITE_FORMAT( "CreatorId : %x", creatorId ); |
216 CLOG_WRITE_FORMAT( "CreatorId : %x", creatorId ); |
116 |
217 |
117 if( KCreatorUid != creatorId ) |
218 if( KCreatorUid != creatorId ) |
118 { |
219 { |