Exemplo n.º 1
0
void CPolicyStore::ConstructPolicyListL()
    {
    // Using two policy lists (one for all and one for the visible
    // ones) makes it easy to support the concept of hidden and
    // visible policies. There's a slight memory penalty but this
    // is not serious as the number of policies is typically small).
    // Hidden policies differ from visible ones in only one aspect - 
    // they are not included in the policy listing returned to
    // the caller.
    
    // A list of all policies (both visible and hidden)
    iPolicyListAll = new (ELeave) CArrayFixFlat<TVpnPolicyInfo>(2);
    // A list of visible policies only
    iPolicyListVisible = new (ELeave) CArrayFixFlat<TVpnPolicyInfo>(2);

    TFindFile fileFinder(iFs);
    CDir* fileList; 

    TPath privateDir;
    User::LeaveIfError(iFs.PrivatePath(privateDir));
    TInt ret = fileFinder.FindWildByDir(KPolFilePat, privateDir, fileList);
    if (ret == KErrNone)
        {
        CleanupStack::PushL(fileList);
        
        for (TInt i = 0; i < fileList->Count(); i++)
            {
            TParse fileNameParser;
            fileNameParser.Set((*fileList)[i].iName, &fileFinder.File(), NULL);

            TVpnPolicyId policyId;
            
            // Only add the policy to the list its ID length is
            // acceptable (this is the case with all policies
            // that have been properly imported to the store)
            if (fileNameParser.Name().Length() <= policyId.MaxLength())
                {
                policyId.Copy(fileNameParser.Name());

                HBufC* pinFile = iFileUtil.GetPinFileNameLC(policyId);

                if (iFileUtil.FileExists(*pinFile))
                    {
                    AddPolicyL(policyId);
                    }
                CleanupStack::PopAndDestroy(pinFile);
                }
            }
        
        CleanupStack::PopAndDestroy(); // fileList
        }
    }
Exemplo n.º 2
0
LOCAL_C void MainL()
/**
 * Main implementation
 */
	{
	CActiveScheduler* sched=NULL;
	sched=new(ELeave) CActiveScheduler;
	CActiveScheduler::Install(sched);
	CTeIpUpsSuite* server = NULL;
		
	CCommandLineArguments* args = CCommandLineArguments::NewLC();
	TPtrC exeName = args->Arg(0);
	TParse fullName;
	fullName.Set(exeName, NULL, NULL);
	CleanupStack::PopAndDestroy(args);
	
	// Create the CTestServer derived server
	TRAPD(err,server = CTeIpUpsSuite::NewL(fullName.Name()));
	if(!err)
		{
		// Sync with the client and enter the active scheduler
		RProcess::Rendezvous(KErrNone);
		sched->Start();
		}
	delete server;
	delete sched;
	}
Exemplo n.º 3
0
void CPolicyImporter::BuildPolicyIdListL()
    {
    delete iPolicyIdList;
    iPolicyIdList = NULL;
    iPolicyIdList = new (ELeave) CArrayFixFlat<TExtVpnPolicyId>(2);

    TFindFile* fileFinder = new (ELeave) TFindFile(iFs);
    CleanupStack::PushL(fileFinder);

    CDir* fileList;

    TInt ret = fileFinder->FindWildByDir(KPinFilePat, iImportDir, fileList);

    if (ret == KErrNone)
        {
        CleanupStack::PushL(fileList);

        for (TInt i = 0; i < fileList->Count(); i++)
            {
            TParse* fileNameParser = new (ELeave) TParse();
            CleanupStack::PushL(fileNameParser);

            fileNameParser->Set((*fileList)[i].iName, NULL, NULL);

            TExtVpnPolicyId policyId;
            policyId.Copy(fileNameParser->Name());

            iPolicyIdList->AppendL(policyId);

            CleanupStack::PopAndDestroy(); // fileNameParser
            }
        CleanupStack::PopAndDestroy(); // fileList
        }
    CleanupStack::PopAndDestroy(); // fileFinder
    }
void CCustomCommandAsync::GetFileName(TPtrC path, TFileName* fileName)
{

	TParse p;
	p.Set(path,NULL,NULL);
	fileName->Append(p.DriveAndPath());
	fileName->Append(p.Name());

	fileName->Append(p.Ext());
}
Exemplo n.º 5
0
RApaApplication* CApaProcess::FindAppInListL(const TDesC& aAppFileName, TUid aUid) const
// returns pointer to a matching app, or NULL if not in list
//
	{
	__ASSERT_DEBUG(iAppList, Panic(EPanicNullPointer));

	TInt index = iAppList->Count();
	if (aUid!=KNullUid)
		{// search by UID
		while(--index >= 0)
			{
			__ASSERT_DEBUG((*iAppList)[index], Panic(EDPanicNoAppHolder));
			if ((*iAppList)[index]->AppFileUid() == aUid)
				{
				(*iAppList)[index]->ScheduleForAsyncDeletion(EFalse);
				return (*iAppList)[index]; // match found
				}
			}
		}
	else
		{// search by name as no UID has been supplied
		TParse app; 
		TParse suspect;
		User::LeaveIfError(app.Set(aAppFileName,NULL,NULL));
		while (--index>=0)
			{
			__ASSERT_DEBUG((*iAppList)[index], Panic(EDPanicNoAppHolder));
			suspect.SetNoWild((*iAppList)[index]->AppFileName(), NULL, NULL);
			if (!app.Name().CompareF(suspect.Name()))
				{
				(*iAppList)[index]->ScheduleForAsyncDeletion(EFalse);
				return (*iAppList)[index]; // match found
				}
			}
		}
		
	return NULL; // no match found
	}
Exemplo n.º 6
0
CNifFactory* MPppRecvr::FindPppFactoryL(const TDesC& aFilename, TUid aUid2, CObjectCon& aCon)
//
// Basically this is all the stuff required to load a DLL appart from the
// Factory->CreatMe call
//
	{
	CNifFactory* Factory=NULL;
	TParse parse;
	User::LeaveIfError(parse.Set(aFilename, 0, 0));

	TName dummy1;
	TInt find=0;

	if(aCon.FindByName(find, parse.Name(), dummy1)!=KErrNone)
		{

	    // Else load the module
		TAutoClose<RLibrary> lib;
		User::LeaveIfError(lib.iObj.Load(aFilename));
		lib.PushL();

		// The Uid check
		if(lib.iObj.Type()[1]!=aUid2)
			User::Leave(KErrBadLibraryEntryPoint);

		TPppFactoryNewL libEntry=(TPppFactoryNewL)lib.iObj.Lookup(1);
		if (libEntry==NULL)
			User::Leave(KErrNoMemory);

		Factory =(*libEntry)(); // Opens CObject
		if (!Factory)
			User::Leave(KErrBadDriver);

		CleanupStack::PushL(TCleanupItem(CNifFactory::Cleanup, Factory));
		Factory->InitL(lib.iObj, aCon); // Transfers the library object if successful

		// Can pop the library now - auto close will have no effect because handle is null
		CleanupStack::Pop();
		lib.Pop();

		}
	else
		{
		Factory=(CNifFactory*)aCon.At(find);
		Factory->Open();
		}
		return Factory;
	}
Exemplo n.º 7
0
void CMsvSendExe::FLog(const TDesC& aFileName, TRefByValue<const TDesC16> aFmt, ...)
	{
	VA_LIST list;
	VA_START(list, aFmt);

	TParse parse;
	parse.Set(aFileName, NULL, NULL);

	TBuf<256> buf;
	buf.Append(parse.Name());
	buf.Append(_L(": "));
	buf.AppendFormatList(aFmt, list);

	RFileLogger::Write(KSchSendLogDir, KSchSendExeLogFile, KSchSendExeLoggingMode,
				buf);
	}
