127 __LOG1( ELogAlways, "MDS DB not valid, creating tables: %d", 0 ); |
127 __LOG1( ELogAlways, "MDS DB not valid, creating tables: %d", 0 ); |
128 // first-time init: re-form the database completely |
128 // first-time init: re-form the database completely |
129 iMaintenance->CreateDatabaseL( ); |
129 iMaintenance->CreateDatabaseL( ); |
130 const TUint KMdSServerUid = 0x0320e65f; // temporal uid |
130 const TUint KMdSServerUid = 0x0320e65f; // temporal uid |
131 |
131 |
132 // try to read schema file from C drive |
132 TInt schemaError( KErrNone ); |
133 TRAPD( err, ImportSchemaL( aSchema, KSchemaImportFile, KMdSServerUid) ); |
133 |
134 |
134 if( iPrivateSchemaFileInvalid ) |
135 if( err != KErrNone ) |
135 { |
|
136 // if schema was updated in FOTA update, read the updated schema from ROM |
|
137 TRAP( schemaError, ImportSchemaL( aSchema, KSchemaRomImportFile, KMdSServerUid) ); |
|
138 } |
|
139 else |
|
140 { |
|
141 // try to read schema file from C drive |
|
142 TRAP( schemaError, ImportSchemaL( aSchema, KSchemaImportFile, KMdSServerUid) ); |
|
143 } |
|
144 |
|
145 if( schemaError != KErrNone ) |
136 { |
146 { |
137 __LOG1( ELogAlways, "Schema reading error: %d", err ); |
147 __LOG1( ELogAlways, "Schema reading error: %d", schemaError ); |
138 // if schema file is not found, try to read from rom (Z) drive |
148 // if schema file is not found, try to read from rom (Z) drive |
139 if ( err == KErrNotFound || err == KErrPathNotFound ) |
149 if ( schemaError == KErrNotFound || schemaError == KErrPathNotFound ) |
140 { |
150 { |
141 TRAP( err, ImportSchemaL( aSchema, KSchemaRomImportFile, KMdSServerUid) ); |
151 TRAP( schemaError, ImportSchemaL( aSchema, KSchemaRomImportFile, KMdSServerUid) ); |
142 } |
152 } |
143 if( err != KErrNone ) |
153 else if( !iPrivateSchemaFileInvalid && schemaError == KErrCorrupt ) |
|
154 { |
|
155 iPrivateSchemaFileInvalid = ETrue; |
|
156 } |
|
157 else |
|
158 { |
|
159 schemaError = KErrUnknown; |
|
160 } |
|
161 if( schemaError != KErrNone ) |
144 { |
162 { |
145 __LOG1( ELogAlways, "Schema reading error: %d", err ); |
163 __LOG1( ELogAlways, "Schema reading error: %d", schemaError ); |
146 DeleteDatabase(); |
164 DeleteDatabase(); |
147 User::Leave( err ); |
165 User::Leave( schemaError ); |
148 } |
166 } |
149 } |
167 } |
150 |
168 |
151 if ( FailedImports() != 0 ) |
169 if ( FailedImports() != 0 ) |
152 { |
170 { |
153 User::Leave( KErrCorrupt ); |
171 User::Leave( KErrBadName ); |
154 } |
172 } |
155 |
173 |
156 // try to read default import file from C drive |
174 // try to read default import file from C drive |
157 TRAP( err, ImportMetadataL( aManipulate, aSchema, KMdsDefaultImportFile ) ); |
175 TRAPD( err, ImportMetadataL( aManipulate, aSchema, KMdsDefaultImportFile ) ); |
158 if ( err == KErrNotFound || err == KErrPathNotFound ) |
176 if ( err == KErrNotFound || err == KErrPathNotFound ) |
159 { |
177 { |
160 // if default import file is not found, try to read from rom (Z) drive |
178 // if default import file is not found, try to read from rom (Z) drive |
161 // and ignore errors |
179 // and ignore errors |
162 TRAP_IGNORE( ImportMetadataL( aManipulate, aSchema, KMdsDefaultRomImportFile ) ); |
180 TRAP_IGNORE( ImportMetadataL( aManipulate, aSchema, KMdsDefaultRomImportFile ) ); |