void CTestRControlChannel::ExtractServiceDescriptionL (const TDesC& aConfigSection, CUPnPServiceRegisterParamSet& aServiceRegisterParamSet) { RFs fs; RFile file; RBuf8 buf; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); TPtrC descriptionPath; _LIT(KDescriptionPath, "Description_Path"); GetStringFromConfig(aConfigSection, KDescriptionPath, descriptionPath); TInt err = file.Open(fs, descriptionPath, EFileShareReadersOnly); // For Hardware system path is c:, so descriptionPath value present in '.ini' is referring 'c:' if ( err == KErrPathNotFound ) { RBuf fileName; TDriveName aSystemDrive; TDriveUnit driveunit(RFs::GetSystemDrive()); aSystemDrive.Zero(); aSystemDrive=driveunit.Name(); fileName.CreateL ( descriptionPath.Length () ); fileName.Zero(); fileName.Append(aSystemDrive); fileName.Append ( descriptionPath.Mid ( aSystemDrive.Length () ) ); err = file.Open(fs, fileName, EFileShareReadersOnly); } if (err != KErrNone) { User::LeaveIfError(err); } CleanupClosePushL(file); TInt fileSize = 0; file.Size(fileSize); buf.Create(fileSize); err = file.Read(buf, fileSize); aServiceRegisterParamSet.SetServiceDescriptionL ( buf ); CleanupStack::PopAndDestroy(2 ); buf.Close(); _LIT(KInfoLogFile, "CRControlChannelObserver::ExtractServiceDescriptionL End.... \n"); INFO_PRINTF1(KInfoLogFile); }
void PopulateDatabaseL() { test.Start(_L("Populate database")); RUpsSession session; User::LeaveIfError(session.Connect()); CleanupClosePushL(session); RThread thd; RUpsSubsession clientSubsession; TInt r = clientSubsession.Initialise(session, thd); test(r == KErrNone); CleanupClosePushL(clientSubsession); RBuf destination; destination.CreateL(100); CleanupClosePushL(destination); for(TInt i=0 ; i<100; ++i) { TServiceId serviceId = {42}; if( i & 1) serviceId.iUid = 43; destination.Zero(); destination.AppendFormat(_L("destination %x"), i); TUpsDecision dec = EUpsDecNo; TRequestStatus rs; clientSubsession.Authorise(EFalse, serviceId, destination, _L8("Opaque data"), dec, rs); User::WaitForRequest(rs); test(rs == KErrNone); if(serviceId.iUid == 42) { test(dec == EUpsDecYes); } else { test(dec == EUpsDecNo); } } CleanupStack::PopAndDestroy(&destination); CleanupStack::PopAndDestroy(&clientSubsession); CleanupStack::PopAndDestroy(&session); test.End(); }
void CIoReadTest::DoRunL() { // read the file into memory ReadFileL(); LeaveIfErr(iIoFile.Create(IoSession(), iFile, RIoFile::ERead), _L("Cannot create file end point for '%S'"), &iFile); iFileReader.CreateL(IoSession()); iIoFile.AttachL(iFileReader, RIoEndPoint::EForeground); iFileReader.SetReadModeL(iReadMode); iReadBuf.CreateL(iReadSize); iFileBuffer = CTextBuffer::NewL(0x20); TInt err; do { iReadBuf.Zero(); err = iFileReader.Read(iReadBuf); iFileBuffer->AppendL(iReadBuf); } while (err == KErrNone); if (err!=KErrEof) LeaveIfErr(err, _L("Unexpected error from RIoReadHandle::Read")); TInt completion = 0; if (iFileBuffer->Length() != iFileContents.Length()) { PrintWarning(_L("Amount of data read from file (%d) differs from file size (%d)."), iFileBuffer->Length(), iFileContents.Length()); completion = 1; } if (iFileBuffer->Descriptor().Compare(iFileContents) != 0) { PrintWarning(_L("Data read from file differs from file contents.")); completion = 1; } Complete(completion); }