// ---------------------------------------------------------
// CPhoneStateHandle::LoadLibraryHandleL
// ---------------------------------------------------------
void CPhoneStateHandle::LoadLibraryHandleL( 
    const TDesC& aFileName,
    const TUid aFactoryUid )
    {

    TBool factoryFound = EFalse;
    TParse fullentry;
    fullentry.Set( aFileName, NULL, NULL );

    if ( iFactoryLibrary.Load( fullentry.Name(), fullentry.DriveAndPath() ) 
        == KErrNone )
        {
        if ( iFactoryLibrary.Type()[1] == aFactoryUid )
            {
            factoryFound = ETrue;
            }
        else
            {
            iFactoryLibrary.Close();
            }
        }

    // If Factory not found:
    if ( !factoryFound )
        {
        Panic( EPhoneCtrlFactoryLibraryNotFound );
        }
    // Look for the 1st exported function
    iEntry = iFactoryLibrary.Lookup( KPhoneUiStateMachineOrdinal ); 

    // Create the state machine factory
    iStateMachineFactory = (CPhoneUIStateMachineFactoryBase*) iEntry();

    // Create the state machine
    iPhoneStateMachine = iStateMachineFactory->CreatePhoneStateMachineL(
        iViewCommandHandle );

    // Create the phone resource resolver
    iPhoneResourceResolver = 
        iStateMachineFactory->CreatePhoneResourceResolverL();
    
    // Create the phone error messages handler    
    iPhoneErrorMessagesHandler = 
        iStateMachineFactory->CreatePhoneErrorMessagesHandlerL( 
                            iViewCommandHandle, iPhoneStateMachine );
    }
	// class CIconFileHandle : public CBase, public MContextBase, 	
void FigureOutRealPathL(const TDesC& aFullPath, TDes& aRealPath, RFs& aFs) 
	{
		CALLSTACKITEMSTATIC_N(_CL("JuikIcons"), _CL("FigureOutRealPathL"));

		if ( aFullPath == AknIconUtils::AvkonIconFileName() )
			{
				aRealPath.Copy( aFullPath );
				return;
			}
#ifdef __S60V3__
		// Change path to c:\\resource 
		TParse p; p.Set( aFullPath, 0, 0);
		aRealPath=_L("c:\\resource\\");
		aRealPath.Append(p.NameAndExt());
#else
		// Just use given path
		aRealPath=aFullPath;
#endif
		
#ifdef __WINS__
		// in WINS, read always from Z 
		aRealPath.Replace(0, 1, _L("z"));
#else
		// In device, if file doesn't exist, read from E
		TBool try_mif=EFalse;
		if (p.Ext().CompareF(_L(".mbm"))==0) try_mif=ETrue;
again:
		if (! BaflUtils::FileExists(aFs, aRealPath)) {
			aRealPath.Replace(0, 1, _L("e"));
			if (! BaflUtils::FileExists(aFs, aRealPath)) {
				if (try_mif) {
					aRealPath=_L("c:\\resource\\");
					aRealPath.Append(p.Name());
					aRealPath.Append(_L(".mif"));
					try_mif=EFalse;
					goto again;
				}
				User::Leave(KErrNotFound);
			}
		}
#endif
	}
Exemplo n.º 10
0
/**
@internalComponent
*/
TInt CTestVirusHook::VsReadFileSection(TFsPluginRequest& aRequest)
	{

	// The t_virus test uses a filename clean.txt, a read length of 8 and a read position of 0.
	TFileName fileName;
	TInt len;
	TInt pos;

	// test getting name on read file section intercept
	TInt err = GetName(&aRequest, fileName);
	if(err != KErrNone)
		{
		return(err);
		}
	TParse parse;
	parse.Set(fileName,NULL,NULL);
	TPtrC name = parse.Name();
	if(name.CompareF(_L("clean"))!=0)
		{
		return(KErrGeneral);
		}
	TPtrC ext = parse.Ext();
	if(ext.CompareF(_L(".txt"))!=0)
		{
		return(KErrGeneral);
		}

	// test getting read length and required file position on read file section intercept
	err = GetFileAccessInfo(&aRequest, len, pos);
	if(err != KErrNone)
		{
		return(err);
		}
	if ((len != 8) || (pos != 0))
		{
		return(KErrGeneral);
		}
	
	return KErrNone;
	}
