/** Delete entry in directory */ LOCAL_C TInt DeleteEntryAccess2(TAny* ) { RFs fs; TInt r = fs.Connect(); TBuf<100> dirfile; TBuf<50> filename; RFile file; RTest test(_L("test 2")); fs.SetSessionPath(gSessionPath); filename.Format(KDeleteMe2, gT2); dirfile = gDelEntryDir2; dirfile.Append(filename); client.Signal(); FOREVER { if(!gKillMe) { r = file.Create(fs, dirfile, EFileShareAny|EFileWrite); if(r == KErrAlreadyExists) r=file.Open(fs, dirfile, EFileShareAny|EFileWrite); file.Close(); FailIfError(r); r = fs.Delete(dirfile); if((r != KErrNone) && (r != KErrInUse)) { test.Printf(_L("error = %d\n"), r); } test(r == KErrNone || r == KErrInUse); } } }
TInt CFloggerTest028_Sync_Static_WriteFormatVUni::DoTestCheckWriteL() { RFile logFile; HBufC8* hBuffer; TInt listfilesize,returnCode; RFs fileSystem; //For file operation create a file system TBuf8<KTestMessageSize> testData; //To hold the test descriptor User::LeaveIfError(fileSystem.Connect()); //Open the file in the read mode User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); CleanupClosePushL(logFile); User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file hBuffer = HBufC8::New(listfilesize); //Allocate the buffer CleanupStack::PushL(hBuffer); TPtr8 ptrString = hBuffer->Des(); ; //To access the buffer // Read from position 0: start of file User::LeaveIfError(returnCode = logFile.Read(ptrString)); testData.Copy(KTestMessageOneParamExpected); //Copy the test descriptor returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read //from the file CleanupStack::PopAndDestroy(hBuffer); CleanupStack::PopAndDestroy(); //logFile if (returnCode > 0) return KErrNone; else return KErrNotFound; }
void CVersitTest::StreamInL() //Convert the iVersit into stream format, save it as "TTVersitIn" //and internalize it as a CVersitParser { RFs fsSession; User::LeaveIfError(fsSession.Connect()); CFileStore* store = CDirectFileStore::ReplaceLC(fsSession,_L("c:\\TTVersit2"),EFileWrite); store->SetTypeL(KDirectFileStoreLayoutUid); RStoreWriteStream outstream; TStreamId id = outstream.CreateLC(*store); TInt length=iVersit.Length(); for (TInt ii=0; ii<length; ii++) outstream.WriteInt8L(iVersit[ii]); outstream.CommitL(); CleanupStack::PopAndDestroy(); store->SetRootL(id); store->CommitL(); CleanupStack::PopAndDestroy(); store = CDirectFileStore::OpenLC(fsSession,_L("c:\\TTVersit2"),EFileRead); //retrieve stream RStoreReadStream instream; instream.OpenLC(*store,store->Root()); iParser->InternalizeL(instream); CleanupStack::PopAndDestroy(2); //store + stream }
void CCentRepToolSession::PerformRFSL() { RDEBUG("CentRepToolSession: Restore factory setting operation started"); //RFS tasks in centrep tool // 1. restory setting enforcements // 2. remove backup and temp files from private directory //clean private directory RFs rfs; TInt err = rfs.Connect(); if( err != KErrNone ) { RDEBUG_2("**** CCentRepToolSession::PerformRFSL() - failed to connect to RFs: %d", err ); return; } CleanupClosePushL( rfs); TBuf<100> privatePath; err = rfs.PrivatePath( privatePath); if ( err == KErrNone) { //remove files from private directory, also backups CFileMan* file = CFileMan::NewL( rfs); privatePath.Append(_L("*.*")); err = file->Delete( privatePath, CFileMan::ERecurse); delete file; } CleanupStack::PopAndDestroy( &rfs); RDEBUG("CentRepToolSession: Restore factory setting operation finished"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // TInt CPhoneRingingTone::CheckToneFileSize( const TDesC& aFile, TInt aSizeLimitKB ) { __LOGMETHODSTARTEND( EPhoneControl, "CPhoneRingingtone::CheckToneFileSize()" ); //return KErrNone; // Get file size TInt size = 0; RFs fs; TInt error = fs.Connect(); TEntry entry; if ( KErrNone == error ) { if (KErrNone == fs.Entry( aFile, entry )) { size = entry.iSize; } // Check aSizeLimitKB *= Kkilo; if ( aSizeLimitKB && size > aSizeLimitKB ) { error = KErrTooBig; } } fs.Close(); __PHONELOG1( EBasic, EPhoneControl, "CPhoneRingingtonePlayer::CheckToneFileSize - size (%d)", size ); return error; }
/** @SYMTestCaseID SYSLIB-XML-CT-3738 @SYMTestCaseDesc Parser copes with leaving content handler. @SYMTestPriority Medium @SYMTestActions Checks that the parser copes with a leave from a content handler callback. @SYMTestExpectedResults Tests pass. @SYMPREQ PREQ230 */ LOCAL_C void CallbackLeaveTestL() { TSimpleContentHandler contentHandler; contentHandler.iLeaveOnStartElement = ETrue; CParser* parser = CParser::NewLC(KParserDataType, contentHandler); RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); TRAPD(err, ParseL(*parser, fs, KSimpleTestFile())); User::LeaveIfError(err); // For OOM testing test(contentHandler.iNumElements==1); test(err==TSimpleContentHandler::KExpectedLeaveCode); contentHandler.iLeaveOnStartElement = EFalse; ParseL(*parser, fs, KSimpleTestFile()); test(contentHandler.iNumElements==6); CleanupStack::PopAndDestroy(2); }
static void DeleteTestDirL() { RFs fsSession; TInt err = fsSession.Connect(); if(err == KErrNone) { CleanupClosePushL(fsSession); RDebug::Print(_L("Deleting \"%S\" directory.\n"), &KOpaqueDirectory); CFileMan* fileMan = CFileMan::NewL(fsSession); CleanupStack::PushL(fileMan); TInt err = fileMan->RmDir(KOpaqueDirectory); if(err == KErrPathNotFound) { err = KErrNone; } User::LeaveIfError(err); CleanupStack::PopAndDestroy(fileMan); CleanupStack::PopAndDestroy(&fsSession); } else { RDebug::Print(_L("Error %d connecting file session. Directory: %S.\n"), err, &KOpaqueDirectory); } }
void CDummyUsbDevice::OpenFileL() { RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); TFindFile ff(fs); User::LeaveIfError(ff.FindByDir(_L("\\system\\data\\t_charging.txt"),KNullDesC)); RFile file; TInt size; User::LeaveIfError(file.Open(fs,ff.File(),EFileStreamText|EFileRead|EFileShareReadersOnly)); CleanupClosePushL(file); User::LeaveIfError(file.Size(size)); iText = REINTERPRET_CAST(TText8*, User::AllocL(size)); iPtr.Set(iText, size/sizeof(TText8), size/sizeof(TText8)); TPtr8 dest(REINTERPRET_CAST(TUint8*,iText), 0, size); User::LeaveIfError(file.Read(dest)); CleanupStack::PopAndDestroy(); // file CleanupStack::PopAndDestroy(); // fs }
EXPORT_C HBufC8* TcLog::ReadLogLC() { RFs fs; if( fs.Connect() != KErrNone ) { return NULL; } RFile in; if( !in.Open( fs, KLogFile, EFileRead | EFileShareAny ) ) { TInt fileSize( 0 ); in.Size( fileSize ); HBufC8* logText = HBufC8::NewLC( fileSize ); TPtr8 logTextPtr( logText->Des() ); in.Read( logTextPtr ); in.Close(); fs.Close(); return logText; } fs.Close(); return NULL; }
/*Way to Find AppPrivatePath (A Path where an application can store its private data) */ static TInt GetPrivatePath(TFileName& privatePath) { TFileName KPath; RFs fsSession; TInt result; result = fsSession.Connect(); if (result != KErrNone) { return result; } fsSession.PrivatePath(KPath); TFindFile findFile(fsSession); privatePath = KPath; result = findFile.FindByDir(KPath, KNullDesC); if (result == KErrNone) { privatePath = findFile.File(); } fsSession.Close(); return result; }
void CDeploymentComponentData::LoadDataL() const { if (iDataFileName.Length() > 0) { RFs fs; User::LeaveIfError(fs.Connect() ); CleanupClosePushL(fs); // 1 RFile file; TFileName fileName; fileName.Copy(iDataFileName); TInt err(file.Open(fs, fileName, EFileRead) ); if (err == KErrNone) { CleanupClosePushL(file); // 2 TInt fsize; User::LeaveIfError(file.Size(fsize) ); iData = HBufC8::NewL(fsize); TPtr8 ptr(iData->Des() ); User::LeaveIfError(file.Read(ptr) ); CleanupStack::PopAndDestroy( &file); } else { RDEBUG_3( "ERROR Leaving CDeploymentComponentData::Data - SEVERE Could not open data file '%S': %d!", &fileName, err ); User::Leave(KErrNotFound) ; } CleanupStack::PopAndDestroy( &fs); } else { RDEBUG( "ERROR Leaving CDeploymentComponentData::LoadDataL() - No file to load!" ); User::Leave(KErrNotFound) ; } }
TInt CDeploymentComponentData::DataLengthL() const { TInt ret( 0); if (iData == NULL) { if (iDataFileName.Length() > 0) { RFs fs; User::LeaveIfError(fs.Connect() ); CleanupClosePushL(fs); // 1 TEntry entry; TFileName fileName; fileName.Copy(iDataFileName); User::LeaveIfError(fs.Entry(fileName, entry) ); ret = entry.iSize; CleanupStack::PopAndDestroy( &fs); } } else { ret = iData->Length(); } return ret; }
TInt CSimulateMessageServerSession::ReadDataFromFile(RSimMsgDataArray& aArray) { RFs rfs; User::LeaveIfError(rfs.Connect()); TFileName filename; // rfs.PrivatePath(filename); filename.Append(iServer.iPath); filename.Append(KDataFile); RFile file; TInt err = file.Open(rfs, filename, EFileRead); if (KErrNone != err) { return err; } CleanupClosePushL(file); //꾸鱗 TInt size; file.Size(size); HBufC8* buffer = HBufC8::NewL(size); TPtr8 ptr = buffer->Des(); file.Read(ptr); ParseDataBuffer(buffer,aArray); delete buffer; CleanupStack::PopAndDestroy(); rfs.Close(); return KErrNone; }
Vector<String> PluginDatabase::defaultPluginDirectories() { Vector<String> directories; //find the installation drive TDriveList drivelist; TChar driveLetter; RFs fsSession; if (fsSession.Connect() == KErrNone && fsSession.DriveList(drivelist) == KErrNone) { for (TInt driveNumber = EDriveA; driveNumber <= EDriveZ; driveNumber++) { if (drivelist[driveNumber] && fsSession.DriveToChar(driveNumber, driveLetter) == KErrNone) { QString driveStringValue(QChar((uint)driveLetter.GetUpperCase())); QString stubDirPath; stubDirPath.append(driveStringValue); stubDirPath.append(QT_PLUGIN_FOLDER); if (QFileInfo(stubDirPath).exists()) directories.append(stubDirPath); } } } fsSession.Close(); return directories; }
// --------------------------------------------------------- // CPosTp56::CreateDatabasesL // // (other items were commented in a header). // --------------------------------------------------------- // void CPosTp56::CreateDatabasesL() { // Paths will need to be changed to the secure dbms path when security is implemented _LIT(KDefaultDbPath, "c:\\system\\data\\eposlm.ldb"); _LIT(KDb1Path, "c:\\system\\data\\eposlm1.ldb"); _LIT(KDb2Path, "c:\\system\\data\\eposlm2.ldb"); _LIT(KDb3Path, "c:\\system\\data\\eposlm3.ldb"); CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); CleanupStack::PushL(lmd); if (lmd->IsInitializingNeeded()) { ExecuteAndDeleteLD(lmd->InitializeL()); } CleanupStack::PopAndDestroy(lmd); RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); fs.Delete(KExportFile); CFileMan* fileMan = CFileMan::NewL(fs); CleanupStack::PushL(fileMan); User::LeaveIfError(fileMan->Copy(KDefaultDbPath, KDb1Path, CFileMan::EOverWrite)); User::LeaveIfError(fileMan->Copy(KDefaultDbPath, KDb2Path, CFileMan::EOverWrite)); User::LeaveIfError(fileMan->Copy(KDefaultDbPath, KDb3Path, CFileMan::EOverWrite)); CleanupStack::PopAndDestroy(2, &fs); }
CFbsBitmap* CMobiStegoChooseImgView::loadImageL() { RFs fs; TRequestStatus status; CFbsBitmap* bitmap = NULL; CImageDecoder* aImageDecoder = NULL; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); RFbsSession::Connect(fs); RFbsSession* rfbs = RFbsSession::GetSession(); aImageDecoder = CImageDecoder::FileNewL(fs, _L("c:\\Data\\Images\\red.jpg")); CleanupStack::PushL(aImageDecoder); bitmap = new (ELeave) CFbsBitmap(); CleanupStack::PushL(bitmap); TSize sizeImage = aImageDecoder->FrameInfo().iOverallSizeInPixels; TInt aa = KErrCouldNotConnect;//////INDAGA!!!!!!!!!!!!!!!! TInt ppp = bitmap->Create(sizeImage, aImageDecoder->FrameInfo().iFrameDisplayMode); aImageDecoder->Convert(&status, *bitmap); CleanupStack::Pop(3); return bitmap; /*CImageDecoder* iImageDecoder = CImageDecoder::FileNewL( iFs, aFileName ); // create the destination bitmap result = new (ELeave) CFbsBitmap(); result->Create( iImageDecoder->FrameInfo().iOverallSizeInPixels, iImageDecoder->FrameInfo().iFrameDisplayMode ); // start conversion to bitmap iImageDecoder->Convert( &iStatus, *result ); return result;*/ }
void CMtfTestActionOpenTempStoreFile::ExecuteActionL() { TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionOpenTempStoreFile); // Obtain the input parameters TMsvId paramEntryId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(0)); RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); RMsvServerSession serverSession; serverSession.Connect(fs); CleanupClosePushL(serverSession); RFile file; serverSession.OpenTempStoreFileL(paramEntryId,file); CleanupClosePushL(file); _LIT8(KOpenTempStoreFileTestData,"This is a test data for temporary store file"); TInt error = file.Write(0,KOpenTempStoreFileTestData); if(error) { TestCase().ERR_PRINTF2(_L("Error writing to temporary store file , Error = %d"), error); TestCase().SetTestStepResult(EFail); } else { TestCase().INFO_PRINTF1(_L("Test data successfully written to temporary store file")); } // Close the handles CleanupStack::PopAndDestroy(3,&fs); TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionOpenTempStoreFile); TestCase().ActionCompletedL(*this); }
TInt E32Main() { __UHEAP_MARK; test.Title(); test.Start(_L("initialising")); CTrapCleanup* c=CTrapCleanup::New(); // start the loader RFs fs; test (fs.Connect()==KErrNone); fs.Close(); test (c!=0); TRAPD(r,MainL()); test (r==KErrNone); delete c; test.End(); test.Close(); __UHEAP_MARKEND; return KErrNone; }
/** Test code for INC042690 - Bi-directional MIME types are not supported in Charconv The bi-directional MIME types only indicate how to treat the layout of the mail, the actual character conversion should be the same as for the exisiting ISO-8859-6/ISO-8859-8 plugins @SYMTestCaseID SYSLIB-CHARCONV-CT-0542 @SYMTestCaseDesc Tests the Bi-directional MIME @SYMTestPriority Medium @SYMTestActions Tests for conversions of ISO_8859-6 UID to MIB @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ void CT_ISO8859X::testInc042690L() { INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0542 Test for INC042690 ")); RFs fileServerSession; CleanupClosePushL(fileServerSession); User::LeaveIfError(fileServerSession.Connect()); CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC(); // check that the character set value of '81' is converted to the ISO_8859-6 UID (0x10008a29) test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(81,fileServerSession)==KCharacterSetIdentifierIso88596); INFO_PRINTF1(_L("\nMIB 81->Char Set ISO_8859-6 UID - OK")); // check that the character set value of '82' is converted to the ISO_8859-6 UID (0x10008a29) test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(82,fileServerSession)==KCharacterSetIdentifierIso88596); INFO_PRINTF1(_L("\nMIB 82->Char Set ISO_8859-6 UID - OK")); // check that the character set value of '84' is converted to the ISO_8859-8 UID (0x10008a2a) test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(84,fileServerSession)==KCharacterSetIdentifierIso88598); INFO_PRINTF1(_L("\nMIB 84->Char Set ISO_8859-8 UID - OK")); // check that the character set value of '85' is converted to the ISO_8859-8 UID (0x10008a2a) test(characterSetConverter->ConvertMibEnumOfCharacterSetToIdentifierL(85,fileServerSession)==KCharacterSetIdentifierIso88598); INFO_PRINTF1(_L("\nMIB 85->Char Set ISO_8859-8 UID - OK")); // check that the ISO_8859-6 UID (0x10008a29) is converted to the character set value of '9' test(characterSetConverter->ConvertCharacterSetIdentifierToMibEnumL(KCharacterSetIdentifierIso88596,fileServerSession)==9); INFO_PRINTF1(_L("\nChar Set ISO_8859-6 UID->MIB - OK")); // check that the ISO_8859-8 UID (0x10008a2a) is converted to the character set value of '11' test(characterSetConverter->ConvertCharacterSetIdentifierToMibEnumL(KCharacterSetIdentifierIso88598,fileServerSession)==11); INFO_PRINTF1(_L("\nChar Set ISO_8859-8 UID->MIB - OK")); INFO_PRINTF1(_L("\nTest for INC042690 complete:\n")); CleanupStack::PopAndDestroy(2); // characterSetConverter and fileServerSession }
////////////////////////////////////////////////////////////////////////////// // // Application entry point // ////////////////////////////////////////////////////////////////////////////// static void RunAppL() { TInt error = KErrUnknown; //RDebug::Print(_L("USBMSAPP: Creating console\n")); console = Console::NewL(KTxtApp,TSize(KConsFullScreen,KConsFullScreen)); CleanupStack::PushL(console); console->SetPos(0,2); console->Printf(_L("========================================")); // Command line: list of drive letters to auto-mount (all if not specified) User::CommandLine(mountList); mountList.UpperCase(); CActiveScheduler* sched = new(ELeave) CActiveScheduler; CleanupStack::PushL(sched); CActiveScheduler::Install(sched); fs.Connect(); CleanupClosePushL(fs); _LIT(KMountAllDefault,"(all)"); console->SetPos(0,3); LogPrint(_L("Drives to auto-mount: %S"), (mountList.Length() ? &mountList : &KMountAllDefault)); // Add MS file system error = fs.AddFileSystem(KMsFsy); if(error != KErrNone && error != KErrAlreadyExists) { //RDebug::Print(_L("AddFileSystem failed, err=%d\n"), error); User::Leave(error); } console->SetPos(0,4); LogPrint(_L("MSFS file system:\tAdded OK\n")); RUsb usb; // Load the logical device _LIT(KDriverFileName,"EUSBC.LDD"); error = User::LoadLogicalDevice(KDriverFileName); if (error != KErrAlreadyExists) User::LeaveIfError(error); error = usb.Open(0); User::LeaveIfError(error); _LIT(KOtgdiLddFilename, "otgdi"); // Check for OTG support TBuf8<KUsbDescSize_Otg> otg_desc; error = usb.GetOtgDescriptor(otg_desc); if (!(error == KErrNotSupported || error == KErrNone)) { LogPrint(_L("Error %d while fetching OTG descriptor"), error); User::Leave(-1); return; } // On an OTG device we have to start the OTG driver, otherwise the Client // stack will remain disabled forever. if (error == KErrNotSupported) { CleanupClosePushL(usb); User::Leave(-1); } error = User::LoadLogicalDevice(KOtgdiLddFilename); if (error != KErrNone) { LogPrint(_L("Error %d on loading OTG LDD"), error); User::Leave(-1); return; } RUsbOtgDriver iOtgPort; error = iOtgPort.Open(); if (error != KErrNone) { LogPrint(_L("Error %d on opening OTG port"), error); User::Leave(-1); return; } error = iOtgPort.StartStacks(); if (error != KErrNone) { LogPrint(_L("Error %d on starting USB stack"), error); User::Leave(-1); return; } CleanupClosePushL(usb); // RDebug::Print(_L("USBMSAPP: Create active objects\n")); CMessageKeyProcessor::NewLC(console); CPropertyWatch::NewLC(EUsbMsDriveState_KBytesRead, PropertyHandlers::Read); CPropertyWatch::NewLC(EUsbMsDriveState_KBytesWritten, PropertyHandlers::Written); CPropertyWatch::NewLC(EUsbMsDriveState_DriveStatus, PropertyHandlers::DriveStatus); CPropertyWatch::NewLC(EUsbMsDriveState_MediaError, PropertyHandlers::MediaError); CUsbWatch::NewLC(usb); CPeriodUpdate::NewLC(); RUsbMassStorage UsbMs; TBuf<8> t_vendorId(_L("vendor")); TBuf<16> t_productId(_L("product")); TBuf<4> t_productRev(_L("1.00")); TMassStorageConfig msConfig; msConfig.iVendorId.Copy(t_vendorId); msConfig.iProductId.Copy(t_productId); msConfig.iProductRev.Copy(t_productRev); // console->Printf(_L("Connect to Mass Storage")); error = UsbMs.Connect(); User::LeaveIfError(error); // console->Printf(_L("Start Mass Storage")); error = UsbMs.Start(msConfig); User::LeaveIfError(error); TBuf8<KUsbDescSize_Device> deviceDescriptor; error = usb.GetDeviceDescriptor(deviceDescriptor); User::LeaveIfError(error); const TInt KUsbSpecOffset = 2; const TInt KUsbDeviceClassOffset = 4; const TInt KUsbVendorIdOffset = 8; const TInt KUsbProductIdOffset = 10; const TInt KUsbDevReleaseOffset = 12; //Change the USB spec number to 2.00 deviceDescriptor[KUsbSpecOffset] = 0x00; deviceDescriptor[KUsbSpecOffset+1] = 0x02; //Change the Device Class, Device SubClass and Device Protocol deviceDescriptor[KUsbDeviceClassOffset] = 0x00; deviceDescriptor[KUsbDeviceClassOffset+1] = 0x00; deviceDescriptor[KUsbDeviceClassOffset+2] = 0x00; //Change the device vendor ID (VID) to 0x0E22 (Symbian) deviceDescriptor[KUsbVendorIdOffset] = 0x22; // little endian deviceDescriptor[KUsbVendorIdOffset+1] = 0x0E; //Change the device product ID (PID) to 0x1111 deviceDescriptor[KUsbProductIdOffset] = 0x12; deviceDescriptor[KUsbProductIdOffset+1] = 0x11; //Change the device release number to 3.05 deviceDescriptor[KUsbDevReleaseOffset] = 0x05; deviceDescriptor[KUsbDevReleaseOffset+1] = 0x03; error = usb.SetDeviceDescriptor(deviceDescriptor); User::LeaveIfError(error); // Remove possible Remote-Wakup support in Configuration descriptor, // so that we can use the MSC device also easily for Chapter9 testing. TBuf8<KUsbDescSize_Config> configDescriptor; error = usb.GetConfigurationDescriptor(configDescriptor); User::LeaveIfError(error); const TInt KConfDesc_AttribOffset = 7; configDescriptor[KConfDesc_AttribOffset] &= ~KUsbDevAttr_RemoteWakeup; error = usb.SetConfigurationDescriptor(configDescriptor); User::LeaveIfError(error); _LIT16(productID_L, "Symbian USB Mass Storage Device (Base)"); TBuf16<KUsbStringDescStringMaxSize / 2> productID(productID_L); error = usb.SetProductStringDescriptor(productID); User::LeaveIfError(error); TRequestStatus enum_status; console->SetPos(0,5); LogPrint(_L("Re-enumerating...\n")); usb.ReEnumerate(enum_status); User::LeaveIfError(error); console->SetPos(0,5); User::WaitForRequest(enum_status); if(enum_status.Int() == KErrNone) LogPrint(_L("Re-enumeration Done\n")); else LogPrint(_L("Re-enumeration not successfully done\n")); console->SetPos(0,14); TBuf<3>password(KDefPwd); LogPrint(_L("Password: %S"), &password); ShowDriveSelection(); console->SetPos(0,17); _LIT(KMsgTitleB,"Menu: q=quit d=chg drv\n m=mount u=unmount\n l=lock i=lock n=unlock\n c=clr pwd"); //RDebug::Print(_L("USBMSAPP: Start CActiveScheduler\n")); console->Printf(KMsgTitleB); CActiveScheduler::Start(); error = UsbMs.Stop(); User::LeaveIfError(error); UsbMs.Close(); error = fs.RemoveFileSystem(KMsFs); User::LeaveIfError(error); CleanupStack::PopAndDestroy(11); iOtgPort.StopStacks(); iOtgPort.Close(); error = User::FreeLogicalDevice(RUsbOtgDriver::Name()); User::LeaveIfError(error); error = User::FreeLogicalDevice(_L("USBC")); User::LeaveIfError(error); }
EXPORT_C void CSTPreferences::SaveSettingsL() { if (iPreferencesFileName) { LWRITELN(iLog, _L("Saving settings")); RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); fs.MkDirAll(*iPreferencesFileName); RFile file; if (file.Replace(fs, *iPreferencesFileName, EFileWrite) == KErrNone) { LWRITELN(iLog, _L("Settings file replaced")); CleanupClosePushL(file); // DownloadPath SaveSettingL(file, KSettingDownloadPath, *iDownloadPath); // AccessPointName SaveSettingL(file, KSettingAccesPointName, *iAccessPointName); // AccessPointId { TBuf<16> accesPointId; accesPointId.Num(TInt(iAccessPointId)); SaveSettingL(file, KSettingAccesPointId, accesPointId); } // Right softkey mode { TBuf<16> rsmBuf; rsmBuf.Num(TInt(iRightSoftkeyMode)); SaveSettingL(file, KSettingRightSoftkeyMode, rsmBuf); } // IncomingPort { TBuf<16> portBuf; portBuf.Num(IncomingPort()); SaveSettingL(file, KSettingIncomingPort, portBuf); } #ifdef EKA2 // TrackerServicePort { TBuf<16> trackerBuf; trackerBuf.Num(TrackerServicePort()); SaveSettingL(file, KSettingTrackerServicePort, trackerBuf); } // PieceSize { TBuf<16> pieceBuf; pieceBuf.Num(PieceSize()); SaveSettingL(file, KSettingPieceSize, pieceBuf); } // DHTEnabled { if (IsDHTEnabled()) SaveSettingL(file, KSettingDHTEnabled, _L("1")); else SaveSettingL(file, KSettingDHTEnabled, _L("0")); } #endif // CloseConnectionAfterDownload { if (CloseConnectionAfterDownload()) SaveSettingL(file, KSettingCloseConnectionAfterDownload, _L("1")); else SaveSettingL(file, KSettingCloseConnectionAfterDownload, _L("0")); } // Subpiece size { TBuf<16> spsBuf; spsBuf.Num(iSubpieceSize); SaveSettingL(file, KSettingSubpieceSize, spsBuf); } // ProxyServicePort { TBuf<16> servicePortBuf; servicePortBuf.Num(iProxyServicePort); SaveSettingL(file, KSettingProxyServicePort, servicePortBuf); } // ProxyConnectionPort { TBuf<16> connPortBuf; connPortBuf.Num(iProxyConnectionPort); SaveSettingL(file, KSettingProxyConnectionPort, connPortBuf); } // ProxyHostName SaveSettingL(file, KSettingProxyHostName, ProxyHostName()); // IncomingConnectionsMode { TBuf<16> icmBuf; icmBuf.Num(TInt(iIncomingConnectionsMode)); SaveSettingL(file, KSettingIncomingConnectionsMode, icmBuf); } // IsUploadEnabled { if (iIsUploadEnabled) SaveSettingL(file, KSettingUploadEnabled, _L("1")); else SaveSettingL(file, KSettingUploadEnabled, _L("0")); } // StartupHashCheck { if (StartupHashCheck()) SaveSettingL(file, KSettingStartupHashCheck, _L("1")); else SaveSettingL(file, KSettingStartupHashCheck, _L("0")); } for (TInt i=0; i<iSTorrents->Count(); i++) SaveSettingL(file, KSettingSTorrent, (*iSTorrents)[i]); file.Write(KLit8EndLine); CleanupStack::PopAndDestroy(); // file } else LWRITELN(iLog, _L("Failed to replace settings file")); CleanupStack::PopAndDestroy(); // fs } }
EXPORT_C void CSTPreferences::LoadSettingsL() { if (iPreferencesFileName) { LWRITELN(iLog, _L("Loading settings")); RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); RFile file; if (file.Open(fs, *iPreferencesFileName, EFileRead|EFileShareReadersOnly) == KErrNone) { LWRITELN(iLog, _L("Settings file opened")); CleanupClosePushL(file); TBuf8<KMaxSettingNameLength> settingName; TInt settingLength; while (ReadSettingName(file, settingName, settingLength)) { if (settingName == KSettingDownloadPath) { HBufC* downloadPath = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); if (downloadPath) { delete iDownloadPath; iDownloadPath = downloadPath; } } else if (settingName == KSettingAccesPointId) { HBufC* iapIdBuf = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); if (iapIdBuf) { TLex lex(*iapIdBuf); lex.Mark(); TInt iapId = 0; if (lex.Val(iapId) == KErrNone) iAccessPointId = iapId; } delete iapIdBuf; } else if (settingName == KSettingAccesPointName) { HBufC* iapName = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); if (iapName) { delete iAccessPointName; iAccessPointName = iapName; } } else if (settingName == KSettingRightSoftkeyMode) { HBufC* rsmBuf = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); if (rsmBuf) { TLex lex(*rsmBuf); lex.Mark(); TInt rsm = 0; if (lex.Val(rsm) == KErrNone) SetRightSoftkeyMode(TSTSoftkeyMode(rsm)); } delete rsmBuf; } else if (settingName == KSettingSTorrent) { HBufC* sTorrent = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); CleanupStack::PushL(sTorrent); if (sTorrent) iSTorrents->AppendL(*sTorrent); CleanupStack::PopAndDestroy(); // sTorrent } else if (settingName == KSettingProxyServicePort) { HBufC* servicePortBuf = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); if (servicePortBuf) { TLex lex(*servicePortBuf); lex.Mark(); TInt servicePort = 0; if (lex.Val(servicePort) == KErrNone) SetProxyServicePort(servicePort); } delete servicePortBuf; } else if (settingName == KSettingProxyConnectionPort) { HBufC* connPortBuf = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); if (connPortBuf) { TLex lex(*connPortBuf); lex.Mark(); TInt connPort = 0; if (lex.Val(connPort) == KErrNone) SetProxyConnectionPort(connPort); } delete connPortBuf; } else if (settingName == KSettingProxyHostName) { HBufC* hostname = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); if (hostname) { CleanupStack::PushL(hostname); SetProxyAddressL(*hostname); CleanupStack::PopAndDestroy(hostname); } } else if (settingName == KSettingIncomingConnectionsMode) { HBufC* icmBuf = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); if (icmBuf) { TLex lex(*icmBuf); lex.Mark(); TInt icm = 0; if (lex.Val(icm) == KErrNone) SetIncomingConnectionsMode(CNetworkManager::TIncomingConnectionsMode(icm)); } delete icmBuf; } else if (settingName == KSettingUploadEnabled) { HBufC* upBuf = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); if (upBuf) { TLex lex(*upBuf); lex.Mark(); TInt uploadEnabled = 0; if (lex.Val(uploadEnabled) == KErrNone) if (uploadEnabled) SetUploadEnabled(ETrue); else SetUploadEnabled(EFalse); } delete upBuf; } else if (settingName == KSettingStartupHashCheck) { HBufC* hcBuf = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); CleanupStack::PushL(hcBuf); if (hcBuf) { TLex lex(*hcBuf); lex.Mark(); TInt hashCheck = 0; if (lex.Val(hashCheck) == KErrNone) if (hashCheck) SetStartupHashCheck(ETrue); else SetStartupHashCheck(EFalse); } CleanupStack::PopAndDestroy(); // hcBuf } else if (settingName == KSettingCloseConnectionAfterDownload) { HBufC* hcBuf = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); CleanupStack::PushL(hcBuf); //TODO test before releasing /*if (hcBuf) { TLex lex(*hcBuf); lex.Mark(); TInt closeConn = 0; if (lex.Val(closeConn) == KErrNone) if (closeConn) SetCloseConnectionAfterDownload(ETrue); else SetCloseConnectionAfterDownload(EFalse); }*/ CleanupStack::PopAndDestroy(); // hcBuf } else if (settingName == KSettingSubpieceSize) { HBufC* buf = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); if (buf) { TLex lex(*buf); lex.Mark(); TInt sps = 0; if (lex.Val(sps) == KErrNone) SetSubpieceSize(sps); } delete buf; } else #ifdef EKA2 if (settingName == KSettingTrackerServicePort) { HBufC* trackerServicePortBuf = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); if (trackerServicePortBuf) { TLex lex(*trackerServicePortBuf); lex.Mark(); TInt trackerServicePort = 0; if (lex.Val(trackerServicePort) == KErrNone) SetTrackerServicePort(trackerServicePort); } delete trackerServicePortBuf; } else if (settingName == KSettingDHTEnabled) { HBufC* buf = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); CleanupStack::PushL(buf); #ifdef USE_DHT if (buf) { TLex lex(*buf); lex.Mark(); TInt dhtEnabled = 0; if (lex.Val(dhtEnabled) == KErrNone) if (dhtEnabled) SetDHTEnabled(ETrue); else SetDHTEnabled(EFalse); } #else SetDHTEnabled(EFalse); #endif CleanupStack::PopAndDestroy(); // buf } else if (settingName == KSettingPieceSize) { HBufC* psBuf = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); if (psBuf) { TLex lex(*psBuf); lex.Mark(); TInt ps = 0; if (lex.Val(ps) == KErrNone) SetPieceSize(ps); } delete psBuf; } else #endif if (settingName == KSettingIncomingPort) { HBufC* portBuf = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); if (portBuf) { TLex lex(*portBuf); lex.Mark(); TInt port = 0; if (lex.Val(port) == KErrNone) SetIncomingPort(port); } delete portBuf; } else { HBufC* unknownSetting = ReadAndConvertFromUtf8ToUnicodeL(file, settingLength); delete unknownSetting; } } CleanupStack::PopAndDestroy(); // file } else LWRITELN(iLog, _L("Failed to open settings file")); CleanupStack::PopAndDestroy(); // fs } }
void CTestImpExvCardSuiteStepBase::ExportItemL(TBuf<80> aPath, TBool aAddBDay) { OpenDBL(); TContactItemId itemId; RFs fsSession; RFileWriteStream fileStream; CContactIdArray* idArray = NULL; CContactCard* contactAdded = NULL; TTime now; User::LeaveIfError(fsSession.Connect()); CleanupClosePushL(fsSession); idArray = CContactIdArray::NewL(); CleanupStack::PushL(idArray); // idArray fsSession.MkDirAll(aPath); User::LeaveIfError(fileStream.Replace(fsSession, aPath, EFileWrite)); contactAdded = CContactCard::NewL(); CleanupStack::PushL(contactAdded); // contactAdded contactAdded->IncAccessCount(); // ADD BDAY if (aAddBDay) { CContactItemFieldSet& fieldSet=contactAdded->CardFields(); const TInt pos=fieldSet.Find(KUidContactFieldBirthday); if (pos!=KErrNotFound) { fieldSet[pos].DateTimeStorage()->SetTime(iBDayLocal); } else { CContactItemField* field=CContactItemField::NewLC(KStorageTypeDateTime,KUidContactFieldBirthday); field->SetMapping(KUidContactFieldVCardMapBDAY); field->DateTimeStorage()->SetTime(iBDayLocal); contactAdded->AddFieldL(*field); CleanupStack::Pop(); // field } } SetNameL(*contactAdded, KUidContactFieldGivenName, _L("toby"), ETrue); SetNameL(*contactAdded, KUidContactFieldPhoneNumber, _L("6041233214"), ETrue); User::After(3000000); // There is no need to call SetLastModifed because // That function will be call by ExportSelectedContactsL below now.UniversalTime(); iRecordedTime = now; INFO_PRINTF1(_L("Adding contact to Database.....")); itemId = iDb->AddNewContactL(*contactAdded); INFO_PRINTF1(_L("Contact Added to Database")); CleanupStack::PopAndDestroy(contactAdded); // contactAdded contactAdded = NULL; idArray->InsertL(0, itemId); INFO_PRINTF1(_L("Exporting Contact.....")); iDb->ExportSelectedContactsL(TUid::Uid(KUidVCardConvDefaultImpl), *idArray, fileStream, CContactVCardConverter::EDefault, ETrue); INFO_PRINTF1(_L("Exported Contact")); fileStream.CommitL(); fileStream.Close(); CleanupStack::PopAndDestroy(idArray); // idArray fsSession.Close(); CleanupStack::PopAndDestroy(); // fsSession CloseDB(); }
static void TestWithCaps(TUint32 aCaps, TInt aExpectedError, const TDesC& aFileName) /** Helper function for TestWithCaps(TUint32, TInt). This function invokes a helper executable with the supplied capabilities and tells it to delete the supplied filename. @param aCapMask Capabilities of process which calls RLoader::Delete. @param aExpectedError Expected error reason. The launched executable is expected to panic with category KTldPanicCat and this reason, which is the expected return code from RLoader::Delete. @param aFileName The helper executable is told to delete this file. */ { test.Printf( _L("TestWithCaps,aCaps=0x%x,aExpectedError=%d,aFileName=\"%S\"\n"), aCaps, aExpectedError, &aFileName); TInt r; // create the file to delete RFs fs; r = fs.Connect(); test(r == KErrNone); // if this file is expected to exist then create it TPtrC dirName; TBool shouldExist = (aFileName == KTldTcbFile || aFileName == KTldAllFilesFile); if (shouldExist) { TParsePtrC pp(aFileName); dirName.Set(pp.DriveAndPath()); r = fs.MkDirAll(dirName); test(r == KErrNone || r == KErrAlreadyExists); CreateTestFile(fs, aFileName); } SetHelperCaps(aCaps); RunHelper(aFileName, aExpectedError); if (shouldExist) { // if the file could not be deleted then delete it now TEntry e; // a C++ bool for the following equality operator bool exists = (fs.Entry(aFileName, e) == KErrNone); test(exists == (aExpectedError != KErrNone)); if (exists) { r = fs.Delete(aFileName); test(r == KErrNone); } // delete the immediate containing directory. The error code is not // used because the directory may be used for something else. fs.RmDir(dirName); } // delete the generated different-caps file r = fs.Delete(_L("c:\\sys\\bin\\tld_helper_caps.exe")); test(r == KErrNone); r = fs.Delete(_L("c:\\sys\\hash\\tld_helper_caps.exe")); test(r == KErrNone || r == KErrNotFound || r == KErrPathNotFound); fs.Close(); }
void CIniFile::ConstructL(const TDesC& aName, const TDesC& aPath) /** * Allocate a buffer and Read file's contents into iPtr * * @param aName is the name of the ini file to be used, e.g. "REFTSY.INI" */ { iToken = HBufC::NewL(KTokenSize+2); // 2 extra chars for [] RFs fs; TInt err; err = fs.Connect(); if(err < 0) { OstTrace1( TRACE_NORMAL, CINIFILE_CONSTRUCTL, "CIniFile::ConstructL;fs.Connect() with error=%d", err ); User::Leave(err); } CleanupClosePushL(fs); TFindFile ff(fs); err = ff.FindByDir(aName, aPath); if(err < 0) { OstTrace1( TRACE_NORMAL, CINIFILE_CONSTRUCTL_DUP1, "CIniFile::ConstructL;ff.FindByDir(aName, aPath) with error=%d", err ); User::Leave(err); } iName = ff.File().AllocL(); RFile file; TInt size; err = file.Open(fs,*iName,EFileStreamText|EFileRead|EFileShareReadersOnly); if(err < 0) { OstTrace1( TRACE_NORMAL, CINIFILE_CONSTRUCTL_DUP2, "CIniFile::ConstructL;file.Open(fs,*iName,EFileStreamText|EFileRead|EFileShareReadersOnly) with error=%d", err ); User::Leave(err); } CleanupClosePushL(file); err = file.Size(size); if(err < 0) { OstTrace1( TRACE_NORMAL, CINIFILE_CONSTRUCTL_DUP3, "CIniFile::ConstructL;file.Size(size) with error=%d", err ); User::Leave(err); } TText* data = REINTERPRET_CAST(TText*, User::AllocL(size)); iPtr.Set(data, size/sizeof(TText), size/sizeof(TText)); TPtr8 dest(REINTERPRET_CAST(TUint8*,data), 0, size); err = file.Read(dest); if(err < 0) { OstTrace1( TRACE_NORMAL, CINIFILE_CONSTRUCTL_DUP4, "CIniFile::ConstructL;file.Read(dest) with error=%d", err ); User::Leave(err); } TUint8* ptr = REINTERPRET_CAST(TUint8*,data); // // This is orderred as FEFF assuming the processor is Little Endian // The data in the file is FFFE. PRR 28/9/98 // if(size>= STATIC_CAST(TInt,sizeof(TText)) && iPtr[0]==0xFEFF) { Mem::Copy(ptr, ptr+sizeof(TText), size-sizeof(TText)); iPtr.Set(data, size/sizeof(TText)-1, size/sizeof(TText)-1); } else if(size) { TText* newdata = REINTERPRET_CAST(TText*, User::AllocL(size*sizeof(TText))); iPtr.Set(newdata, size, size); TInt i; for(i=0 ; i<size ; ++i) { iPtr[i] = ptr[i]; } delete data; } CleanupStack::PopAndDestroy(); // file CleanupStack::PopAndDestroy(); // fs }
// // Set the Default CommDb Combination // void CreateCommDbL() /** * This method creates a special Communications Database to be used with the regression test * harness. The user is given a chance to cancel this operation. This method uses the file * server and timer services. It also calls other methods to actually populate the * special communications database. Note that the communications database created is tailored * to the needs of the ETel Regression Test harness. * * @leave This method leaves if the user cancels the overwrite of the communications * database or if the NewL method called in this method fails. Also, the database * functions can also leave. */ { RFs fs; _LIT(KSvDbFileName,"C:\\System\\Data\\Cdbv3.dat"); TESTL(fs.Connect()==KErrNone); RTimer timer; timer.CreateLocal(); TUint dummy; if(fs.Att(KSvDbFileName,dummy)==KErrNone) { INFO_PRINTF1(_L("\nThis test requires a special CommDb Database.\nExisting Database File detected\nPress any key to STOP Overwrite\n\n")); TBool keyPressed=ETrue; ShortWaitForKey(5,keyPressed); if(keyPressed) User::Leave(KErrAlreadyExists); INFO_PRINTF1(_L("\n")); TESTL(fs.Delete(KSvDbFileName)==KErrNone); } fs.Close(); TheDb=CCommsDatabase::NewL(EDatabaseTypeIAP); CleanupStack::PushL(TheDb); TESTL(TheDb->BeginTransaction()==KErrNone); // // Write the database tables // TUint32 ispId=CreateISPTableL(); CreateModemTablesL(); CreateLocationTablesL(); PopulateModemTemplateL(); CCommsDbTableView* table=TheDb->OpenTableLC(TPtrC(IAP)); TUint32 id; TESTL(table->InsertRecord(id)==KErrNone); table->WriteTextL(TPtrC(COMMDB_NAME),_L("Test Configuration: MM Loopback")); table->WriteUintL(TPtrC(IAP_SERVICE),ispId); table->WriteTextL(TPtrC(IAP_SERVICE_TYPE),TPtrC(DIAL_OUT_ISP)); TESTL(table->PutRecordChanges()==KErrNone); // // Set the Default // CCommsDbConnectionPrefTableView* cpTable=TheDb->OpenConnectionPrefTableViewOnRankLC(ECommDbConnectionDirectionOutgoing,1); cpTable->GotoFirstRecord(); CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref; cpTable->ReadConnectionPreferenceL(pref); pref.iBearer.iIapId=id; pref.iBearer.iBearerSet = KCommDbBearerCSD; cpTable->UpdateBearerL(pref.iBearer); CleanupStack::PopAndDestroy(); TESTL(TheDb->CommitTransaction()==KErrNone); CleanupStack::PopAndDestroy(); CleanupStack::PopAndDestroy(); }
GLDEF_C TInt E32Main() // // Main entry point - make sure everything is going. // /** * This method is the main entry point for the GSM TSY Regression Test Harness code. This * code first makes sure the file server is included. It also loads the comm server if * necessary. After calling a method to create the necessary communications database, * this method invokes the user interface for the test harness. * * @return KErrNone on Success; Errors returned from either communications database * creation failure or individual tests on failures. * * @note This method creates a new instance of the clean up stack. * */ { // Make sure we're linked to the file server RFs s; s.Connect(); s.Close(); test.Title(); test.Start(_L("Loading Serial drivers")); TInt r; // When bootstrapping C32 we have to avoid the PhBkSyncServer being started, since // it needs a different CommDB _LIT(KPhbkSyncCMI, "phbsync.cmi"); r = StartC32WithCMISuppressions(KPhbkSyncCMI); if((r!=KErrNone)&&(r!=KErrAlreadyExists)) INFO_PRINTF1(_L("Failed to start C32 %d\n\r"),r); CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack TRAP(r,CreateCommDbL()); if(r==KErrNone) { TRAP(r,CreateTestReportFileL()); if(r==KErrNone) { TRAP(r,PerformTestL()); if(ReturnValue) r=ReturnValue; } } CloseTestReportFile(); if (r) INFO_PRINTF1(TRefByValue<const TDesC>(_L("\nError %d reported")),r); else INFO_PRINTF1(_L("\nTest Completed Sucessfully")); INFO_PRINTF1(_L(", press any key to end")); TBool keyPressed=ETrue; ShortWaitForKey(10, keyPressed); test.End(); delete cleanup; // delete testActiveScheduler; return KErrNone; }
/** * Load and initialise an audio file. */ TVerdict CTestMmfVclntOpenFile0522::DoTestStepL() { TVerdict ret = EFail; INFO_PRINTF1(_L("Test : Video Recorder - OpenFileL(RFile&)")); RFs fs; RFile file; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); User::LeaveIfError(fs.ShareProtected()); iError = KErrTimedOut; TPtrC filename; if(!GetStringFromConfig(iSectName,iKeyName,filename)) { return EInconclusive; } User::LeaveIfError(file.Open(fs,filename,EFileWrite)); CleanupClosePushL(file); CVideoRecorderUtility* rec = CVideoRecorderUtility::NewL(*this); CleanupStack::PushL(rec); const TUid KVidTstControllerUid = {KMmfVideoTestControllerUid}; TRAP(iError,rec->OpenFileL(file, NULL, KVidTstControllerUid, KUidMdaBmpClipFormat)); if(iError == KErrNone) { INFO_PRINTF1(_L("CVideoRecorderUtility: Open file")); // Wait for initialisation callback CActiveScheduler::Start(); } if(iError == KErrNotSupported) { ret = EPass; } // Check for errors. if ((iError == KErrNone) && (rec != NULL)) { rec->Prepare(); CActiveScheduler::Start(); if(iError != KErrNone) { INFO_PRINTF2(_L("Prepare callback : error %d"), iError); return EInconclusive; } if(iRec) { iError = KErrTimedOut; rec->Record(); INFO_PRINTF1(_L("CVideoRecorderUtility: Record")); // Wait for init callback CActiveScheduler::Start(); if(iError == KErrNone) { ret = EPass; } User::After(1000000); rec->Stop(); } else { ret = EPass; } } rec->Close(); INFO_PRINTF1(_L("CVideoRecorderUtility: Destroy")); CleanupStack::PopAndDestroy(rec); User::After(KOneSecond); // wait for deletion to shut down devsound if(iError != KErrNone) { ERR_PRINTF2( _L("CVideoRecorderUtility failed with error %d"),iError ); } CleanupStack::PopAndDestroy(2,&fs); return ret; }
// --------------------------------------------------------- // CPosTp17::StartL // // (other items were commented in a header). // --------------------------------------------------------- // void CPosTp17::StartL() { #ifdef __WINS__ _LIT(KNotSupported, "Test case is not supported on WINS, exucute it on target!"); LogErrorAndLeave(KNotSupported); #else _LIT(KErrors, "One or several Dll's have an incorrect size"); SetupTestDataL(); RFs session; User::LeaveIfError(session.Connect()); CleanupClosePushL(session); RFile file; TBuf<1> drive= _L("c"); TBuf<KMaxDllFileNameLength> name; name.Copy(iDllNames[0]); name.Replace(0,1,drive); if (file.Open(session, name, EFileRead) != KErrNone) { iLog->Put(_L("(Flashed) Use Drive Z:")); drive.Copy(_L("z")); } else iLog->Put(_L("(Nonflashed) Use Drive C:")); file.Close(); TBool errors=EFalse; for (TInt i=0; i<iDllNames.Count(); i++) { name.Copy(iDllNames[i]); name.Replace(0,1,drive); //User::LeaveIfError(file.Open(session, name, EFileRead)); TInt err = file.Open(session, name, EFileRead); if (err != KErrNone) { TBuf<70> buffe; buffe.Append(_L("Error when opening file ")); buffe.Append(name); LogErrorAndLeave(buffe, err); } CleanupClosePushL(file); TInt fileSize=0; file.Size(fileSize); if (fileSize > iFootprints[i]) { errors = ETrue; _LIT(KDllSizeErr, "ERROR: %S is to big (%d), Max allowed ROM footprint is %d"); TBuf<255> info; HBufC* temp = name.Alloc(); info.Format(KDllSizeErr, temp, fileSize, iFootprints[i]); delete temp; iLog->Put(info); } else { // Always log .dll size _LIT(KDllSizeDebug, "%S is (%d), Max allowed ROM footprint is %d"); TBuf<255> info; HBufC* temp = name.Alloc(); info.Format(KDllSizeDebug, temp, fileSize, iFootprints[i]); delete temp; iLog->Put(info); } CleanupStack::PopAndDestroy(&file); } CleanupStack::PopAndDestroy(&session); if (errors) { LogErrorAndLeave(KErrors); } #endif }
// --------------------------------------------------------- // CPosTp17::SetupTestDataL() // // (other items were commented in a header). // --------------------------------------------------------- // void CPosTp17::SetupTestDataL() { iLog->Put(_L("SetupTestDataL")); _LIT(KLANDMARK,"z:\\sys\\bin\\eposlandmarks.dll"); RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); CFileMan* fileMan = CFileMan::NewL(fs); CleanupStack::PushL(fileMan); //check if landmark is flashed if (BaflUtils::FileExists(fs, KLANDMARK)) { //Landmark is flashed User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlandmarks.dll"))); User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmsearchlib.dll"))); User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmmultidbsearch.dll"))); User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmlocalsearchprovider.dll"))); User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmlocalaccessprovider.dll"))); User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmlocalaccess.dll"))); User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmservlib.dll"))); User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmserver.exe"))); User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmdbreg.dll"))); User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmintservices.dll"))); User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmconverter.dll"))); User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmrecognizer.dll"))); User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmdbmanlib.dll"))); User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmdbmanprov.dll"))); User::LeaveIfError(iDllNames.Append(_L("z:\\sys\\bin\\eposlmlocaldbmanprovider.dll"))); } else { //Landmark is not flashed User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlandmarks.dll"))); User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmsearchlib.dll"))); User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmmultidbsearch.dll"))); User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmlocalsearchprovider.dll"))); User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmlocalaccessprovider.dll"))); User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmlocalaccess.dll"))); User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmservlib.dll"))); User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmserver.exe"))); User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmdbreg.dll"))); User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmintservices.dll"))); User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmconverter.dll"))); User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmrecognizer.dll"))); User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmdbmanlib.dll"))); User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmdbmanprov.dll"))); User::LeaveIfError(iDllNames.Append(_L("!:\\sys\\bin\\eposlmlocaldbmanprovider.dll"))); } User::LeaveIfError(iFootprints.Append(9000)); //eposlandmarks.dll (Landmarks Client Library) // Note that eposlmmultidbsearch.dll + eposlmsearchlib.dll must not be bigger than 17000 User::LeaveIfError(iFootprints.Append(8500)); //eposlmsearchlib.dll (Landmarks Search Client Library) User::LeaveIfError(iFootprints.Append(8500)); //eposlmmultidbsearch.dll (Landmarks Search Client Library) User::LeaveIfError(iFootprints.Append(19000)); //eposlmlocalsearchprovider.dll (Landmarks Local Search Provider) // Note that eposlmlocalaccessprovider.dll + eposlmlocalaccess.dll must not be bigger than 23000 User::LeaveIfError(iFootprints.Append(400)); //eposlmlocalaccessprovider.dll (Landmarks Local Access Provider) User::LeaveIfError(iFootprints.Append(23000)); //eposlmlocalaccess.dll (Landmarks Local Access) User::LeaveIfError(iFootprints.Append(2000)); //eposlmservlib.dll (Landmarks Server Client Library) User::LeaveIfError(iFootprints.Append(26000)); //eposlmserver.exe (Landmarks Server) User::LeaveIfError(iFootprints.Append(6000)); //eposlmdbreg.dll (Landmarks Database Registry) User::LeaveIfError(iFootprints.Append(23000)); //eposlmintservices.dll (Landmarks Internal Services) User::LeaveIfError(iFootprints.Append(22000)); //eposlmconverter,dll (Landmarks Content Format Converter) User::LeaveIfError(iFootprints.Append(2000)); //eposlmrecognizer.mdl (Landmarks Content Format Recognizer) User::LeaveIfError(iFootprints.Append(3000)); //eposlmdbmanlib.dll (Landmarks DB Management Client) User::LeaveIfError(iFootprints.Append(6000)); //eposlmdbmanprov.dll (Landmarks Database Management Provider) User::LeaveIfError(iFootprints.Append(5000)); //eposlmlocaldbmanprovider.dll (Landmarks Local Database Management Provider) CleanupStack::PopAndDestroy(2, &fs); }