コード例 #1
0
void CQualityProfileApi_ProfileReadStep::InitializeQualityProfileInfoL()
	{
	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);

	TBuf<32> privatePath;
	User::LeaveIfError(fs.PrivatePath(privatePath));

	TParse parse;
	parse.Set(privatePath, NULL, NULL);
	parse.AddDir(KLbsDir);
	
	RArray<TQualityProfile> qualityArray;
	CleanupClosePushL(qualityArray);
	
	qualityArray.Reserve(5);

	// Only want to use the first file that is found.
	// The way TFindFile::FindByDir works, it will search
	// C: and D: before Z:, which is what we want.
	TFindFile findFile(fs);
	TInt err = findFile.FindByDir(KQualityProfileIniName, parse.Path());
	if (err == KErrNone)
		{
		GetQualityProfileInfoL(fs, qualityArray, findFile.File());
		}
	
	// Publish the quality profile info
	LbsQualityProfile::InitializeL(qualityArray);
	
	CleanupStack::PopAndDestroy(&qualityArray);
	CleanupStack::PopAndDestroy(&fs);
	}
コード例 #2
0
ファイル: POSIX.CPP プロジェクト: cdaffara/symbiandump-os2
GLDEF_C TInt GetFullFile(TFileName& aName, const TText16* upath, RFs& aSession)
// Use GetFullPath to establish the pathname, then add the filename onto the end
	{
	TParse path;
	TInt err = GetFullPath(path,upath,aSession,&aName);
	if (err!=KErrNone)
		return err;
	// Wildcard drive letter for searching across drives
	if (upath[0]==L'?' && upath[1]==L':')
		{
		TFindFile search(aSession);
		err=search.FindByDir(aName,path.Path());
		if (!err)
			{
			aName=search.File();
			return KErrNone;
			}
		}
	err = path.SetNoWild(path.DriveAndPath(),NULL,&aName);
	if (!err)
		aName = path.FullName();
	return err;
	}
コード例 #3
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);
            );
            }
コード例 #4
0
/**
 *
 * Open a log.
 *
 * @param	"const TDesC& aLogName"
 *			The log name
 *
 * @param	"TInt aLogMode"
 *			The log mode (as bitmask of TTestFrameworkLogMode)
 *
 * @xxxx
 *
 */
void CTestFrameworkServer::OpenLogL(const TDesC& aLogName, TInt aLogMode)
{
    // NB we need to check if a console is already open - if so, we do NOT
    // create another one. Ditto with file / port.

    if(aLogMode & ELogToConsole)
    {
        if(!iConsole)
        {
            iConsole = CServerConsole::NewL(aLogName);

            CConsoleBase* theConsole = iConsole->Console();
            theConsole->Printf(_L("%S : Server log starting\n"), &aLogName);

            iLogMode |= ELogToConsole;

            if (aLogMode & ELogConsoleFull)
                iLogMode |= ELogConsoleFull;
        }
    }

    // NB relative paths will not work with TParse (there is no file server open).
    // Exception is a bare filename (with no path) : this will be found in root of C:

    // NOTE! We have no mechanism to notify this error. The console will display
    // and then exit. The log file cannot be opened.

    // TO BE ENHANCED - if console is made active, then we can pause

    if(aLogMode & ELogToFile)
    {
        if(!iFileLogger)
        {
            TRAPD(err, iFileLogger = CFileLogger::NewL());
            if(err != KErrNone)
            {
                // if we can't create a logger, we panic
                User::Panic(_L("TestFrameworkServer"), 1);
            }

            _LIT(KLogPath, "C:\\Logs\\TestResults");
            _LIT(KDefault, "C:\\.htm");

            TParse parseLogName;
            parseLogName.Set(aLogName, NULL, NULL);

            TFileName logFilePath;
            logFilePath = KLogPath;

            if(parseLogName.PathPresent())
                logFilePath.Append(parseLogName.Path());
            else
                logFilePath.Append(_L("\\"));


            // overwrite extension if supplied with .htm
            TParse logFileFullName;
            TInt returnCode = logFileFullName.Set(KDefault, &logFilePath, &aLogName);
            if (returnCode == KErrNone)
            {
                TInt ret = iFileLogger->Connect();
                if (ret == KErrNone)
                {
                    iFileLogger->CreateLog(logFilePath, logFileFullName.NameAndExt());
                    iLogMode |= ELogToFile;
                }
            }
        }
    }

    if(aLogMode & ELogToPort)
    {
        // RDebug::Print will deal with the serial port, we don't do anything special here
        iLogMode |= ELogToPort;
    }
}