Esempio n. 1
0
/**
 * Identify if input file is a Registration Resource File.
 @ Param : aRegistrationFileName - File name to be scanned.
 */
TInt FindRegistrationResourceFileL(std::string& aRegistrationFileName)
{
	CResourceFile* registrationFile = NULL;
	try {
			registrationFile = new CResourceFile(aRegistrationFileName, 0, 0);
			if(NULL==registrationFile)
			{
				std::cout<<"Failed : Error in Reading File. Memory Allocation Failed"<<std::endl;
				return 1;
			}
			else
			{
				TUid iAppUid = registrationFile->ReadFileUidL();
				if(KUidAppRegistrationResourceFile == iAppUid.GetUid())
				{
					delete registrationFile;
					return 0;
				}
			}
		}
		catch(const CResourceFileException& aObject)
		{
			if(registrationFile)
				delete registrationFile;
			return 1;
		}
	
	delete registrationFile;
	return 1;
}
Esempio n. 2
0
/**
 * Generate XML for Class AppInfoReader and call the function to Update Installation Information in Database using SRCTOOL
 */
void ReadApplicationInformationFromResourceFilesL(XmlDetails::TScrPreProvisionDetail& aScrPreProvisionDetail, 
															const std::string& aFileName,const CParameterList* aParamList, 
															const CInterpretSIS& aInterpretSis, int& aNewFileFlag)
{

	std::string LocalizePath = GetLocalizeFilePath(aFileName, aParamList);
	
	CAppInfoReader* appInfoReader = NULL;
	appInfoReader = CAppInfoReader::NewL(aFileName, NullUid, LocalizePath);	
	if (!appInfoReader)
	{
		std::string errMsg= "Failed : Error in Reading File. Memory Allocation Failed";
		throw CResourceFileException(errMsg);
	}
	else
	{
		TBool readSuccessful=EFalse;

		readSuccessful= appInfoReader->ReadL();

		if (readSuccessful)
		{
			const SisRegistry* SisReg( aInterpretSis.GetSisRegistry());
			const DbHelper* dbHelper( SisReg->GetDbHelper());
				
			TUid aAppUid = appInfoReader->AppUid();
			int val = dbHelper->IsAppUidInstalled(aAppUid.GetUid());
			if(!val)
			{
				aNewFileFlag = 1;
				// for sis file entries the software type would always be Native.
				aScrPreProvisionDetail.iSoftwareTypeName = L"native";;
						
				XmlDetails::TScrPreProvisionDetail::TComponent component;
				CreateApplicationRegistrationInfoL(component,appInfoReader);
				aScrPreProvisionDetail.iComponents.push_back(component);
			}
			else
			{
				std::cout<<",Ignoring : AppUid "<<hex<<aAppUid.iUid<<" already present in SCR.";
			}
		}
		else
		{
			delete appInfoReader;
			std::string errMsg= "Reading Resource File failed.";
			throw CResourceFileException(errMsg);
		}
		delete appInfoReader;
	}

}
Esempio n. 3
0
/**
 * Creates Class TViewData for XML Parsing
 */
