sl@0: /* sl@0: * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @test sl@0: @internalComponent sl@0: sl@0: This contains CT_FsData sl@0: */ sl@0: sl@0: // User includes sl@0: #include "T_FsData.h" sl@0: #include "T_SfSrvServer.h" sl@0: #include "DataWrapperBase.h" sl@0: sl@0: /*@{*/ sl@0: sl@0: _LIT(KMessageSlots, "messageSlots"); sl@0: _LIT(KPath, "path"); sl@0: _LIT(KAddress, "address"); sl@0: _LIT(KType, "type"); sl@0: _LIT(KAll, "all"); sl@0: _LIT(KResources, "resources"); sl@0: _LIT(KNotify, "notify"); sl@0: _LIT(KInRom, "inRom"); sl@0: _LIT(KThreshold, "threshold"); sl@0: _LIT(KDrive, "drive"); sl@0: _LIT(KFunctionId, "functionId"); sl@0: _LIT(KAdd, "add"); sl@0: _LIT(KSub, "sub"); sl@0: _LIT(KUseFreeSpace, "use_free_space"); sl@0: _LIT(KVersionName, "name"); sl@0: _LIT(KVersionBuild, "build"); sl@0: _LIT(KVersionMajor, "major"); sl@0: _LIT(KVersionMinor, "minor"); sl@0: _LIT(KIndex, "index"); sl@0: _LIT(KParam1, "param1"); sl@0: _LIT(KParam2, "param2"); sl@0: _LIT(KFile, "file"); sl@0: _LIT(KCount, "count"); sl@0: sl@0: /// Commands sl@0: _LIT(KCmdNew, "new"); sl@0: _LIT(KCmdClose, "Close"); sl@0: _LIT(KCmdDestructor, "~"); sl@0: _LIT(KCmdConnect, "Connect"); sl@0: _LIT(KCmdVersion, "Version"); sl@0: _LIT(KCmdNotifyChange, "NotifyChange"); sl@0: _LIT(KCmdNotifyChangeCancel, "NotifyChangeCancel"); sl@0: _LIT(KCmdNotifyDiskSpace, "NotifyDiskSpace"); sl@0: _LIT(KCmdNotifyDiskSpaceCancel, "NotifyDiskSpaceCancel"); sl@0: _LIT(KCmdIsRomAddress, "IsRomAddress"); sl@0: _LIT(KCmdResourceCountMarkStart, "ResourceCountMarkStart"); sl@0: _LIT(KCmdResourceCountMarkEnd, "ResourceCountMarkEnd"); sl@0: _LIT(KCmdResourceCount, "ResourceCount"); sl@0: _LIT(KCmdGetNotifyUser, "GetNotifyUser"); sl@0: _LIT(KCmdSetNotifyUser, "SetNotifyUser"); sl@0: _LIT(KCmdSetNotifyChange, "SetNotifyChange"); sl@0: _LIT(KCmdLoaderHeapFunction, "LoaderHeapFunction"); sl@0: _LIT(KCmdInitialisePropertiesFile, "InitialisePropertiesFile"); sl@0: /*@}*/ sl@0: sl@0: CT_FsData* CT_FsData::NewL() sl@0: /** sl@0: * Two phase constructor sl@0: */ sl@0: { sl@0: CT_FsData* ret = new (ELeave) CT_FsData(); sl@0: CleanupStack::PushL(ret); sl@0: ret->ConstructL(); sl@0: CleanupStack::Pop(ret); sl@0: return ret; sl@0: } sl@0: sl@0: CT_FsData::CT_FsData() sl@0: /** sl@0: * Protected constructor. First phase construction sl@0: */ sl@0: { sl@0: } sl@0: sl@0: void CT_FsData::ConstructL() sl@0: /** sl@0: * Protected constructor. Second phase construction sl@0: */ sl@0: { sl@0: sl@0: } sl@0: sl@0: CT_FsData::~CT_FsData() sl@0: /** sl@0: * Destructor. sl@0: */ sl@0: { sl@0: DoCleanup(); sl@0: sl@0: iNotifyChange.ResetAndDestroy(); sl@0: iNotifyDiskSpace.ResetAndDestroy(); sl@0: iNotifyDismount.ResetAndDestroy(); sl@0: iStartupInitComplete.ResetAndDestroy(); sl@0: } sl@0: sl@0: void CT_FsData::DoCleanup() sl@0: /** sl@0: * Contains cleanup implementation sl@0: */ sl@0: { sl@0: //Deleting RFs. sl@0: if(iFs != NULL) sl@0: { sl@0: INFO_PRINTF1(_L("Deleting current RFs")); sl@0: delete iFs; sl@0: iFs = NULL; sl@0: } sl@0: } sl@0: sl@0: TAny* CT_FsData::GetObject() sl@0: /** sl@0: * Return a pointer to the object that the data wraps sl@0: * sl@0: * @return pointer to the object that the data wraps sl@0: */ sl@0: { sl@0: return iFs; sl@0: } sl@0: sl@0: TUint64 CT_FsData::ThreadId() sl@0: { sl@0: RThread currentThread; sl@0: return currentThread.Id().Id(); sl@0: } sl@0: sl@0: TBool CT_FsData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) sl@0: /** sl@0: * Process a command read from the ini file sl@0: * sl@0: * @param aCommand the command to process sl@0: * @param aSection the entry in the ini file requiring the command to be processed sl@0: * sl@0: * @return ETrue if the command is processed sl@0: */ sl@0: { sl@0: TBool retVal = ETrue; sl@0: if (aCommand == KCmdNew) sl@0: { sl@0: DoCmdNewL(); sl@0: } sl@0: else if (aCommand == KCmdClose) sl@0: { sl@0: DoCmdClose(); sl@0: } sl@0: else if (aCommand == KCmdDestructor) sl@0: { sl@0: DoCmdDestructor(); sl@0: } sl@0: else if (aCommand == KCmdConnect) sl@0: { sl@0: DoCmdConnect(aSection); sl@0: } sl@0: else if (aCommand == KCmdVersion) sl@0: { sl@0: DoCmdVersion(aSection); sl@0: } sl@0: else if (aCommand == KCmdNotifyChange) sl@0: { sl@0: DoCmdNotifyChangeL(aSection, aAsyncErrorIndex); sl@0: } sl@0: else if (aCommand == KCmdNotifyChangeCancel) sl@0: { sl@0: DoCmdNotifyChangeCancel(aSection); sl@0: } sl@0: else if (aCommand == KCmdNotifyDiskSpace) sl@0: { sl@0: DoCmdNotifyDiskSpaceL(aSection, aAsyncErrorIndex); sl@0: } sl@0: else if (aCommand == KCmdNotifyDiskSpaceCancel) sl@0: { sl@0: DoCmdNotifyDiskSpaceCancel(aSection); sl@0: } sl@0: else if (aCommand == KCmdIsRomAddress) sl@0: { sl@0: DoCmdIsRomAddress(aSection); sl@0: } sl@0: else if (aCommand == KCmdResourceCountMarkStart) sl@0: { sl@0: DoCmdResourceCountMarkStart(); sl@0: } sl@0: else if (aCommand == KCmdResourceCountMarkEnd) sl@0: { sl@0: DoCmdResourceCountMarkEnd(); sl@0: } sl@0: else if (aCommand == KCmdResourceCount) sl@0: { sl@0: DoCmdResourceCount(aSection); sl@0: } sl@0: else if (aCommand == KCmdGetNotifyUser) sl@0: { sl@0: DoCmdGetNotifyUser(aSection); sl@0: } sl@0: else if (aCommand == KCmdSetNotifyUser) sl@0: { sl@0: DoCmdSetNotifyUser(aSection); sl@0: } sl@0: else if (aCommand == KCmdLoaderHeapFunction) sl@0: { sl@0: DoCmdLoaderHeapFunctionL(aSection); sl@0: } sl@0: else if (aCommand == KCmdSetNotifyChange) sl@0: { sl@0: DoCmdSetNotifyChange(aSection); sl@0: } sl@0: else if (aCommand == KCmdInitialisePropertiesFile) sl@0: { sl@0: DoCmdInitialisePropertiesFile(aSection); sl@0: } sl@0: else sl@0: { sl@0: if (!DoCommandDrivesL(aCommand, aSection, aAsyncErrorIndex)) sl@0: { sl@0: if (!DoCommandMountsL(aCommand, aSection, aAsyncErrorIndex)) sl@0: { sl@0: if (!DoCommandFilesL(aCommand, aSection, aAsyncErrorIndex)) sl@0: { sl@0: retVal = EFalse; sl@0: } sl@0: } sl@0: } sl@0: } sl@0: return retVal; sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdNewL() sl@0: /** Creates new RFs class instance */ sl@0: { sl@0: INFO_PRINTF1(_L("Create new RFs class instance")); sl@0: sl@0: //Deletes previous RFs class instance if it was already created. sl@0: DoCleanup(); sl@0: sl@0: // do create sl@0: TRAPD(err, iFs = new (ELeave) RFs()); sl@0: if ( err!=KErrNone ) sl@0: { sl@0: ERR_PRINTF2(_L("new error %d"), err); sl@0: SetError( err ); sl@0: } sl@0: } sl@0: sl@0: void CT_FsData::DoCmdClose() sl@0: /** Close RFs handle */ sl@0: { sl@0: INFO_PRINTF1(_L("Closing RFs")); sl@0: iFs->Close(); sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdDestructor() sl@0: /** Destroy RFs the object */ sl@0: { sl@0: INFO_PRINTF1(_L("Destroying the RFs object")); sl@0: DoCleanup(); sl@0: } sl@0: sl@0: void CT_FsData::DoCmdConnect(const TDesC& aSection) sl@0: /** Connects a client to the file server */ sl@0: { sl@0: sl@0: TInt messageSlots = KFileServerDefaultMessageSlots; sl@0: GetIntFromConfig(aSection, KMessageSlots, messageSlots); sl@0: sl@0: TInt err = iFs->Connect(messageSlots); sl@0: INFO_PRINTF2(_L("Call Connect(messageSlots = %d)"), messageSlots); sl@0: sl@0: if ( err!=KErrNone ) sl@0: { sl@0: ERR_PRINTF2(_L("Connect() error %d"), err); sl@0: SetError( err ); sl@0: } sl@0: } sl@0: sl@0: void CT_FsData::DoCmdVersion(const TDesC& aSection) sl@0: /** Gets the client side version number */ sl@0: { sl@0: sl@0: TVersion version=iFs->Version(); sl@0: TVersionName versionName = version.Name(); sl@0: INFO_PRINTF2(_L("Version name : %S"), &versionName); sl@0: INFO_PRINTF2(_L("Version build : %d"), (TInt)version.iBuild); sl@0: INFO_PRINTF2(_L("Version major : %d"), (TInt)version.iMajor); sl@0: INFO_PRINTF2(_L("Version minor : %d"), (TInt)version.iMinor); sl@0: sl@0: TPtrC name; sl@0: if ( GET_OPTIONAL_STRING_PARAMETER(KVersionName, aSection, name)) sl@0: { sl@0: if ( name != version.Name() ) sl@0: { sl@0: ERR_PRINTF3(_L("Name does not match expected name: %S, %S"), &name, &versionName); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: TInt intTemp; sl@0: if ( GET_OPTIONAL_INT_PARAMETER(KVersionBuild, aSection, intTemp) ) sl@0: { sl@0: if ( intTemp != version.iBuild ) sl@0: { sl@0: ERR_PRINTF1(_L("Build does not match expected build")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: if ( GET_OPTIONAL_INT_PARAMETER(KVersionMajor, aSection, intTemp) ) sl@0: { sl@0: if ( intTemp != version.iMajor ) sl@0: { sl@0: ERR_PRINTF1(_L("Major does not match expected major")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: if ( GET_OPTIONAL_INT_PARAMETER(KVersionMinor, aSection, intTemp) ) sl@0: { sl@0: if ( intTemp != version.iMinor ) sl@0: { sl@0: ERR_PRINTF1(_L("Minor does not match expected minor")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: if (version.Name() == _L("") && version.iBuild == 0 && version.iMajor == 0 && version.iMinor == 0) sl@0: { sl@0: ERR_PRINTF1(_L("Some version fields are not set!")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: void CT_FsData::DoCmdNotifyChangeL(const TDesC& aSection, const TInt aAsyncErrorIndex) sl@0: /** Requests a notification of change to files or directories */ sl@0: { sl@0: TNotifyType type = ENotifyAll; sl@0: TPtrC typeTemp; sl@0: TBool dataOk = ETrue; sl@0: sl@0: if ( GET_MANDATORY_STRING_PARAMETER(KType, aSection, typeTemp) ) sl@0: { sl@0: if(!ConvertToNotifyType(typeTemp, type)) sl@0: { sl@0: TInt typeNumber; sl@0: if(GetIntFromConfig(aSection, KType(), typeNumber)) sl@0: { sl@0: type = (TNotifyType)typeNumber; sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF3(_L("NotifyChange() incorrect parameter %S in %S"), &typeTemp, &KType()); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: sl@0: TInt count=1; sl@0: GET_OPTIONAL_INT_PARAMETER(KCount, aSection, count); sl@0: sl@0: if(dataOk) sl@0: { sl@0: CT_ActiveNotifyChange* active = CT_ActiveNotifyChange::NewLC(count, aAsyncErrorIndex, *this); sl@0: iNotifyChange.AppendL(active); sl@0: CleanupStack::Pop(active); sl@0: sl@0: TPtrC path; sl@0: if ( GetStringFromConfig(aSection, KPath(), path) ) sl@0: { sl@0: iFs->NotifyChange(type, active->iStatus, path); sl@0: INFO_PRINTF1(_L("NotifyChange(TNotifyType, TRequestStatus, const TDesC)")); sl@0: } sl@0: else sl@0: { sl@0: iFs->NotifyChange(type, active->iStatus); sl@0: INFO_PRINTF1(_L("NotifyChange(TNotifyType TRequestStatus)")); sl@0: } sl@0: sl@0: active->Activate(); sl@0: IncOutstanding(); sl@0: } sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdNotifyChangeCancel(const TDesC& aSection) sl@0: /** Cancels outstanding request(s) for notification of change to files or directories */ sl@0: { sl@0: TBool all = ETrue; sl@0: sl@0: if ( GET_MANDATORY_BOOL_PARAMETER(KAll, aSection, all) ) sl@0: { sl@0: if(all) sl@0: { sl@0: // Cancels all outstanding requests. sl@0: iFs->NotifyChangeCancel(); sl@0: INFO_PRINTF1(_L("NotifyChangeCancel()")); sl@0: } sl@0: else sl@0: { sl@0: // Cancels a specific outstanding request sl@0: TInt index=0; sl@0: GetIntFromConfig(aSection, KIndex(), index); sl@0: sl@0: iFs->NotifyChangeCancel(iNotifyChange[index]->iStatus); sl@0: INFO_PRINTF1(_L("NotifyChangeCancel(TRequestStatus)")); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_FsData::DoCmdNotifyDiskSpaceL(const TDesC& aSection, const TInt aAsyncErrorIndex) sl@0: /** Requests notification when the free disk space on the specified drive crosses the specified threshold value */ sl@0: { sl@0: //Get drive number from config sl@0: TDriveNumber drive = EDriveA; sl@0: TBool dataOk = ETrue; sl@0: if (!GetDriveNumberFromConfig(aSection, KDrive, drive)) sl@0: { sl@0: ERR_PRINTF2(_L("No %S"), &KDrive()); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: sl@0: TBool useFreeSpace = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KUseFreeSpace, aSection, useFreeSpace); sl@0: sl@0: TInt64 threshold = 0; sl@0: //Defining treshold by free space sl@0: if(useFreeSpace) sl@0: { sl@0: threshold = iVolumeInfo.iFree; sl@0: //For Calculation free-temp(_sub), free+temp(_add) sl@0: TInt temp; sl@0: if(GetIntFromConfig(aSection, KAdd, temp)) sl@0: { sl@0: threshold += temp; sl@0: temp = 0; sl@0: } sl@0: if(GetIntFromConfig(aSection, KSub, temp)) sl@0: { sl@0: threshold -= temp; sl@0: temp = 0; sl@0: } sl@0: } sl@0: //Defining treshold by some value sl@0: else sl@0: { sl@0: TPtrC thold; sl@0: if(GET_MANDATORY_STRING_PARAMETER(KThreshold, aSection, thold)) sl@0: { sl@0: TLex lex(thold); sl@0: TInt err = lex.Val(threshold); sl@0: if(err) sl@0: { sl@0: ERR_PRINTF1(_L("NotifyDiskSpace() bad treshold value")); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: } sl@0: } sl@0: sl@0: if(dataOk) sl@0: { sl@0: CActiveCallback* active = CActiveCallback::NewLC(*this); sl@0: iNotifyDiskSpace.AppendL(active); sl@0: CleanupStack::Pop(active); sl@0: sl@0: iFs->NotifyDiskSpace(threshold, drive, active->iStatus); sl@0: INFO_PRINTF1(_L("NotifyDiskSpace()")); sl@0: active->Activate(aAsyncErrorIndex); sl@0: IncOutstanding(); sl@0: } sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdNotifyDiskSpaceCancel(const TDesC& aSection) sl@0: /** Cancels a specific outstanding request for free disk space notification */ sl@0: { sl@0: sl@0: TBool all = ETrue; sl@0: sl@0: if(GET_MANDATORY_BOOL_PARAMETER(KAll, aSection, all)) sl@0: { sl@0: if (all) sl@0: { sl@0: //Cancels all outstanding requests. sl@0: iFs->NotifyDiskSpaceCancel(); sl@0: INFO_PRINTF1(_L("NotifyDiskSpaceCancel()")); sl@0: } sl@0: else sl@0: { sl@0: // Cancels a specific outstanding request sl@0: TInt index=0; sl@0: GetIntFromConfig(aSection, KIndex, index); sl@0: sl@0: iFs->NotifyDiskSpaceCancel(iNotifyDiskSpace[index]->iStatus); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_FsData::DoCmdIsRomAddress(const TDesC& aSection) sl@0: /** Tests whether the specified address is in ROM */ sl@0: { sl@0: //reading address sl@0: TUint8* address = NULL; sl@0: TInt intAddress; sl@0: TBool dataOk = ETrue; sl@0: sl@0: if(GetHexFromConfig(aSection, KAddress, intAddress)) sl@0: { sl@0: address = (TUint8*)intAddress; sl@0: } sl@0: else if(iIsFileInRom) sl@0: { sl@0: address = iIsFileInRom; sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF1(_L("Address not specified")); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: if(dataOk) sl@0: { sl@0: INFO_PRINTF2(_L("Address %X"), address); sl@0: //Address of file in ROM sl@0: TBool actual = RFs::IsRomAddress(address); sl@0: INFO_PRINTF2(_L("RFs::IsRomAddress() %d"), actual); sl@0: //Reading expected result sl@0: TBool expected = EFalse; sl@0: if ( GET_OPTIONAL_BOOL_PARAMETER(KInRom, aSection, expected) ) sl@0: { sl@0: if ( expected != actual ) sl@0: { sl@0: ERR_PRINTF1(_L("Expected result does not match actual")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_FsData::DoCmdResourceCountMarkStart() sl@0: /** Marks the start of resource count checking */ sl@0: { sl@0: iFs->ResourceCountMarkStart(); sl@0: INFO_PRINTF1(_L("ResourceCountMarkStart()")); sl@0: } sl@0: sl@0: void CT_FsData::DoCmdResourceCountMarkEnd() sl@0: /** Ends resource count checking */ sl@0: { sl@0: iFs->ResourceCountMarkEnd(); sl@0: INFO_PRINTF1(_L("ResourceCountMarkEnd()")); sl@0: } sl@0: sl@0: void CT_FsData::DoCmdResourceCount(const TDesC& aSection) sl@0: /** Gets the number of currently open resources */ sl@0: { sl@0: TInt resources = iFs->ResourceCount();//Number of resources currently opened sl@0: INFO_PRINTF2(_L("ResourceCount() = %d"), resources); sl@0: sl@0: TInt expectedValue = 0; //Number of resources from config sl@0: if(GetIntFromConfig(aSection, KResources, expectedValue)) sl@0: { sl@0: if (expectedValue != resources) sl@0: { sl@0: ERR_PRINTF3(_L("ResourceCount() %d != %d expected value"), resources, expectedValue); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_FsData::DoCmdGetNotifyUser(const TDesC& aSection) sl@0: /** Tests whether user notification of file read or write failure is in effect */ sl@0: { sl@0: TBool actual = iFs->GetNotifyUser(); sl@0: INFO_PRINTF2(_L("iFs->GetNotifyUser() %d"), actual); sl@0: sl@0: TBool expected = EFalse; sl@0: if ( GET_OPTIONAL_BOOL_PARAMETER(KNotify, aSection, expected) ) sl@0: { sl@0: if ( expected!=actual ) sl@0: { sl@0: ERR_PRINTF1(_L("Expected result does not match actual")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_FsData::DoCmdSetNotifyUser(const TDesC& aSection) sl@0: /** Sets whether the user should be notified of file read or write failure */ sl@0: { sl@0: TBool notify = EFalse; sl@0: sl@0: if(GET_MANDATORY_BOOL_PARAMETER(KNotify, aSection, notify)) sl@0: { sl@0: iFs->SetNotifyUser(notify); sl@0: TPtrC val = notify ? _L("TRUE") : _L("FALSE"); sl@0: INFO_PRINTF2(_L("SetNotifyUser() %S"), &val); sl@0: } sl@0: sl@0: sl@0: } sl@0: sl@0: void CT_FsData::DoCmdLoaderHeapFunctionL(const TDesC& aSection) sl@0: /** returns KErrNotSupported*/ sl@0: { sl@0: TPtrC name; sl@0: TAny* param1 = NULL; sl@0: if(GetStringFromConfig(aSection, KParam1(), name)) sl@0: { sl@0: //param1 = iDataDictionary->GetObject(name); sl@0: } sl@0: sl@0: TAny* param2 = NULL; sl@0: if(GetStringFromConfig(aSection, KParam2(), name)) sl@0: { sl@0: //param2 = iDataDictionary->GetObjectL(name); sl@0: } sl@0: sl@0: TInt functionId = 0; sl@0: if(GET_MANDATORY_INT_PARAMETER(KFunctionId(), aSection, functionId)) sl@0: { sl@0: TInt err = iFs->LoaderHeapFunction(functionId, param1, param2); sl@0: if( err!=KErrNone ) sl@0: { sl@0: ERR_PRINTF2(_L("LoaderHeapFunction() ERROR: %d"), err); sl@0: SetError(err); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_FsData::DoCmdSetNotifyChange(const TDesC& aSection) sl@0: /** Enables/Disables change notification on a per-session basis. */ sl@0: { sl@0: sl@0: TBool notify = EFalse; sl@0: sl@0: if(GET_MANDATORY_BOOL_PARAMETER(KNotify, aSection, notify)) sl@0: { sl@0: TInt err = iFs->SetNotifyChange(notify); sl@0: sl@0: TPtrC val = notify ? _L("TRUE") : _L("FALSE"); sl@0: if (err == KErrNone) sl@0: { sl@0: INFO_PRINTF2(_L("SetNotifyChange() %S"), &val); sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF3(_L("SetNotifyChange() %S, Error: %d"), &val, err); sl@0: SetError(err); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_FsData::DoCmdInitialisePropertiesFile(const TDesC& aSection) sl@0: /** Sets the F32 properties file ONLY in ESTART */ sl@0: { sl@0: TPtrC tempStr; sl@0: if(GET_MANDATORY_STRING_PARAMETER(KFile, aSection, tempStr)) sl@0: { sl@0: TBuf8 buffer; sl@0: buffer.Copy(tempStr); sl@0: TPtrC8 iniFilePtr(buffer); sl@0: INFO_PRINTF2(_L("InitialisePropertiesFile() %S"), &tempStr); sl@0: sl@0: TInt err = iFs ->InitialisePropertiesFile(iniFilePtr); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("InitialisePropertiesFile() Error: %d"), err); sl@0: SetError(err); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_FsData::RunL(CActive* aActive, TInt aIndex) sl@0: { sl@0: INFO_PRINTF1(_L("CT_FsData::RunL Called")); sl@0: TBool foundActiveObject = EFalse; sl@0: TInt index=0; sl@0: TInt count=0; sl@0: TBool completed=ETrue; sl@0: sl@0: // See if it is in iNotifyChange sl@0: count=iNotifyChange.Count(); sl@0: for( index=0; (indexDecCount()>0 ) sl@0: { sl@0: completed=EFalse; sl@0: iNotifyChange[index]->Activate(); sl@0: } sl@0: else sl@0: { sl@0: iNotifyChange.Remove(index); sl@0: } sl@0: } sl@0: } sl@0: sl@0: // See if it is in iNotifyDiskSpace sl@0: count=iNotifyDiskSpace.Count(); sl@0: for( index=0; (indexiStatus.Int(); sl@0: if( err != KErrNone ) sl@0: { sl@0: ERR_PRINTF2(_L("RunL Error %d"), err); sl@0: SetAsyncError( aIndex, err ); sl@0: } sl@0: sl@0: if ( completed ) sl@0: { sl@0: // Reset the outstanding request state sl@0: delete aActive; sl@0: DecOutstanding(); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF1(_L("Stray RunL signal")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: void CT_FsData::DoCancel(CActive* aActive, TInt aIndex) sl@0: { sl@0: TBool foundActiveObject = EFalse; sl@0: sl@0: TInt index=0; sl@0: TInt count=0; sl@0: sl@0: // See if it is in iNotifyChange sl@0: count=iNotifyChange.Count(); sl@0: for( index=0; (indexiStatus.Int(); sl@0: if( err != KErrNone ) sl@0: { sl@0: ERR_PRINTF2(_L("DoCancel Error %d"), err); sl@0: SetAsyncError( aIndex, err ); sl@0: } sl@0: sl@0: // Reset the outstanding request state sl@0: DecOutstanding(); sl@0: sl@0: delete aActive; sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF1(_L("Stray DoCancel signal")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: TBool CT_FsData::ConvertToNotifyType(const TDesC& aNotifyTypeStr, TNotifyType& aNotifyType) sl@0: { sl@0: TBool ret = ETrue; sl@0: if(aNotifyTypeStr == _L("ENotifyAll")) sl@0: { sl@0: aNotifyType = ENotifyAll; sl@0: } sl@0: else if(aNotifyTypeStr == _L("ENotifyEntry")) sl@0: { sl@0: aNotifyType = ENotifyEntry; sl@0: } sl@0: else if(aNotifyTypeStr == _L("ENotifyFile")) sl@0: { sl@0: aNotifyType = ENotifyFile; sl@0: } sl@0: else if(aNotifyTypeStr == _L("ENotifyDir")) sl@0: { sl@0: aNotifyType = ENotifyDir; sl@0: } sl@0: else if(aNotifyTypeStr == _L("ENotifyAttributes")) sl@0: { sl@0: aNotifyType = ENotifyAttributes; sl@0: } sl@0: else if(aNotifyTypeStr == _L("ENotifyWrite")) sl@0: { sl@0: aNotifyType = ENotifyWrite; sl@0: } sl@0: else if(aNotifyTypeStr == _L("ENotifyDisk")) sl@0: { sl@0: aNotifyType = ENotifyDisk; sl@0: } sl@0: //For COnverting data ENotifyFile|ENotifyDir sl@0: else sl@0: { sl@0: TInt location=aNotifyTypeStr.Match(_L("*|*")); sl@0: if( location!=KErrNotFound ) sl@0: { sl@0: //Converting Left part of the data sl@0: TPtrC tempStr=aNotifyTypeStr.Left(location); sl@0: ret=ConvertToNotifyType(tempStr, aNotifyType); sl@0: sl@0: //Converting right data can be with another "|" sl@0: tempStr.Set(aNotifyTypeStr.Mid(location+1)); sl@0: sl@0: TNotifyType notifyTypeTmp; sl@0: if ( ConvertToNotifyType(tempStr, notifyTypeTmp) ) sl@0: { sl@0: aNotifyType =(TNotifyType)((TInt)aNotifyType|(TInt)notifyTypeTmp); sl@0: } sl@0: else sl@0: { sl@0: ret = EFalse; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ret = EFalse; sl@0: } sl@0: } sl@0: sl@0: return ret; sl@0: }