Exemplo n.º 11
0
void CResourceManager::CleanCachedPage(nid aPageId)
{
    int len = GetCachePath().Length();
    HBufC* cache = HBufC::New(len + 64);
    TPtr p = cache->Des();
    TPtr path = GetCachePath();
    p.Format(KCachePathFormat, &path, aPageId);
    
    _LIT(KWildName, "*.*");
    RFs& fs = CCoeEnv::Static()->FsSession();
    TFindFile file_finder(fs);
    CDir* file_list;
    TInt err = file_finder.FindWildByDir(KWildName, p, file_list);
    while (err == KErrNone) {
        for (TInt i = 0; i < file_list->Count(); i++) {
            if ((*file_list)[i].IsDir())
                continue;

            TParse fullentry;
            fullentry.Set((*file_list)[i].iName, &file_finder.File(), NULL);
            if (fullentry.ExtPresent()) {
                err = fs.Delete(fullentry.FullName());
            }
            else {
                TFileName filename;
                filename.Append(fullentry.DriveAndPath());
                filename.Append(fullentry.Name());
                err = fs.Delete(filename);
            }
        }
        delete file_list;
        err = file_finder.FindWild(file_list);
    }

    err = fs.RmDir(p);
    delete cache;
}
Exemplo n.º 12
0
/**
Protected constructor.

Extracts the initialisation data provided by the calling functions: ConstructSourceL() and 
ConstructSinkL(). Creates a file server session and sets up file name. If there is a file name and 
it cannot be found this function leaves. If there is no file name the function leaves. Does not 
attempt to open the file or check whether the file exists.

If aInitData contains a TMMFFileHandleParams instead of TMMFFileParams, the source/sink is constructed from 
the file handle provided by the caller

@param  aInitData
Initialisation data packaged in a TMMFFileParams or in a TMMFFileHandleParams (File Handle)
*/
void CFileMultimediaSource::ConstructL(const TDesC8& aInitData,TMMFileMode aFileMode)
    {
    User::LeaveIfError(iFsSession.Connect());
    // on IPCv2 we auto attach
    User::LeaveIfError(iFsSession.ShareAuto());
    
    User::LeaveIfError(iFsSession.ShareProtected());
    
    TBool fileInit = EFalse;
    HBufC* filename = NULL; 
    TBool filenamePushed = EFalse;
    
    iCAFParameters = new (ELeave) CCAFParameters;
    TBool drmContent = EFalse;
    RDesReadStream stream(aInitData);
    CleanupClosePushL(stream);

    TUid initUid;
    
    initUid = TUid::Uid(stream.ReadInt32L());
    
    if (initUid == KMMFileHandleSourceUid)
        {
        TPckgBuf<RFile*> fileptr;
        stream.ReadL(fileptr);
        
        iHandle.Duplicate(*fileptr());
        
        TInt length;
        length = stream.ReadInt32L();
        if (length>0)
            {
            iCAFParameters->iUniqueId = HBufC::NewL(length);
            TPtr16 ptr = iCAFParameters->iUniqueId->Des();
            stream.ReadL(ptr, length);
            }
        iFileHandle = ETrue;
        filename = HBufC::NewMaxL(KMaxFileName);
        TPtr ptr = filename->Des();
        iHandle.Name(ptr);
        fileInit = ETrue;
        drmContent = ETrue;
        
        iCAFParameters->iEnableUI = stream.ReadInt32L();
        }
    
    else if (initUid == KMMFileSourceUid)
        {
        TInt length;
        length = stream.ReadInt32L();
        filename = HBufC::NewMaxLC(length);
        TPtr ptr = filename->Des();
        stream.ReadL(ptr, length);
        
        length = stream.ReadInt32L();
        if (length>0)
            {
            iCAFParameters->iUniqueId = HBufC::NewMaxL(length);
            ptr.Set(iCAFParameters->iUniqueId->Des());
            stream.ReadL(ptr, length);
            }
        CleanupStack::Pop(filename);
        
        fileInit = ETrue;
        drmContent = ETrue;
        iFileHandle = EFalse; 
        iCAFParameters->iEnableUI = stream.ReadInt32L();
        }
    else
        {
        //		TODO If the UID is unknown we should reject, but  currently
        //		code also used for older calls that just supply filename.
        //		User::Leave(KErrNotSupported);
        }
    
    CleanupStack::PopAndDestroy(&stream);
    
    if (!fileInit && aInitData.Length() == sizeof(TMMFFileHandleParams))
        {
        TMMFFileHandleParams params;
        TPckgC<TMMFFileHandleParams> config(params);
        config.Set(aInitData);
        params = config();
        
        
        if (params.iUid == KFileHandleUid)
            {
            fileInit = ETrue;
            User::LeaveIfError(iHandle.Duplicate(*params.iFile));
            TInt pos = 0;
            // make sure the duplicate handle is at the start of the file - the usage of the file handle really requires this
            User::LeaveIfError(iHandle.Seek(ESeekStart, pos));
            iFileHandle = ETrue;
            filename = HBufC::NewMaxLC(KMaxFileName);
            filenamePushed = ETrue;
            TPtr ptr = filename->Des();
            User::LeaveIfError(iHandle.Name(ptr));
            }
        }
    
    if (!fileInit) // do old case as last resort
        {
        TMMFFileParams params;
        TPckgC<TMMFFileParams> config(params);
        config.Set(aInitData);
        params = config();
        
        filename = params.iPath.AllocL();
        fileInit = ETrue;
        }
    
    if (!filenamePushed)
        {
        // from now on it is assumed pushed.
        CleanupStack::PushL(filename);
        }
    
    TParse parser ;
    User::LeaveIfError(parser.Set(*filename, NULL, NULL));
    CleanupStack::PopAndDestroy(filename);
    if ( !( parser.NamePresent() ) && !( parser.ExtPresent() ) )
        User::Leave( KErrBadName ) ;
    
    iFullFileName.Copy( parser.FullName() ) ;	
    iFileName = parser.Name().AllocL() ;
    iFileExt = parser.Ext().AllocL() ;
    iFilePath = parser.Path().AllocL() ;
    iFileDrive = parser.Drive().AllocL() ;
    
    // in order to simulate old behaviour we are not passing error out
    // but will try to create Content again during PrimeL()
    if (fileInit && drmContent && aFileMode==ESourceMode)
        {
        TInt contentError;
        if (iFileHandle)
            {
            TRAP(contentError, 
                iFile = CContentFile::NewL(iHandle, UniqueId(), iCAFParameters->iEnableUI);
            );
            }
Exemplo n.º 13
0
TVerdict CUpsClientStep::doTestStepPreambleL()
/**
 * @return - TVerdict code
 * Override of base class virtual
 */
	{
	
 	__UHEAP_MARK;
 	
	// Read values to config servers from INI file. (ARRAY of values)
 	
    // Read how many times the test step needs to be repeated.
    TName fStepRepeat(_L("StepRepeat"));
    TInt  repeats;
    
    if(GetIntFromConfig(ConfigSection(),fStepRepeat,repeats))
	    {
	   	iStepRepeat=repeats;
	    }
	else
		{
		iStepRepeat=1;		
		}
    
    // Read values for test sequence from INI file. (ARRAY of values)
	TInt index=0;
	TName fUseServiceUID;
	fUseServiceUID.Format(_L("UseServiceUID_%d"),index);
	TName fUseServerName;
	fUseServerName.Format(_L("UseServerName_%d"),index);
	TName fDestination;
	fDestination.Format(_L("Destination_%d"),index);
	TName fExpectedError;
	fExpectedError.Format(_L("ExpectedError_%d"),index);
	TName fUseOpaqueData;
	fUseOpaqueData.Format(_L("UseOpaqueData_%d"),index);
	TName fSelectDialogOption;
	fSelectDialogOption.Format(_L("SelectDialogOption_%d"),index); 
	TName fButtonsDisplayed;
	fButtonsDisplayed.Format(_L("ButtonsDisplayed_%d"),index);
	TName fDialogCreatorInvoked;
	fDialogCreatorInvoked.Format(_L("DialogCreatorInvoked_%d"),index);
	TName fPolicyEvaluatorInvoked;
	fPolicyEvaluatorInvoked.Format(_L("PolicyEvaluatorInvoked_%d"),index);
	TName fAccessGranted;
	fAccessGranted.Format(_L("AccessGranted_%d"), index);
	TName fCloseSession;
	fCloseSession.Format(_L("CloseSession_%d"), index);
	TName fHoldEvaluatorOpen;
	fHoldEvaluatorOpen.Format(_L("HoldEvaluatorOpen_%d"), index);
	TName fHoldPrepareDialogOpen;
	fHoldPrepareDialogOpen.Format(_L("HoldPrepareDialogOpen_%d"), index);
	TName fHoldDisplayDialogOpen;
	fHoldDisplayDialogOpen.Format(_L("HoldDisplayDialogOpen_%d"), index);
	TName fRequestDurationThreshold;
	fRequestDurationThreshold.Format(_L("RequestDurationThreshold_%d"), index);
	TName fLeaveDialog;
	fLeaveDialog.Format(_L("LeaveDialog_%d"), index);
	TName fLeaveEvaluator;
	fLeaveEvaluator.Format(_L("LeaveEvaluator_%d"), index);
	TName fCancelUpsRequest;
	fCancelUpsRequest.Format(_L("CancelUpsRequest_%d"), index);
	TName fPlatSecPass;
	fPlatSecPass.Format(_L("PlatSecPass_%d"), index);
	TName fForcePrompt;
	fForcePrompt.Format(_L("ForcePrompt_%d"), index);
	TName fExpectedEvaInfo;
	fExpectedEvaInfo.Format(_L("ExpectedEvaluatorInfo_%d"), index);
	TName fSelectFingerprint;
	fSelectFingerprint.Format(_L("SelectFingerprint_%d"), index);
	TName fWaitUntilFileAppears;
	fWaitUntilFileAppears.Format(_L("WaitUntilFileAppears_%d"), index);
	
	TInt	useServiceUID;
	TPtrC   useServerName;
	TPtrC   destination;
	TInt	expectedError;
	TPtrC   useOpaqueData;
    TPtrC	selectDialogOption;
	TInt	buttonsDisplayed;
	TInt    dialogCreatorInvoked;
	TInt	policyEvaluatorInvoked;
	TPtrC	accessGranted;
	TBool	closeSession;
	TBool   holdEvaluatorOpen;
	TBool   holdPrepareDialogOpen;
	TBool   holdDisplayDialogOpen;
	TInt 	requestDurationThreshold;
	TBool   leaveDialog;
	TBool   leaveEvaluator;
	TBool   cancelUpsRequest;
	TBool   platSecPass;
	TBool   forcePrompt;
	TInt    expectedEvaInfo;
	TInt	selectFingerprint;
	TPtrC   waitUntilFileAppears;	
	
	while (GetHexFromConfig(ConfigSection(), fUseServiceUID,useServiceUID)
		&& GetStringFromConfig(ConfigSection(),fUseServerName,useServerName)
		&& GetStringFromConfig(ConfigSection(),fDestination,destination)
	  	&& GetStringFromConfig(ConfigSection(),fAccessGranted,accessGranted))
		{
	    TServiceRequestParameters newSerReq;
	    newSerReq.iServiceUID = useServiceUID; 
	    newSerReq.iServerName = useServerName;
	    newSerReq.iDestination = destination;
	    newSerReq.iAccessGranted = accessGranted;
	    
        // Close session is optional.
        if(GetBoolFromConfig(ConfigSection(),fCloseSession,closeSession))
	    	{
	    	newSerReq.iCloseSession = closeSession;
	    	}
	    
	    // use of dialog creator is optional.
	    if(GetStringFromConfig(ConfigSection(),fSelectDialogOption,selectDialogOption)
		&& GetIntFromConfig(ConfigSection(),fButtonsDisplayed,buttonsDisplayed)
		&& GetIntFromConfig(ConfigSection(),fDialogCreatorInvoked,dialogCreatorInvoked))
	    	{
		    newSerReq.iSelectDialogOption = selectDialogOption;
		    newSerReq.iButtonsDisplayed	= buttonsDisplayed;
		    newSerReq.iDialogCreatorInvoked	= dialogCreatorInvoked;
	    	} 
	    
	    // use of policy evaluator is optional.
	    if(GetIntFromConfig(ConfigSection(),fPolicyEvaluatorInvoked,policyEvaluatorInvoked))
	    	{
	       	newSerReq.iPolicyEvaluatorInvoked = policyEvaluatorInvoked;
	    	}
	    	    
	    // Opaque data is optional
	    if(GetStringFromConfig(ConfigSection(),fUseOpaqueData,useOpaqueData))
	    	{
	       	HBufC8* converter = HBufC8::NewLC(useOpaqueData.Length());
			converter->Des().Copy(useOpaqueData);	
             
	       	newSerReq.iOpaqueData = converter->Ptr() ;	
	       	CleanupStack::PopAndDestroy(); //converter 
	    	}
	    
	    // Expected error is optional.
	    if(GetIntFromConfig(ConfigSection(),fExpectedError,expectedError))
	    	{
			newSerReq.iExpectedError = expectedError;
	    	}
	    	
	    // hold policy evaluator open is optional.
	    if(GetBoolFromConfig(ConfigSection(),fHoldEvaluatorOpen, holdEvaluatorOpen))
	    	{
			newSerReq.iHoldEvaluatorOpen =	holdEvaluatorOpen;
	    	}
	    
	    // hold prepare dialog open is optional.
	    if(GetBoolFromConfig(ConfigSection(),fHoldPrepareDialogOpen, holdPrepareDialogOpen))
	    	{
			newSerReq.iHoldPrepareDialogOpen =	holdPrepareDialogOpen;
	    	}
	    	
	    // hold display dialog open is optional.
	    if(GetBoolFromConfig(ConfigSection(),fHoldDisplayDialogOpen, holdDisplayDialogOpen))
	    	{
			newSerReq.iHoldDisplayDialogOpen =	holdDisplayDialogOpen;
	    	}
	    
	    // request duration threshold - if a request takes 
	    // longer than this threshold it will fail the test
	    if(GetIntFromConfig(ConfigSection(),fRequestDurationThreshold, requestDurationThreshold))
	    	{
	       	newSerReq.iRequestDurationThreshold = requestDurationThreshold;
	    	}

	    // leave dialog is optional.
	    if(GetBoolFromConfig(ConfigSection(),fLeaveDialog,leaveDialog))
	    	{
	    	newSerReq.iLeaveDialog = leaveDialog;
	   		}
	    
	    // leave Evaluator is optional.
	    if(GetBoolFromConfig(ConfigSection(),fLeaveEvaluator,leaveEvaluator))
	    	{
			newSerReq.iLeaveEvaluator = leaveEvaluator;	
	    	}
		       
	    // Cancel ups request is optional.
	    if(GetBoolFromConfig(ConfigSection(),fCancelUpsRequest,cancelUpsRequest))
	    	{
	  		newSerReq.iCancelUpsRequest = cancelUpsRequest;		
	    	}
    
	    // plat sec pass is optional.
	    if(GetBoolFromConfig(ConfigSection(),fPlatSecPass,platSecPass))
	    	{
			newSerReq.iPlatSecPass = platSecPass;
	    	}
	    
	    // Force prompt is optional.
	    if(GetBoolFromConfig(ConfigSection(),fForcePrompt,forcePrompt))
	    	{
			newSerReq.iForcePrompt = forcePrompt;
	    	}
	    
	    // use of policy evaluator is optional.
	    if(GetIntFromConfig(ConfigSection(),fExpectedEvaInfo,expectedEvaInfo))
	    	{
	       	newSerReq.iExpectedEvaluatorInfo = expectedEvaInfo;
	    	}
	    
	    // Fingerprint selection is optional.
	    if(GetIntFromConfig(ConfigSection(),fSelectFingerprint,selectFingerprint))
	    	{
	       	newSerReq.iSelectFingerprint = selectFingerprint;
	    	}
	    
	    // iRepeatUntilFileAppears is optional.
	    if(GetStringFromConfig(ConfigSection(),fWaitUntilFileAppears,waitUntilFileAppears))
	    	{
	    	newSerReq.iWaitUntilFileAppears = waitUntilFileAppears;
	    	}
	    
	    // Add the new service to be requested to array.
	    iArraySersToRequest.Append(newSerReq);
	       
	    index++;
	    fUseServiceUID.Format(_L("UseServiceUID_%d"),index);
	    fUseServerName.Format(_L("UseServerName_%d"),index);
	    fDestination.Format(_L("Destination_%d"),index);
	    fExpectedError.Format(_L("ExpectedError_%d"),index);
	    fUseOpaqueData.Format(_L("UseOpaqueData_%d"),index);
	    fSelectDialogOption.Format(_L("SelectDialogOption_%d"),index);
	    fButtonsDisplayed.Format(_L("ButtonsDisplayed_%d"),index);
	    fDialogCreatorInvoked.Format(_L("DialogCreatorInvoked_%d"),index); 
	    fPolicyEvaluatorInvoked.Format(_L("PolicyEvaluatorInvoked_%d"),index);
	    fAccessGranted.Format(_L("AccessGranted_%d"), index);  
	    fCloseSession.Format(_L("CloseSession_%d"), index);
	    fHoldEvaluatorOpen.Format(_L("HoldEvaluatorOpen_%d"), index);
	    fHoldPrepareDialogOpen.Format(_L("HoldPrepareDialogOpen_%d"), index);
	    fHoldDisplayDialogOpen.Format(_L("HoldDisplayDialogOpen_%d"), index);
		fRequestDurationThreshold.Format(_L("RequestDurationThreshold_%d"), index);
	    fLeaveDialog.Format(_L("LeaveDialog_%d"), index);
	    fLeaveEvaluator.Format(_L("LeaveEvaluator_%d"), index);
	    fCancelUpsRequest.Format(_L("CancelUpsRequest_%d"), index);
	    fPlatSecPass.Format(_L("PlatSecPass_%d"), index);
	    fForcePrompt.Format(_L("ForcePrompt_%d"), index);
	   	fExpectedEvaInfo.Format(_L("ExpectedEvaluatorInfo_%d"), index);
	   	fSelectFingerprint.Format(_L("SelectFingerprint_%d"), index);
	   	fWaitUntilFileAppears.Format(_L("WaitUntilFileAppears_%d"), index);
	   	}	

	// now try for some clientStep specific stuff
	// this ini file entry specifies the property key value for the hold flag
	// If the hold flag property is true then monitor it until it becomes false
	// then continue
	TInt holdKey;
    if(GetIntFromConfig(ConfigSection(),_L("HoldClientStepKey"), holdKey))
	    {
		iHoldClientStepKey = holdKey;

		// as this property is present then set it to true using a direct call to p&s api because
		// the ups p&s api only handles policy evaluators and dialog creators and not test steps
		User::LeaveIfError(RProperty::Set(KPropertyCreatorUid, iHoldClientStepKey, 2));
	    }

	// Instantiates property reader and seter
	iPropertyReader= CUpsProperty::NewL(KPropertyCreatorUid); 

	// reads client name and SID
	TParse clientFullName;
	RThread client;
	clientFullName.Set(client.FullName(),NULL, NULL);
	iTEFServerName=clientFullName.Name();
	iExpectedClientSid = client.SecureId() ;
	client.Close();
			
	SetTestStepResult(EPass);
	return TestStepResult();
	}
Exemplo n.º 14
0
/**
 * Subroutine performing pre-processing tasks for testexecute execution
 * Also, responsible for triggering the state machine through instance of ScriptMaster
 * @param aScheduler - Instance of ActiveScheduler created through MainL()
 * @param aSysDrive - Default system drive letter to be used for all script parsing
 */
LOCAL_C void ProcessMainL(CActiveScheduler* aScheduler, const TDriveName aSysDrive)
	{
	TDriveName defaultSysDrive(aSysDrive);
	TDriveName testSysDrive(KTEFLegacySysDrive);
	TInt waitForLoggingTime = 0;
	TBuf<KMaxTestExecuteNameLength> htmlLogPath;
	// Create a object of the Parser for TestExecute.ini
	CTestExecuteIniData* parseTestExecuteIni = NULL;
	TRAPD(err, parseTestExecuteIni = CTestExecuteIniData::NewL(defaultSysDrive));
	if (err == KErrNone)
		{
		CleanupStack::PushL(parseTestExecuteIni);
		// Extract all the key values within the object
		parseTestExecuteIni->ExtractValuesFromIni();
		}

	// Read and parse the command line for the flags
	// -d -slf -help and -v
	TBuf<KMaxTestExecuteCommandLength> commandLine;
	TDesC* selTestCfgFileData = NULL; //the pointer to the data of in the .tcs file
	ReadCommandLineL(commandLine);
	
	// Make lower case because we parse it for flags and search for ".script"
	commandLine.LowerCase();
	TBool separateLogFiles(EFalse); // -slf
	TBool justInTime(EFalse); // -d
	TBool graphicalWindowServer(EFalse); // -gws
	TBool helpRequest(EFalse); // -help
	TBool versionRequest(EFalse); // -v

	TBool includeSelectiveCases(EFalse); // -tci
	TBool excludeSelectiveCases(EFalse); // -tcx
	TBool pipe(EFalse) ; 
	
	// Set up the bools from the command line
	ParseCommandLine(commandLine,separateLogFiles,justInTime,graphicalWindowServer,includeSelectiveCases, excludeSelectiveCases,pipe, helpRequest,versionRequest,*parseTestExecuteIni,err);
	// If -d then set Just In Time debugging. Panicks break into debug on emulator
	(justInTime) ? (User::SetJustInTime(ETrue)) : (User::SetJustInTime(EFalse)); 

	// Hooks for creating the Graphical Window server
	#ifdef GWS
	#endif

	// Create a console
	_LIT(KMessage,"TestExecute Script Engine");
	CConsoleBase* console = Console::NewL(KMessage,TSize(KConsFullScreen,KConsFullScreen));
	CleanupStack::PushL(console);
	console->SetCursorHeight(0);
	RConsoleLogger consoleLogger(*console);
	
	CScriptControl::iRunScriptFailCount=0;
	// A lex for getting the first command line argument, ie the script file path
	TLex lex(commandLine);
	TPtrC scriptFilePath(lex.NextToken());
	TInt ret = KErrNotFound;
	if (scriptFilePath.CompareF(KNull) != 0)
		{
		_LIT(KTEFSwitchPrefix, "-");
		if(scriptFilePath.Mid(0,1).CompareF(KTEFSwitchPrefix) == 0)
			{
			// If the first command line argument is not the script file path but a optional switches
			// Then set the script file path for the execution to be 'blank'
			scriptFilePath.Set(KNull);
			}
		else
			{
			TBuf<KBuffSize> tempScriptPath(scriptFilePath);

			// Check whether script name is provided along with folder path in the command line
			// If not, take the path from testexecute.ini & name from the command line
			ret=scriptFilePath.FindC(KTEFColon);
			if(ret==KErrNotFound)
				{
				if (parseTestExecuteIni != NULL)
					{
					TBuf<KMaxTestExecuteNameLength> tempBuffer;
					parseTestExecuteIni->GetKeyValueFromIni(KTEFDefaultScriptPath, tempBuffer);
 					// If the relative script file path does not refer to the root,
 					// we will look for DefaultScriptDir entry in testexecute.ini
 					// If available prepend it to the relative path
 					// else if the relative path refers to root,
 					// then set the default system drive, i.e. c:
 					// else leaving it as it is (considering invalid path)
 					if (scriptFilePath.Left(1).CompareF(KTEFSlash) != 0 &&
 					 tempBuffer.Length() > 0)
 						scriptFilePath.Set(tempBuffer);
 					else if (scriptFilePath.Left(1).CompareF(KTEFSlash) == 0)
 						scriptFilePath.Set(defaultSysDrive);
 					else
 						scriptFilePath.Set(KNull);
					}
				else
					{
					// If the file path is not provided in command line as well as in testexecute.ini
					// then set the  script file path to be 'blank'
					scriptFilePath.Set(KNull);
					}

				// Construct the full file path from the values extracted from command line and ini file
				TBuf<KBuffSize> storeScriptPathTemp(scriptFilePath);
				storeScriptPathTemp.Append(tempScriptPath);
				scriptFilePath.Set(storeScriptPathTemp);
				tempScriptPath.Copy(scriptFilePath);
				}

			//If scriptFilePath is not appended by .script Append .script 
			if(scriptFilePath.Find(KTEFScriptExtension)==KErrNotFound)
				{
				tempScriptPath.Append(KTEFScriptExtension);
				}
			scriptFilePath.Set(tempScriptPath);
			}
		}

	TPtrC pipeName ; 
	if(pipe)
		{
		TLex flagLex(commandLine);
		//first of all navigate the command line arguments to the selective test cases flag...
		while(!flagLex.Eos())
		{
			TPtrC token(flagLex.NextToken());
			if( (token.CompareF(KTestExecuteCommandLineFlagPipe) == 0) )
				{
				break;
				}
		}
		pipeName.Set(flagLex.NextToken()) ; 	
		}
	
	TSelectiveTestingOptions* selTestingOptions =NULL;
	if (includeSelectiveCases && excludeSelectiveCases)
		{
			//mutually exclusive options have been encountered
			includeSelectiveCases =EFalse;
			excludeSelectiveCases =EFalse;					
			console->Printf(KTEFInvalidCommandSetMessage);
			console->Printf(KTEFEnterKeyMessage);
			console->Getch();
		}
	else
		{
		if(includeSelectiveCases || excludeSelectiveCases)
			{
			RArray<TRange> selectiveCaseRange;
			ParseCommandLineForSelectiveTestingOptions(commandLine,*parseTestExecuteIni,selectiveCaseRange, selTestCfgFileData);
			
			//you need to sort these two arrays first, and also if they are both empty ignore the entire option altogether.
			if(  selectiveCaseRange.Count() > 0 )
				{
				CleanupStack::PushL(selTestCfgFileData);
				TLinearOrder<TRange> orderingrng(TRange::CompareTRangeStartOrder) ; 
				selectiveCaseRange.Sort(orderingrng );
				ESelectiveTesting selectiveTestingType(iExclusive);
				if(includeSelectiveCases)
					{
					selectiveTestingType = iInclusive ; 
					}
				selTestingOptions = new(ELeave) TSelectiveTestingOptions(selectiveCaseRange, selectiveTestingType);
				}
			else
				{
				//if no arguments to this option have been found, ignore it...
				includeSelectiveCases =EFalse;
				excludeSelectiveCases =EFalse;
				delete selTestCfgFileData;
				}
			}
		}

	if (scriptFilePath.CompareF(KNull)==0)
		{
		if (!separateLogFiles && !justInTime)
			{
			// Print the product version details through console window
			console->Printf(KTEFVersionMessage);
			console->Printf(KTEFProductVersion);

			if (!(versionRequest && !helpRequest))
				{
				// Print the help & usage informations through console window along with product version
				console->Printf(KTEFConsoleHelpMessage1);
				console->Printf(KTEFConsoleHelpMessage2);
				console->Printf(KTEFConsoleHelpMessage3);
				console->Printf(KTEFConsoleHelpMessage4);
				console->Printf(KTEFConsoleHelpMessage5);
				}
			}
		else
			{
			// Display a error message on the console window for invalid set of arguments
			console->Printf(KTEFInvalidCommandSetMessage);
			}
		// Exit on a key press from user
		console->Printf(KTEFEnterKeyMessage);
		console->Getch();
		}
	else
		{
		// Create a Interface class object for generating HTML & XML logs
		CTestExecuteLogger *tefLogger = new(ELeave) CTestExecuteLogger();
		CleanupStack::PushL(tefLogger);

		TInt logMode;
		TInt logLevel;
		TInt remotePanicDetection;
		TBuf<KMaxTestExecuteNameLength> iniSysDrive;

		if (parseTestExecuteIni != NULL)
			{
			// Parse ini for retrieving logging options set through ini
			parseTestExecuteIni->GetKeyValueFromIni(KTEFLogMode, logMode);
			parseTestExecuteIni->GetKeyValueFromIni(KTEFLogSeverityKey, logLevel);
			parseTestExecuteIni->GetKeyValueFromIni(KTEFRemotePanicDetection, remotePanicDetection);
			parseTestExecuteIni->GetKeyValueFromIni(KTEFDefaultSysDrive, iniSysDrive);
			parseTestExecuteIni->GetKeyValueFromIni(KTEFWaitForLoggingTime, waitForLoggingTime);
			parseTestExecuteIni->GetKeyValueFromIni(KTEFHtmlKey, htmlLogPath);
			}
		else
			{
			// Set default values for logging options if parser is not functioning
			logMode = TLoggerOptions(ELogHTMLOnly);
			logLevel = RFileFlogger::TLogSeverity(ESevrAll);
			remotePanicDetection = 0;
			iniSysDrive.Copy(KTEFIniSysDrive);
			waitForLoggingTime = 5;
			htmlLogPath.Copy(KTestExecuteLogPath);
			htmlLogPath.Replace(0, 2, defaultSysDrive);
			}
		
		tefLogger->SetLoggerOptions(logMode);
		if(pipe)
			{
			tefLogger->SetPipeName(pipeName) ; 
			}
		
		// Initialise the logging passing in the script file path & log level to the interface
		tefLogger->InitialiseLoggingL(scriptFilePath, separateLogFiles, logLevel);

		// Check to see if defaultsysdrive key is set in testexecute.ini
		// if set to SYSDRIVE, assign the default system drive obtained from the plugin
		// else, if a true value is set in testexecute.ini, use it as system drive for all test artifacts
		if (iniSysDrive.Length() == 2 && iniSysDrive.Right(1).Compare(KTEFColon) == 0)
			testSysDrive.Copy(iniSysDrive);
		else if (iniSysDrive.CompareF(KTEFIniSysDrive) == 0)
			testSysDrive.Copy(defaultSysDrive);


		// Pass the first command line argument to the script master
		// which is always the command script
		CScriptMaster* scriptMaster = new (ELeave) CScriptMaster(scriptFilePath,*tefLogger, consoleLogger, defaultSysDrive, testSysDrive, selTestingOptions);
		// To kick the state machine of the script master off -
		// Call the kick method which jumps us into the RunL() of the CScriptMaster class
		// CScriptMaster is the top AO in the hierarchy.
		scriptMaster->Kick();

		// Construct and Install a test watcher object for capturing remote panics during test execution
		CTestWatcher* testWatcher = NULL;
		if (remotePanicDetection != 0)
			{
			testWatcher = CTestWatcher::NewL();
			testWatcher->StartL();
			}

		// Enter the Active Scheduler
		aScheduler->Start();
		
		// Cleanup
		delete scriptMaster;
		
		TInt commentedCommandsCnt=CScriptControl::commentedCommandsCount;
		if(commentedCommandsCnt==-1)
			{
			CScriptControl::commentedCommandsCount=0;
			//If the path specified fails check out for path from testexecute.ini
			if(ret!=KErrNotFound)
				{
				//To get scriptFile name  i.e get sampleFile.script
				TInt posOfLastSlash=scriptFilePath.LocateReverse('\\') ;
				scriptFilePath.Set(scriptFilePath.Mid(posOfLastSlash+1));
				TBuf<KBuffSize> tempStore(scriptFilePath);
				if (parseTestExecuteIni != NULL)
					{
					TBuf<KMaxTestExecuteNameLength> tempBuffer;
					parseTestExecuteIni->GetKeyValueFromIni(KTEFDefaultScriptPath, tempBuffer);
					if (tempBuffer.CompareF(KNull) != 0)
						{
						scriptFilePath.Set(tempBuffer);
						TBuf<KBuffSize> tempStoreScriptPath(scriptFilePath);
						tempStoreScriptPath.Append(tempStore);
						scriptFilePath.Set(tempStoreScriptPath);
						TBuf<KMaxTestExecuteNameLength> scriptFileLocation(scriptFilePath);
						CScriptMaster* scriptMaster = new (ELeave) CScriptMaster(scriptFilePath,*tefLogger, consoleLogger, defaultSysDrive, testSysDrive, selTestingOptions);
						// To kick the state machine of the script master off -
						// Call the kick method which jumps us into the RunL() of the CScriptMaster class
						// CScriptMaster is the top AO in the hierarchy.
						scriptMaster->Kick();
						// Enter the Active Scheduler
						aScheduler->Start();
						
						commentedCommandsCnt=CScriptControl::commentedCommandsCount;
						if(commentedCommandsCnt==-1)
							{
							CScriptControl::commentedCommandsCount=0;
							}
							
						// Cleanup
						delete scriptMaster;
						}
					}
				}
			}
		delete selTestingOptions;
		
		TInt commandsCount = CScriptControl::commentedCommandsCount;
		TInt countOfRemotePanics = 0;

		// Stop and Process the test watcher object for extracting panic informations and print them to the log files
		if (remotePanicDetection != 0)
			{
			testWatcher->Stop();
			countOfRemotePanics = testWatcher->iSharedData->iPanicDetails.Count();
			if (countOfRemotePanics > 0)
				{
				tefLogger->LogExtra((TText8*)__FILE__,__LINE__,ESevrErr,
					_L("The panic detection thread detected %d panics:"), countOfRemotePanics);
				for (TInt count = 0; count < countOfRemotePanics; count++)
					tefLogger->LogExtra((TText8*)__FILE__,__LINE__,ESevrErr,_L("Remote Panic %d - Name of Panicked Thread: %S, Exit Reason: %d, Exit Category %S"), count+1, &(testWatcher->iSharedData->iPanicDetails)[count]->iThreadName,(testWatcher->iSharedData->iPanicDetails)[count]->iReason,&(testWatcher->iSharedData->iPanicDetails)[count]->iCategory);
				}
			delete testWatcher;
			}

		// Call the Termination routine for logging within the interface
		tefLogger->TerminateLoggingL(commandsCount, countOfRemotePanics, CScriptControl::iRunScriptFailCount);
		CleanupStack::Pop(tefLogger);
		delete tefLogger;
		}
	if(includeSelectiveCases || excludeSelectiveCases)
		{	
		CleanupStack::PopAndDestroy(selTestCfgFileData);
		selTestCfgFileData = NULL;
		}
	// Close the parser instance if it is active
	CleanupStack::PopAndDestroy(console);
	if (parseTestExecuteIni != NULL)
		{
		CleanupStack::PopAndDestroy(parseTestExecuteIni);
		}

	if (scriptFilePath.CompareF(KNull)!=0)
		{
		// Wait for flogger to write to file
		_LIT(KHtmExtension,".htm");
		TParse fileNameParse;
		fileNameParse.Set(scriptFilePath, NULL, NULL);
		
		TPtrC fileName = fileNameParse.Name();
		htmlLogPath.Append(fileName);
		htmlLogPath.Append(KHtmExtension);

	#ifdef _DEBUG
		RDebug::Print(_L("Log file path--> %S"), &htmlLogPath);
	#endif
		RFs fs;
		fs.Connect();
		TBool answer = EFalse;
		while(ETrue)
			{
			TInt err = fs.IsFileOpen(htmlLogPath, answer);
			if ((KErrNone==err&&!answer) || KErrNotFound==err || KErrPathNotFound==err) 
				{
				break;
				}
			User::After(100000);
			}
		
		if (waitForLoggingTime > 0)
			{
			User::After(waitForLoggingTime*1000000);
			}
		}
	}
TVerdict CUPSDbManagementStep::doTestStepPreambleL()
/**
 * @return - TVerdict code
 * Override of base class virtual
 */
	{
 	__UHEAP_MARK;
 	
 	INFO_PRINTF2(_L("START CELLS: %d"), User::CountAllocCells());
 	
 	// reads client name and SID
	TParse clientFullName;
	RThread client;
	clientFullName.Set(client.FullName(),NULL, NULL);
	iTEFServerName=clientFullName.Name();
	iExpectedClientSid = client.SecureId() ;
	client.Close();
 	
    // Read how many times the test step needs to be repeated.
    TName fStepRepeat(_L("StepRepeat"));
    TInt  repeats;
    
    if(GetIntFromConfig(ConfigSection(),fStepRepeat,repeats))
    	{
    	iStepRepeat=repeats;
    	}
	else
		{	
		iStepRepeat=1;		
		}
    
    // Read values for test sequence from INI file. (ARRAY of values)
	TInt index=0;
	TName fOperation;
	fOperation.Format(_L("Operation_%d"), index);
	TName fClientSid;
	fClientSid.Format(_L("ClientSid_%d"),index);
	TName fEvaluatorId;
	fEvaluatorId.Format(_L("EvaluatorId_%d"),index);
	TName fServiceId;
	fServiceId.Format(_L("ServiceId_%d"),index);
	TName fServerSid;
	fServerSid.Format(_L("ServerSid_%d"),index);
	TName fFingerprint;
	fFingerprint.Format(_L("Fingerprint_%d"),index);
	TName fClientEntity;
	fClientEntity.Format(_L("ClientEntity_%d"),index);
	TName fDescription;
	fDescription.Format(_L("Description_%d"),index);
	TName fDecisionResult;
	fDecisionResult.Format(_L("DecisionResult_%d"),index);
	TName fMajorPolicyVersion;
	fMajorPolicyVersion.Format(_L("MajorPolicyVersion_%d"),index);
	TName fRecordId;
	fRecordId.Format(_L("RecordId_%d"),index);
	TName fEvaluatorInfo;
	fEvaluatorInfo.Format(_L("EvaluatorInfo_%d"),index);
	TName fExpectedDecisionCount;
	fExpectedDecisionCount.Format(_L("ExpectedDecisionCount_%d"),index);
	
	TPtrC 	operation;
	TInt	clientSid;
	TInt	evaluatorId;
	TInt	serviceId;
	TInt	serverSid;
	TPtrC	fingerprint;
	TPtrC	clientEntity;
	TPtrC	description;
	TPtrC	decisionResult;
	TInt	majorPolicyVersion;
	TInt 	recordId;
	TInt	evaluatorInfo;
	TInt 	expectedDecisionCount;
	
	while (GetStringFromConfig(ConfigSection(),fOperation,operation))
		{
		
		// Create an instance of a new request
		CUpsDbRequest* newRequest = CUpsDbRequest::NewL();
		CleanupStack::PushL(newRequest);
		
		// Set the operation to be performed
	    newRequest->iOperation = operation;
	    
	    if(GetHexFromConfig(ConfigSection(),fClientSid,clientSid))
		    {
		    newRequest->iClientSid = clientSid;
		  	newRequest->iDecisionFilter->SetClientSid(TSecureId(clientSid),EEqual);
		    }
	    
		if(GetHexFromConfig(ConfigSection(),fEvaluatorId,evaluatorId))
			{
			newRequest->iEvaluatorId = evaluatorId;	
			newRequest->iDecisionFilter->SetEvaluatorId(TUid::Uid(evaluatorId),EEqual);
			}
		
		if(GetHexFromConfig(ConfigSection(),fServiceId,serviceId))
			{
			newRequest->iServiceId = serviceId;	
			newRequest->iDecisionFilter->SetServiceId(TUid::Uid(serviceId),EEqual);
			}
	
		if(GetHexFromConfig(ConfigSection(),fServerSid,serverSid))
			{
			newRequest->iServerSid = serverSid;	
			newRequest->iDecisionFilter->SetServerSid(TSecureId(serverSid),EEqual);
			}
			
		if(GetStringFromConfig(ConfigSection(),fFingerprint,fingerprint))
			{
			HBufC8* fingerprintConverter = HBufC8::NewLC(fingerprint.Length());
			TPtr8 fingerprintPtr = fingerprintConverter->Des();
			fingerprintPtr.Copy(fingerprint); 	
             
	       	newRequest->iFingerprint = fingerprintPtr;
	       	
	       	HBufC8* binaryFingerprint = StringToBinaryLC(fingerprintPtr);
	       	
	      	newRequest->iDecisionFilter->SetFingerprintL(*binaryFingerprint,EEqual);	
	       	CleanupStack::PopAndDestroy(binaryFingerprint);
	       	CleanupStack::PopAndDestroy(fingerprintConverter); 
			}

		if(GetStringFromConfig(ConfigSection(),fClientEntity,clientEntity))
			{
			HBufC8* clientEntityConverter = HBufC8::NewLC(clientEntity.Length());
			TPtr8 clientEntityPtr = clientEntityConverter->Des();
			clientEntityPtr.Copy(clientEntity); 	
             
	       	newRequest->iClientEntity = clientEntityPtr;
	       	newRequest->iDecisionFilter->SetClientEntityL(clientEntityPtr,EEqual);		
	       	CleanupStack::PopAndDestroy(clientEntityConverter); 
			}
			
		if(GetStringFromConfig(ConfigSection(),fDescription,description))
			{
		    newRequest->iDescription = description;
			}
			
		if(GetStringFromConfig(ConfigSection(),fDecisionResult,decisionResult))
			{
			if(decisionResult.CompareF(_L("Yes"))==0 || decisionResult.CompareF(_L("No"))==0 || decisionResult.CompareF(_L(""))==0 )
				{
				newRequest->iDecisionResult = decisionResult;	
				}
			else 
				{
				ERR_PRINTF3(_L("%S: Unexpected Decision Result - %S"),&iTEFServerName, &decisionResult);
				}
			}

		if(GetIntFromConfig(ConfigSection(),fMajorPolicyVersion,majorPolicyVersion)) 
			{
			newRequest->iMajorPolicyVersion = majorPolicyVersion;
			newRequest->iDecisionFilter->SetMajorPolicyVersion(majorPolicyVersion,EEqual);		
			}
		
		if(GetIntFromConfig(ConfigSection(),fRecordId,recordId))
			{
			newRequest->iRecordId = recordId;
			newRequest->iDecisionFilter->SetRecordId(recordId,EEqual);		
			}
			
		if(GetIntFromConfig(ConfigSection(),fEvaluatorInfo,evaluatorInfo))
			{
			newRequest->iEvaluatorInfo = evaluatorInfo;		
			}
			
		if(GetIntFromConfig(ConfigSection(),fExpectedDecisionCount,expectedDecisionCount))
			{
			newRequest->iExpectedDecisionCount = expectedDecisionCount;		
			}
	    
	    // Add the new service to be requested to array.
	    iArraySersToRequest.AppendL(newRequest);
	    
	    CleanupStack::Pop(newRequest);
	       
	    index++;
	    fOperation.Format(_L("Operation_%d"), index);
	    fClientSid.Format(_L("ClientSid_%d"),index);
		fEvaluatorId.Format(_L("EvaluatorId_%d"),index);
		fServiceId.Format(_L("ServiceId_%d"),index);
		fServerSid.Format(_L("ServerSid_%d"),index);
		fFingerprint.Format(_L("Fingerprint_%d"),index);
		fClientEntity.Format(_L("ClientEntity_%d"),index);
		fDescription.Format(_L("Description_%d"),index);
		fDecisionResult.Format(_L("DecisionResult_%d"),index);
		fMajorPolicyVersion.Format(_L("MajorPolicyVersion_%d"),index);
		fRecordId.Format(_L("RecordId_%d"),index);
		fEvaluatorInfo.Format(_L("EvaluatorInfo_%d"),index);
		fExpectedDecisionCount.Format(_L("ExpectedDecisionCount_%d"),index);
		}
	
	SetTestStepResult(EPass);
	return TestStepResult();
	}
Exemplo n.º 16
0
// Second-phase constructor
void CPuttyAppUi::ConstructL() {
#ifdef PUTTY_S60V3
    #ifdef PUTTY_SYM3
        BaseConstructL(CAknAppUi::EAknEnableSkin | EAknTouchCompatible | EAknSingleClickCompatible);
    #else
        BaseConstructL(CAknAppUi::EAknEnableSkin);
    #endif
#else
    BaseConstructL();
#endif

    // Determine profile, data and font directories based on the executable
    // installation location. The files are on the same drive as the
    // executable, except if the exe is in ROM (z:), in which case profiles and
    // data use c:.
    TFileName name;
    name = RProcess().FileName();
    TParse parsa;
    parsa.SetNoWild(name, NULL, NULL);
    TUint drive = parsa.Drive()[0];

    // Font directory -- "<drv>:\resource\puttyfonts\"
    iFontDirectory.Format(KFontDirFormat, drive);

    // Fix drive for profiles and data
    if ( (drive == 'z') || (drive == 'Z') ) {
        drive = 'c';
    }

    // Data directory -- "<drv>:\private\<SID>\data\"
    // If the data directory doesn't exist, create it and attempt to migrate
    // host keys from a previous installation
    iDataDirectory.Format(KDataDirFormat, drive, RProcess().SecureId().iId);
    RFs &fs = CEikonEnv::Static()->FsSession();
    if ( !BaflUtils::FolderExists(fs, iDataDirectory) ) {
        BaflUtils::EnsurePathExistsL(fs, iDataDirectory);
        if ( BaflUtils::FileExists(fs, KOldHostKeysFile) ) {
            name = iDataDirectory;
            name.Append(KNewHostKeysFile);
            BaflUtils::CopyFile(fs, KOldHostKeysFile, name);
        }
    }

    // Profile directory -- "<drv>:\private\<SID>\profiles\"
    // If the profile directory doesn't exist, create it and attempt to migrate
    // default settings from a previous installation
    iProfileDirectory.Format(KProfileDirFormat, drive,
                             RProcess().SecureId().iId);
    if ( !BaflUtils::FolderExists(fs, iProfileDirectory) ) {
        BaflUtils::EnsurePathExistsL(fs, iProfileDirectory);
        if ( BaflUtils::FileExists(fs, KOldSettingsFile) ) {
            name = iProfileDirectory;
            name.Append(KNewDefaultProfileFile);
            BaflUtils::CopyFile(fs, KOldSettingsFile, name);
        }
    }

    // Create navi pane
    iNaviPane = (CAknNavigationControlContainer*)
        (StatusPane()->ControlL(TUid::Uid(EEikStatusPaneUidNavi)));

    // Build a list of available fonts
    iFonts = new CDesC16ArrayFlat(8);
    CDir *dir;
    User::LeaveIfError(
        CEikonEnv::Static()->FsSession().GetDir(iFontDirectory,
                                                KEntryAttNormal,
                                                ESortByName, dir));
    CleanupStack::PushL(dir);
    for ( TInt i = 0; i < dir->Count(); i++ ) {
        parsa.SetNoWild((*dir)[i].iName, NULL, NULL);
        iFonts->AppendL(parsa.Name());
    }
    CleanupStack::PopAndDestroy(); //dir    

    // Build views
    iProfileListView = CProfileListView::NewL();
    AddViewL(iProfileListView);
    iProfileEditView = CProfileEditView::NewL();
    AddViewL(iProfileEditView);
    iTerminalView = CTerminalView::NewL();
    AddViewL(iTerminalView);

    // Start from the profile list view.
    SetDefaultViewL(*iProfileListView);
}