void CreateViewDataL(XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppLocalizableInfo& aLocalizableAttribute, 
							const CAppLocalizableInfo* aAppInfoReader)
{
	std::wstring sStr1;
	std::wstring sStr;

	std::vector<CAppViewData*>* viewDataArray = aAppInfoReader->GetViewDataArray();

	if(viewDataArray)
	{
		for(TInt i = 0; i<viewDataArray->size(); i++)
		{

			XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppLocalizableInfo::TViewData ViewData;
			CAppViewData *temp = viewDataArray->at(i);
	
			sStr = DbConstants::CompUID;
			TUid ID = temp->Uid();
			sStr1 = Utils::IntegerToWideString(ID.GetUid());
			CreateViewDataAttributes(ViewData,sStr,sStr1,true,false);
	
			sStr = DbConstants::CompScreenMode;
			TInt SMode = temp->GetScreenMode();
	
			sStr1 = Utils::IntegerToWideString(SMode);
			CreateViewDataAttributes(ViewData,sStr,sStr1,true,false);
			
			sStr = DbConstants::CompCaption;
			Ptr16* caption = temp->GetCaption();
			if(caption)
				sStr1 = Ptr16ToWstring(caption);
			else
				sStr1=L'\0';		
			CreateViewDataAttributes(ViewData,sStr,sStr1,false,false);
			
			sStr = DbConstants::CompNumberOfIcons;
			TInt IconNum = temp->GetNumOfViewIcons();
			sStr1 = Utils::IntegerToWideString(IconNum);
			CreateViewDataAttributes(ViewData,sStr,sStr1,true,false);
	
			sStr = DbConstants::CompIconFile;
			Ptr16* IconName = temp->GetIconFileName();
			if(IconName)
				sStr1 = Ptr16ToWstring(IconName);
			else
				sStr1=L'\0';
			CreateViewDataAttributes(ViewData,sStr,sStr1,false,false);

			aLocalizableAttribute.iViewData.push_back(ViewData);
		}
	}
}
Esempio n. 4
0
void CreateAppServiceInfo(XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo& aAppServiceInfo, 
									const TUid& aUid, const std::vector<TDataTypeWithPriority*>& aDataType) 
{
		XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppServiceInfo componentServiceInfo;

		componentServiceInfo.iUid = aUid.GetUid();
		for(TInt ii = 0; ii<aDataType.size(); ii++)
		{
			TDataTypeWithPriority *temp = aDataType.at(ii);
			CreateAppDataType(componentServiceInfo,temp);
		}
	
		aAppServiceInfo.iApplicationServiceInfo.push_back(componentServiceInfo);
}
// reads as much info as it can
// at least captions and icons must be setup on return from this method (using defaults if necessary)
TBool CAppInfoReader::ReadL()
{
	TUint fileOffset = 0;
	TInt fileLength = 0;
	TUid firstUid(KExecutableImageUidVal);
	TUid middleUid(KUidApp);
	TInt err;
	TInt LocalizeError = 0;
	TUid reguid;
	
	CResourceFile* registrationFile = new CResourceFile(iRegistrationFileName, fileOffset, fileLength);
	if(NULL==registrationFile)
	{
		std::string errMsg= "Failed : Error in Reading File. Memory Allocation Failed";
		throw CResourceFileException(errMsg);
	}

	if(registrationFile)
	{
		iAppUid = registrationFile->ReadAppUidL();
		if(!iAppUid.GetUid())
		{
			std::string errMsg= "Failed : Invalid Resource File. Null Application UID.";
			throw CResourceFileException(errMsg);
		}

		reguid = registrationFile->ReadFileUidL();
		if(reguid.GetUid()!= KUidAppRegistrationResourceFile)
		{
			std::string errMsg= "Failed : Invalid Resource File. UID2 is not defined.";
			throw CResourceFileException(errMsg);
		}
	}

	// set the TUidType for the app binary
	// cannot read the TEntry info from the app binary because it's in \sys\bin
	iAppBinaryUidType = TUidType(firstUid, middleUid, iAppUid);	
	
	RResourceReader	resourceReader;
	resourceReader.OpenL(registrationFile, KAppRegistrationInfoResourceId);	

	TUint localisableResourceId = 1; // only initialising this here to keep the compiler happy, as it's concerned that the variable might be used without having been initialised. The variable should be initialised later, before it's used

	try {
			ReadMandatoryInfoL(resourceReader);
		
			err = ReadNonLocalisableInfoL(resourceReader, localisableResourceId);

			if (!err)
			{	
				err = ReadNonLocalisableOptionalInfoL(resourceReader, registrationFile);
			}
		}
		catch(const CResourceFileException& aObject)
		{
		
			delete registrationFile;
			cout<< aObject.GetMsg()<< endl;
			return EFalse; // might have read something, but failed to setup enough info to make it worthwhile trying to read any more
		}
	
	TBool useDefaultIcons = ETrue;

	if(iLocalisableResourceFileName)
	{
		std::string localizeFileName = Ptr16ToString(iLocalisableResourceFileName);
		std::string folder;
		std::string file;
		size_t found;
		std::string iLocalPath(iDrivePath);

		#ifdef __LINUX__
	  	found=localizeFileName.find_last_of("//");
		#else
		found=localizeFileName.find_last_of("/\\");
		#endif

	  	if(found)
	  		folder = localizeFileName.substr(0,found);
	  	else
		{
			#ifdef __LINUX__
			folder.assign("/");	  		
			#else
			folder.assign("\\");
			#endif
		}
	  	
	  	file = localizeFileName.substr(found+1);
		file.append(".");
		
		iLocalPath.append(folder);
				
		std::wstring iFilePath = string2wstring(iLocalPath);
		std::wstring iFileName = string2wstring(file);

		#ifdef __LINUX__
		iLocalPath.append("/");
		#else
		iLocalPath.append("\\");
		#endif
		
		std::list<std::wstring> locDirs;
		GetDirContents( iFilePath, locDirs );

	 	std::list<std::wstring>::iterator curr = locDirs.begin();
		for( curr = locDirs.begin(); curr != locDirs.end(); ++curr )
		{
			if (curr->find(iFileName,0) != std::wstring::npos)
			{
			    std::string fName;
				std::string sAbsolutePath;
				sAbsolutePath.assign(iLocalPath);
			 	fName = wstring2string( *curr );

			   	sAbsolutePath.append(fName);
				//cout << sAbsolutePath<<endl;
				
				std::string Locale;
				int iLocale = 0;
		
				found=fName.rfind(".r");
				if(found!=string::npos)
					Locale = fName.substr(found+2);
				else
					continue;

				iLocale = atoi(Locale.c_str()); 
			    if(!iLocale)
					iLocale = KNonLocalized;
				   
				CResourceFile* tlocalisableFile = NULL;

				try {
					// open the localisable resource file	
					tlocalisableFile = new CResourceFile(sAbsolutePath, 0, 0);
					if(NULL==tlocalisableFile)
					{
						std::string errMsg= "Failed : Error in Reading File. Memory Allocation Failed";
						throw CResourceFileException(errMsg);
					}

					if (!err)
					{
						if (tlocalisableFile && (localisableResourceId & KResourceOffsetMask))
							tlocalisableFile->ConfirmSignatureL();

						err = ReadLocalisableInfoLoopL(*tlocalisableFile, localisableResourceId, useDefaultIcons, iLocale);
					}
					
					delete tlocalisableFile;
				}
				catch(const CResourceFileException& aObject)
				{
					LocalizeError = 1;
					aObject.Display();
					delete tlocalisableFile;
				}
			}
		}
	}

	// if anything went wrong, we tell the caller that the read was unsuccessful. Some
	// of the members of this class may contain data which is not complete, but this doesn't matter
	// because the caller shouldn't try to access the data if the read was unsuccessful
	TBool readSuccessful = 0;
	if(!LocalizeError)
		readSuccessful = (err == KErrNone);
	delete registrationFile;
	return readSuccessful;
}
TBool CAppInfoReader::ReadL(const std::vector<FileDescription*>& aFileDescription, std::string& aRomPath, int aInRom )
{
		TUint fileOffset = 0;
		TInt fileLength = 0;
		TUid firstUid(KExecutableImageUidVal);
		TUid middleUid(KUidApp);
		TInt err;
		TInt LocalizeError = 0;
		TUid reguid;
		CResourceFile* registrationFile = new CResourceFile(iRegistrationFileName, fileOffset, fileLength);
		if(NULL==registrationFile)
		{
			std::string errMsg= "Failed : Error in Reading File. Memory Allocation Failed";
			throw CResourceFileException(errMsg);
		}
	
		if(registrationFile)
		{
			iAppUid = registrationFile->ReadAppUidL();
			if(!iAppUid.GetUid())
			{
				std::string errMsg= "Failed : Invalid Resource File. Null Application UID.";
				throw CResourceFileException(errMsg);
			}

			reguid = registrationFile->ReadFileUidL();
			if(reguid.GetUid()!= KUidAppRegistrationResourceFile)
			{
				std::string errMsg= "Failed : Invalid Resource File. UID2 is not defined.";
				throw CResourceFileException(errMsg);
			}
		}
	
		// set the TUidType for the app binary
		// cannot read the TEntry info from the app binary because it's in \sys\bin
		iAppBinaryUidType = TUidType(firstUid, middleUid, iAppUid); 
		
		RResourceReader resourceReader;
		resourceReader.OpenL(registrationFile, KAppRegistrationInfoResourceId); 
	
		TUint localisableResourceId = 1; // only initialising this here to keep the compiler happy, as it's concerned that the variable might be used without having been initialised. The variable should be initialised later, before it's used
	
		try {
				ReadMandatoryInfoL(resourceReader);
			
				err = ReadNonLocalisableInfoL(resourceReader, localisableResourceId);
	
				if (!err)
				{	
					err = ReadNonLocalisableOptionalInfoL(resourceReader, registrationFile);
				}
			}
			catch(const CResourceFileException& aObject)
			{
			
				delete registrationFile;
				cout<< aObject.GetMsg()<< endl;
				return EFalse; // might have read something, but failed to setup enough info to make it worthwhile trying to read any more
			}
		
		TBool useDefaultIcons = ETrue;
	
		if(iLocalisableResourceFileName)
		{
			std::string localizeFileName = Ptr16ToString(iLocalisableResourceFileName);

			std::vector<FileDescription*>::const_iterator filedesIter;
			//std::wstring iFile;
			std::wstring iLocalizeFile;
			//std::string aFileName;
			std::string iLocalFilePath;

			std::string iLocalFileExt(".r");
			
			for(filedesIter = aFileDescription.begin() ; filedesIter != aFileDescription.end(); ++filedesIter)
			{
				iLocalizeFile = (*filedesIter)->GetLocalFile();
			
				iLocalFilePath = wstring2string(iLocalizeFile);

				if((iLocalFilePath.find(localizeFileName,0) == std::wstring::npos) 
						|| (iLocalFilePath.find(iLocalFileExt,0) == std::wstring::npos))
					continue;

				size_t found;
				std::string Locale;
				int iLocale = 0;
			
				found=iLocalFilePath.find_last_of(".");
				if(found)
					Locale = iLocalFilePath.substr(found+2);

				iLocale = atoi(Locale.c_str()); 
				if(!iLocale)
					iLocale = KNonLocalized;
			
				CResourceFile* tlocalisableFile = NULL;

				if(aInRom)
				{
					std::string LocalFile = FullNameWithoutDrive(iLocalFilePath);
					iLocalFilePath = aRomPath + LocalFile;
				}

				try {
					// open the localisable resource file	
					tlocalisableFile = new CResourceFile(iLocalFilePath, 0, 0);
					if(NULL==tlocalisableFile)
					{
						std::string errMsg= "Failed : Error in Reading File. Memory Allocation Failed";
						throw CResourceFileException(errMsg);
					}
	
					if (!err)
					{
						if (tlocalisableFile && (localisableResourceId & KResourceOffsetMask))
							tlocalisableFile->ConfirmSignatureL();

						err = ReadLocalisableInfoLoopL(*tlocalisableFile, localisableResourceId, useDefaultIcons, iLocale);
					}
						
					delete tlocalisableFile;
				}
				catch(const CResourceFileException& aObject)
				{
					LocalizeError = 1;
					aObject.Display();
					delete tlocalisableFile;
				}
			}
		}
	
	// if anything went wrong, we tell the caller that the read was unsuccessful. Some
	// of the members of this class may contain data which is not complete, but this doesn't matter
	// because the caller shouldn't try to access the data if the read was unsuccessful
	TBool readSuccessful = 0;
	if(!LocalizeError)
		readSuccessful = (err == KErrNone);
	delete registrationFile;
	return readSuccessful;
}
Esempio n. 7
0
void CreateApplicationRegistrationInfoL(XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, 
												const CAppInfoReader* aAppInfoReader)
{
	XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo iApplicationRegistrationInfo;

	Ptr16* iAppBinaryFullName = aAppInfoReader->AppBinaryFullName();
	std::wstring sAppAttributeName = DbConstants::CompAppFile;
	std::wstring sAppAttributeValue = Ptr16ToWstring(iAppBinaryFullName);
	CreateAppAttribute(iApplicationRegistrationInfo,sAppAttributeName,sAppAttributeValue,false,false);

	TUidType iAppBinaryUidType = aAppInfoReader->AppBinaryUidType();;
	sAppAttributeName = DbConstants::CompAppUid;
	TUid Uid = iAppBinaryUidType[2];
	sAppAttributeValue = Utils::IntegerToWideString(Uid.GetUid());
	CreateAppAttribute(iApplicationRegistrationInfo,sAppAttributeName,sAppAttributeValue,true,false);

	sAppAttributeName = DbConstants::CompTypeId;
	TInt TypeId = -1367772926;
	sAppAttributeValue = Utils::IntegerToWideString(TypeId);
	CreateAppAttribute(iApplicationRegistrationInfo,sAppAttributeName,sAppAttributeValue,true,false);

	TAppCapability iCapability;
	aAppInfoReader->Capability(iCapability);

 	sAppAttributeName = DbConstants::CompAttributes;
	sAppAttributeValue = Utils::IntegerToWideString(iCapability.iAttributes);
	CreateAppAttribute(iApplicationRegistrationInfo,sAppAttributeName,sAppAttributeValue,true,false);

	sAppAttributeName = DbConstants::CompHidden;
	sAppAttributeValue = Utils::IntegerToWideString(iCapability.iAppIsHidden);
	CreateAppAttribute(iApplicationRegistrationInfo,sAppAttributeName,sAppAttributeValue,true,false);

	sAppAttributeName = DbConstants::CompEmbeddable;
	sAppAttributeValue = Utils::IntegerToWideString(iCapability.iEmbeddability);
	CreateAppAttribute(iApplicationRegistrationInfo,sAppAttributeName,sAppAttributeValue,true,false);

	sAppAttributeName = DbConstants::CompNewfile;
	sAppAttributeValue = Utils::IntegerToWideString(iCapability.iSupportsNewFile);
	CreateAppAttribute(iApplicationRegistrationInfo,sAppAttributeName,sAppAttributeValue,true,false);

	sAppAttributeName = DbConstants::CompLaunch;
	sAppAttributeValue = Utils::IntegerToWideString(iCapability.iLaunchInBackground);
	CreateAppAttribute(iApplicationRegistrationInfo,sAppAttributeName,sAppAttributeValue,true,false);

	sAppAttributeName = DbConstants::CompGroupName;
	if(iCapability.iGroupName)
		sAppAttributeValue = Ptr16ToWstring(iCapability.iGroupName);
	else
		sAppAttributeValue=L'\0';
	CreateAppAttribute(iApplicationRegistrationInfo,sAppAttributeName,sAppAttributeValue,false,false);

	TUint iDefaultScreenNumber = aAppInfoReader->DefaultScreenNumber();
	sAppAttributeName = DbConstants::CompDefaultScreenNumber;
	sAppAttributeValue = Utils::IntegerToWideString(iDefaultScreenNumber);
	CreateAppAttribute(iApplicationRegistrationInfo,sAppAttributeName,sAppAttributeValue,true,false);

	std::vector<Ptr16*>* ownedFileArray = aAppInfoReader->OwnedFiles();
	std::wstring sFileName;
	if(ownedFileArray)
	{
		for(TInt ii = 0; ii<ownedFileArray->size(); ii++)
		{
			Ptr16 *temp = ownedFileArray->at(ii);
			if(temp)
				sFileName = Ptr16ToWstring(temp);
			else
				sFileName = L'\0';
			iApplicationRegistrationInfo.iFileOwnershipInfo.push_back(sFileName);
		}
	}

	std::string sOpaqueData;
	TInt iIndexOfFirstOpenService;
	std::vector<TAppServiceInfo*>* iServiceArray = aAppInfoReader->ServiceArray(iIndexOfFirstOpenService);
	if(iServiceArray)
	{
		for(TInt i = 0; i<iServiceArray->size(); i++)
		{
			TAppServiceInfo* temp = iServiceArray->at(i);
			TUid iUid = temp->GetUid();
			std::vector<TDataTypeWithPriority*> iData = temp->GetDataType();
			CreateAppServiceInfo(iApplicationRegistrationInfo,iUid,iData);

			int servUid = iUid.GetUid();
			std::vector<CAppLocalOpaqueDataInfo*> opaqueDataArray = aAppInfoReader->GetOpaqueDataArray();
			for(TInt i = 0; i<opaqueDataArray.size(); i++)
			{
				CAppLocalOpaqueDataInfo* tp = opaqueDataArray.at(i);
			
				TUint32 serviceUid = tp->GetServiceUid();
				if(servUid == serviceUid)
				{
					Ptr8*	opaqueData = tp->GetOpaqueData();

					if(opaqueData)
						sOpaqueData.assign(opaqueData->GetPtr(), opaqueData->GetPtr()+opaqueData->GetLength());
					else
						sOpaqueData = '\0';
					TInt locale = tp->GetLocale();
					CreateOpaqueDataType(iApplicationRegistrationInfo,sOpaqueData,locale,serviceUid);
				}
			}
		}
	}

	std::vector<CAppLocalizableInfo*> aAppLocalizable = aAppInfoReader->LocalizableInfo();

	for(TInt i = 0; i<aAppLocalizable.size(); i++)
	{
		CAppLocalizableInfo* tp = aAppLocalizable.at(i);
		CreateLocalizableInfoL(iApplicationRegistrationInfo,tp);
	}

	std::vector<CAppLocalOpaqueDataInfo*> opaqueDataArray = aAppInfoReader->GetOpaqueDataArray();
	for(TInt i = 0; i<opaqueDataArray.size(); i++)
	{
		CAppLocalOpaqueDataInfo* tp = opaqueDataArray.at(i);

		TUint32 serviceUid = tp->GetServiceUid();
		if(0 == serviceUid)
		{
			Ptr8* 	opaqueData = tp->GetOpaqueData();

			if(opaqueData)
				sOpaqueData.assign(opaqueData->GetPtr(), opaqueData->GetPtr()+opaqueData->GetLength());
			else
				sOpaqueData='\0';
			
			TInt locale = tp->GetLocale();
			CreateOpaqueDataType(iApplicationRegistrationInfo,sOpaqueData,locale,serviceUid);
		}
	}

	aComponent.iApplicationRegistrationInfo.push_back(iApplicationRegistrationInfo);
}