1090 { |
1103 { |
1091 DEBUG_PRINTF3(_L("CInstallationPlanner::ProcessControllerL failed to publish Uid %x with error %d."),publishUid.iUid, err); |
1104 DEBUG_PRINTF3(_L("CInstallationPlanner::ProcessControllerL failed to publish Uid %x with error %d."),publishUid.iUid, err); |
1092 User::Leave(err); |
1105 User::Leave(err); |
1093 } |
1106 } |
1094 } |
1107 } |
1095 |
1108 |
|
1109 // Filtering of rsc files from the set of files to be copied and using parser to |
|
1110 // extract app uid,foldername,filename and iconfilename |
|
1111 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
1112 if(IsInInfoCollectionMode()) |
|
1113 { |
|
1114 _LIT(KApparcRegDir, "\\private\\10003a3f\\import\\apps\\"); |
|
1115 _LIT(KApparcRegistrationFileExtn,".rsc"); |
|
1116 |
|
1117 //Getting the list of files to be added from CApplication Object |
|
1118 RPointerArray<CSisRegistryFileDescription> listOfFilesToBeAdded = application->FilesToAdd(); |
|
1119 //Stores the registration resource files which are passed to the apparc parser |
|
1120 RPointerArray<TDesC> regFilesArray; |
|
1121 CleanupResetAndDestroyPushL(regFilesArray); |
|
1122 RPointerArray<CSisRegistryFileDescription> listOfFilesToBeExtracted; |
|
1123 CleanupClosePushL(listOfFilesToBeExtracted); |
|
1124 RFs fs; |
|
1125 RArray<TChar> drives; // Array of system drives |
|
1126 RArray<TInt64> driveSpaces; // Space available on each drive |
|
1127 CleanupClosePushL(drives); |
|
1128 CleanupClosePushL(driveSpaces); |
|
1129 TInt64 currentAvailableDriveSpace = 0 ; |
|
1130 TInt64 totalApplicationDataSize = 0; |
|
1131 CSisRegistryFileDescription* currentFileDescription = NULL; |
|
1132 |
|
1133 //Obtain the disk space available on the drives |
|
1134 iSisHelper.FillDrivesAndSpacesL(drives, driveSpaces); |
|
1135 TChar systemDrive = RFs::GetSystemDriveChar(); |
|
1136 TInt driveIndex = drives.Find(systemDrive); |
|
1137 currentAvailableDriveSpace = driveSpaces[driveIndex]; //first drive is 'C' drive only |
|
1138 |
|
1139 //Opening a file server session |
|
1140 User::LeaveIfError(fs.Connect()); |
|
1141 CleanupClosePushL(fs); |
|
1142 User::LeaveIfError(fs.ShareProtected()); |
|
1143 |
|
1144 TInt noOfFilesToBeAdded = listOfFilesToBeAdded.Count(); |
|
1145 // Processing each file and checking if a file is an resource file(*_reg.rsc or *.rsc or *.r%d) |
|
1146 for(TInt i=0 ; i < noOfFilesToBeAdded ; i++) |
|
1147 { |
|
1148 HBufC* targetFileName; |
|
1149 targetFileName = listOfFilesToBeAdded[i]->Target().Alloc(); |
|
1150 CleanupStack::PushL(targetFileName); |
|
1151 TParsePtrC filename(*targetFileName); |
|
1152 TBool isApparcFile = EFalse; |
|
1153 HBufC* extension = TParsePtrC(*targetFileName).Ext().AllocLC(); |
|
1154 |
|
1155 if(!extension->Compare(KApparcRegistrationFileExtn)) // for resource files *_reg.rsc or *.rsc |
|
1156 { |
|
1157 isApparcFile = ETrue; |
|
1158 } |
|
1159 else |
|
1160 { |
|
1161 TInt extnLength = extension->Length(); |
|
1162 HBufC* extn; |
|
1163 if(extnLength == 4) //for localizable resource files with extn like .r01 |
|
1164 { |
|
1165 extn = extension->Right(2).AllocLC(); |
|
1166 } |
|
1167 else if(extnLength == 5) |
|
1168 { |
|
1169 extn = extension->Right(3).AllocLC(); //for localizable resource files with extn like .r101 |
|
1170 } |
|
1171 else |
|
1172 { |
|
1173 CleanupStack::PopAndDestroy(2, targetFileName); //extension |
|
1174 continue; |
|
1175 } |
|
1176 |
|
1177 //Check to find if the extension is of valid localizable resource files |
|
1178 TInt value = 0; |
|
1179 // Declare the variable |
|
1180 TLex lex(*extn); |
|
1181 // Convert the descriptor into the integer number |
|
1182 TInt err = lex.Val(value); |
|
1183 if(err == KErrNone) |
|
1184 { |
|
1185 isApparcFile = ETrue; |
|
1186 } |
|
1187 CleanupStack::PopAndDestroy(extn); |
|
1188 } |
|
1189 |
|
1190 //If its an apparc file(rsc) file then add its size to the total application size |
|
1191 if(isApparcFile) |
|
1192 { |
|
1193 listOfFilesToBeExtracted.AppendL(listOfFilesToBeAdded[i]); |
|
1194 totalApplicationDataSize += listOfFilesToBeAdded[i]->UncompressedLength(); |
|
1195 } |
|
1196 CleanupStack::PopAndDestroy(2, targetFileName); //extension |
|
1197 } |
|
1198 |
|
1199 //Here we do extraction of rsc files ,before extracting files we check if there is an enough space on the disk(C drive) |
|
1200 //to extract the files then extract the file to a temporary location and |
|
1201 //check if it is a registration resource file(using target path) then store it into an array. |
|
1202 TInt noOfFilesToBeExtracted = listOfFilesToBeExtracted.Count(); |
|
1203 DEBUG_PRINTF2(_L("Total number resource files (registration/localizable)to be extracted is %d"), noOfFilesToBeExtracted); |
|
1204 if(0 != noOfFilesToBeExtracted) |
|
1205 { |
|
1206 |
|
1207 //Check if there is enough space to extract the resource (registration or localizable) files |
|
1208 if(totalApplicationDataSize > currentAvailableDriveSpace) |
|
1209 { |
|
1210 //No memory to extract the file |
|
1211 User::LeaveIfError(KErrDiskFull); |
|
1212 } |
|
1213 |
|
1214 //Extraction of rsc file to a temporary location and if it is a reg resource filr append t to an array for parsing |
|
1215 for (TInt i = 0 ; i < noOfFilesToBeExtracted ; i++) |
|
1216 { |
|
1217 TFileName resourceFileName; |
|
1218 _LIT(KResourceFileNameFmt, "%c:\\resource\\install\\temp\\0x%08x\\%S"); // Pakage Uid |
|
1219 TFileName finalToBeExtracted = TParsePtrC(listOfFilesToBeExtracted[i]->Target()).NameAndExt(); |
|
1220 resourceFileName.Format(KResourceFileNameFmt, TUint(systemDrive), aController.Info().Uid().Uid().iUid, |
|
1221 &finalToBeExtracted); |
|
1222 |
|
1223 TInt err = fs.MkDirAll(resourceFileName); |
|
1224 if (err!= KErrNone && err != KErrAlreadyExists) |
|
1225 User::LeaveIfError(err); |
|
1226 |
|
1227 RFile resourceFile; |
|
1228 User::LeaveIfError(resourceFile.Replace(fs, resourceFileName, |
|
1229 EFileStream|EFileWrite|EFileRead|EFileShareExclusive)); |
|
1230 CleanupClosePushL(resourceFile); |
|
1231 |
|
1232 // Extract resource file to a temporary file. |
|
1233 DEBUG_PRINTF2(_L("Current resource file (registration/localizable) to be extraced is %S"), &resourceFileName); |
|
1234 User::LeaveIfError(iSisHelper.ExtractFileL(fs, resourceFile, |
|
1235 listOfFilesToBeExtracted[i]->Index(), application->AbsoluteDataIndex(), UiHandler())); |
|
1236 |
|
1237 CleanupStack::PopAndDestroy(&resourceFile); |
|
1238 |
|
1239 // If target of the file is apparc's private folder then it is registration resource file for an app |
|
1240 TParsePtrC filename(listOfFilesToBeExtracted[i]->Target()); |
|
1241 if (filename.Path().Left(KApparcRegDir().Length()).CompareF(KApparcRegDir) == 0) |
|
1242 { |
|
1243 HBufC* regResourceFileName = resourceFileName.AllocL(); |
|
1244 |
|
1245 regFilesArray.AppendL(regResourceFileName); |
|
1246 } |
|
1247 } |
|
1248 //Since the files have been extracted the available disk space is reduced |
|
1249 currentAvailableDriveSpace -= totalApplicationDataSize; |
|
1250 } |
|
1251 |
|
1252 DEBUG_PRINTF(_L8("Finished extracting all resource files (registration/localizable) successfuly")); |
|
1253 //Pass each registration resource file to the parser to fetch the app info and then if icon file is present fetch the icon file |
|
1254 //to a temporary location. |
|
1255 |
|
1256 TInt noOfRegFilesToBeParsed = regFilesArray.Count(); |
|
1257 DEBUG_PRINTF2(_L("Total number Registration Resource files to be parsed is %d"), noOfRegFilesToBeParsed); |
|
1258 for(TInt i = 0 ; i < noOfRegFilesToBeParsed ; i++) |
|
1259 { |
|
1260 Usif::CApplicationRegistrationData *appData = NULL; |
|
1261 CNativeComponentInfo::CNativeApplicationInfo* applicationInfo = NULL; |
|
1262 RArray<TLanguage> languages; |
|
1263 TFileName iconFile; |
|
1264 // Calling the apparc parser to fetch the app info from the resouce files |
|
1265 |
|
1266 DEBUG_PRINTF2(_L("Current Registration Resource file to be parsed is %S"), regFilesArray[i]); |
|
1267 |
|
1268 // Ask the launcher to parse the registration resource file |
|
1269 RSisLauncherSession launcher; |
|
1270 CleanupClosePushL(launcher); |
|
1271 User::LeaveIfError(launcher.Connect()); |
|
1272 RFile file; |
|
1273 User::LeaveIfError(file.Open(fs, *regFilesArray[i], EFileRead)); |
|
1274 RArray<TLanguage> appLanguages; |
|
1275 CleanupClosePushL(appLanguages); |
|
1276 TRAPD(err,appData=launcher.SyncParseResourceFileL(file, appLanguages)); |
|
1277 CleanupStack::PopAndDestroy(&appLanguages); |
|
1278 file.Close(); |
|
1279 CleanupStack::PopAndDestroy(&launcher); // popping and destroying as it is not reqd further. |
|
1280 |
|
1281 DEBUG_PRINTF2(_L("Finished Parsing Registration Resource file %S successfuly"), regFilesArray[i]); |
|
1282 if(KErrCorrupt == err) |
|
1283 { |
|
1284 continue; |
|
1285 } |
|
1286 else if(KErrNone != err) |
|
1287 { |
|
1288 User::Leave(err); |
|
1289 } |
|
1290 |
|
1291 CleanupStack::PushL(appData); |
|
1292 TUid appuid = appData->AppUid(); |
|
1293 HBufC* finalAppName = TParsePtrC(appData->AppFile()).NameAndExt().AllocLC(); |
|
1294 const RPointerArray<Usif::CLocalizableAppInfo> aLocalizableAppInfoList = appData->LocalizableAppInfoList(); |
|
1295 HBufC* groupName = NULL; |
|
1296 HBufC* iconFileName = NULL; |
|
1297 TInt fileSize = 0 ; |
|
1298 |
|
1299 //If localizable info for an app is present get the localized group name, else get it from app registration data |
|
1300 if(0 == aLocalizableAppInfoList.Count()) |
|
1301 { |
|
1302 if(appData->GroupName().Length()) |
|
1303 { |
|
1304 groupName = appData->GroupName().AllocLC(); |
|
1305 DEBUG_PRINTF2(_L("Application Group Name %S"), groupName); |
|
1306 } |
|
1307 //Since locale does not exists no need to extract, create CNativeApplicationInfo without iconFileName |
|
1308 applicationInfo = Swi::CNativeComponentInfo::CNativeApplicationInfo::NewLC(appuid, *finalAppName, groupName?*groupName:_L(""), _L("")); |
|
1309 } |
|
1310 else |
|
1311 { |
|
1312 Usif::CLocalizableAppInfo* localizedInfo = NULL; |
|
1313 const Usif::CCaptionAndIconInfo* captionAndIconInfo = NULL; |
|
1314 localizedInfo = aLocalizableAppInfoList[0]; |
|
1315 if(localizedInfo->GroupName().Length()) |
|
1316 { |
|
1317 groupName = localizedInfo->GroupName().AllocLC(); |
|
1318 } |
|
1319 captionAndIconInfo = localizedInfo->CaptionAndIconInfo(); |
|
1320 //Check if caption and icon info for an app is present or not, if present extract the icon file. |
|
1321 if(captionAndIconInfo) |
|
1322 { |
|
1323 if(captionAndIconInfo->IconFileName().Length()) |
|
1324 iconFileName = captionAndIconInfo->IconFileName().AllocLC(); |
|
1325 |
|
1326 if(iconFileName != NULL) |
|
1327 { |
|
1328 HBufC* finalIconFileName = TParsePtrC(*iconFileName).NameAndExt().AllocLC(); |
|
1329 |
|
1330 _LIT(KIconFileNameFmt, "%c:\\resource\\install\\icon\\0x%08x\\%S"); // Applicaiton Uid |
|
1331 iconFile.Format(KIconFileNameFmt, TUint(systemDrive), appuid.iUid, |
|
1332 finalIconFileName); |
|
1333 |
|
1334 TInt err = fs.MkDirAll(iconFile); |
|
1335 if (err!= KErrNone && err != KErrAlreadyExists) |
|
1336 User::LeaveIfError(err); |
|
1337 |
|
1338 //Find from the list of files to be copied , the file description of the icon file returned by the parser |
|
1339 for(TInt k = 0; k < listOfFilesToBeAdded.Count() ; k++) |
|
1340 { |
|
1341 currentFileDescription = listOfFilesToBeAdded[k]; |
|
1342 if(TParsePtrC(currentFileDescription->Target()).NameAndExt().Compare(*finalIconFileName)) |
|
1343 { |
|
1344 break; |
|
1345 } |
|
1346 } |
|
1347 //Check if there is enough space to extract the icon file |
|
1348 fileSize = currentFileDescription->UncompressedLength(); |
|
1349 if(currentAvailableDriveSpace < fileSize) |
|
1350 { |
|
1351 //No memory to extract the file |
|
1352 User::LeaveIfError(KErrDiskFull); |
|
1353 } |
|
1354 |
|
1355 //Extracting the icon file to a temp location |
|
1356 RFile tempIconFile; |
|
1357 TInt index = 1; |
|
1358 TBuf<10> integerAppendStr; |
|
1359 // Check if file already exists, if yes then create file with another name (e.g. *_1 or *_2) |
|
1360 while(1) |
|
1361 { |
|
1362 err = tempIconFile.Create(fs, iconFile, EFileStream|EFileWrite|EFileRead|EFileShareExclusive); |
|
1363 if(err == KErrAlreadyExists) |
|
1364 { |
|
1365 integerAppendStr.TrimAll(); |
|
1366 integerAppendStr.Format(_L("%d"), index++); |
|
1367 TInt pos = iconFile.Length()-TParsePtrC(iconFile).Ext().Length(); |
|
1368 iconFile.Insert(pos,integerAppendStr); |
|
1369 } |
|
1370 else if(err == KErrNone) |
|
1371 { |
|
1372 //Everthing is fine, proceed |
|
1373 break; |
|
1374 } |
|
1375 else |
|
1376 { |
|
1377 tempIconFile.Close(); |
|
1378 User::Leave(err); |
|
1379 } |
|
1380 } |
|
1381 CleanupClosePushL(tempIconFile); |
|
1382 |
|
1383 DEBUG_PRINTF2(_L("Icon file to be extraced is %S"), &iconFile); |
|
1384 User::LeaveIfError(iSisHelper.ExtractFileL(fs, tempIconFile, listOfFilesToBeAdded[i]->Index(), application->AbsoluteDataIndex(), UiHandler())); |
|
1385 DEBUG_PRINTF(_L8("Finished extracting Icon file successfuly")); |
|
1386 //After copy the available disk space is reduced |
|
1387 currentAvailableDriveSpace -= fileSize; |
|
1388 CleanupStack::PopAndDestroy(3,iconFileName); //file,finalIconFileName,iconFileSize |
|
1389 |
|
1390 //Create CNativeApplicationInfo with iconFileName |
|
1391 applicationInfo = Swi::CNativeComponentInfo::CNativeApplicationInfo::NewLC(appuid, *finalAppName, groupName?*groupName:_L(""), iconFile); |
|
1392 } |
|
1393 else |
|
1394 { |
|
1395 //Since iconFileName does not exists no need to extract, create CNativeApplicationInfo without iconName |
|
1396 applicationInfo = Swi::CNativeComponentInfo::CNativeApplicationInfo::NewLC(appuid, *finalAppName, groupName?*groupName:_L(""), _L("")); |
|
1397 } |
|
1398 } |
|
1399 } |
|
1400 |
|
1401 DEBUG_PRINTF2(_L("Application Uid 0x%08x"), appuid); |
|
1402 DEBUG_PRINTF2(_L("Application Name %S"), finalAppName); |
|
1403 if(groupName) |
|
1404 DEBUG_PRINTF2(_L("Application Group Name %S"), groupName); |
|
1405 if(iconFile.Length()) |
|
1406 DEBUG_PRINTF2(_L("Application Icon File Name %S"), &iconFile); |
|
1407 |
|
1408 const_cast <Sis::CController&>(aController).AddApplicationInfoL(applicationInfo); |
|
1409 CleanupStack::Pop(applicationInfo); |
|
1410 if(groupName) |
|
1411 CleanupStack::PopAndDestroy(3, appData); //groupName,finalAppName,appData |
|
1412 else |
|
1413 CleanupStack::PopAndDestroy(2, appData); //finalAppName,appData |
|
1414 languages.Close(); |
|
1415 } |
|
1416 |
|
1417 CleanupStack::PopAndDestroy(3,&drives); //fs,driveSpaces,drives |
|
1418 CleanupStack::Pop(&listOfFilesToBeExtracted); |
|
1419 listOfFilesToBeExtracted.Close(); |
|
1420 CleanupStack::PopAndDestroy(®FilesArray); |
|
1421 } |
|
1422 #endif |
|
1423 |
1096 //Append planned controllers list |
1424 //Append planned controllers list |
1097 iFilesFromPlannedControllers.AppendL(filesList); |
1425 iFilesFromPlannedControllers.AppendL(filesList); |
1098 CleanupStack::Pop(filesList); |
1426 CleanupStack::Pop(filesList); |
1099 |
1427 |
1100 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
1428 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
1101 // Some files may need to be questioned of overwrite only when the planner is not in info collection mode. |
1429 // Some files may need to be questioned of overwrite only when the planner is not in info collection mode. |
1102 if (!IsInInfoCollectionMode()) |
1430 if (!IsInInfoCollectionMode()) |
1103 #endif |
1431 #endif |
1104 //Some files may need to be questioned of overwrite |
1432 //Some files may need to be questioned of overwrite |
1105 WarnEclipseOverWriteL(*application); |
1433 WarnEclipseOverWriteL(*application); |
1106 |
1434 |
1107 // Reset the file list array for next controller use |
1435 // Reset the file list array for next controller use |
1108 iEclipsableOverwriteFiles.Reset(); |
1436 iEclipsableOverwriteFiles.Reset(); |
1109 |
1437 |