// ----------------------------------------------------------------------------- // CPKIDialog::?member_function // ?implementation_description // (other items were commented in a header). // ----------------------------------------------------------------------------- // void CPKIDialog::DoSaveCertificateL( TCertificateFormat aFormat, TCertificateOwnerType aCertificateOwnerType, const TDesC8& aCert, TRequestStatus& aStatus) { iCurrentOperation = ESaveCert; InitClientStatus( aStatus ); TSaveCertInput saveCertInput; saveCertInput.iOperation = ESaveCert; saveCertInput.iCertFormat = aFormat; saveCertInput.iCertOwnerType = aCertificateOwnerType; saveCertInput.iDataSize = aCert.Size(); TPckgC<TSaveCertInput> saveCertInputBuf( saveCertInput ); //const TUint8* textToSignPtr = reinterpret_cast<const TUint8*>( aCert.Ptr() ); // new stuff begin delete iBufferData; TInt inputBufferSize = aCert.Size() + sizeof(TSaveCertInput); iBufferData = HBufC8::NewL( inputBufferSize ); TPtr8 inputBufferPtr( iBufferData->Des() ); inputBufferPtr.Append( saveCertInputBuf ); inputBufferPtr.Append(aCert); iRequester->RequestDialog(*iBufferData, iDlgResponseBuf); }
// ----------------------------------------------------------------------------- // CPKIDialog::?member_function // ?implementation_description // (other items were commented in a header). // ----------------------------------------------------------------------------- // void CPKIDialog::RequestWithTokenHandleL( const TDesC& aText, const TCTTokenObjectHandle& aTokenHandle, TRequestStatus& aStatus ) { InitClientStatus(aStatus); iSenderBuffer->Reset(); RBufWriteStream stream; CleanupClosePushL( stream ); stream.Open( *iSenderBuffer ); stream.WriteInt32L( iCurrentOperation ); if (0 < aText.Length()) { stream.WriteInt32L( aText.Length() ); stream << aText; } // new stuff begin delete iBufferData; TInt inputBufferSize = iSenderBuffer->Ptr(0).Size() + sizeof(TCTTokenObjectHandle); iBufferData = HBufC8::NewL( inputBufferSize ); TPtr8 inputBufferPtr( iBufferData->Des() ); inputBufferPtr = iSenderBuffer->Ptr(0); TPckgC<TCTTokenObjectHandle> handleBuf( aTokenHandle ); inputBufferPtr.Append( handleBuf ); // new stuff end CleanupStack::PopAndDestroy(); // stream.close; iRequester->RequestDialog(*iBufferData, iDlgResponseBuf); }
// --------------------------------------------------------------------------- // CSecurityDialogNotifierSession::GetInputBufferL() // --------------------------------------------------------------------------- // void CSecurityDialogNotifierSession::GetInputBufferL( const RMessage2& aMessage ) { TInt inputLength = aMessage.GetDesLength( KInputParam ); TRACE( "CSecurityDialogNotifierSession::GetInputBufferL, inputLength=%d", inputLength ); __ASSERT_ALWAYS( inputLength > 0, User::Leave( KErrCorrupt ) ); if( iInputBuffer ) { delete iInputBuffer; iInputBuffer = NULL; } iInputBuffer = HBufC8::NewL( inputLength ); TPtr8 inputBufferPtr( iInputBuffer->Des() ); aMessage.ReadL( KInputParam, inputBufferPtr ); TRACE( "CSecurityDialogNotifierSession::GetInputBufferL, read complete" ); }
synthclone::Sample * SessionSampleData::updateSample(synthclone::Sample &sample, bool forceCopy, QObject *parent) { if (! sampleDirectory) { // The session is being unloaded. return 0; } synthclone::SampleInputStream inputStream(sample); ChannelConvertAlgorithm channelConvertAlgorithm; synthclone::SampleChannelCount inputChannels = inputStream.getChannels(); if (sampleChannelCount == inputChannels) { channelConvertAlgorithm = CHANNELCONVERTALGORITHM_NONE; } else if (sampleChannelCount == 1) { channelConvertAlgorithm = CHANNELCONVERTALGORITHM_TO_MONO; } else if (inputChannels == 1) { channelConvertAlgorithm = CHANNELCONVERTALGORITHM_FROM_MONO; } else { // How does one convert a multi-channel sample to a different channel // count that isn't mono? I'm open to ideas. return 0; } // If the sample rate isn't set, then set it to the sample rate of the new // sample. synthclone::SampleRate inputSampleRate = inputStream.getSampleRate(); if (sampleRate == synthclone::SAMPLE_RATE_NOT_SET) { setSampleRate(inputSampleRate); } bool sampleConversionRequired = inputSampleRate != sampleRate; QString newPath = createUniqueFile(sampleDirectory); if ((channelConvertAlgorithm == CHANNELCONVERTALGORITHM_NONE) && (! sampleConversionRequired) && (! forceCopy)) { if (sampleDirectory) { if (QFileInfo(sample.getPath()).absolutePath() == sampleDirectory->absolutePath()) { // Nothing needs to be done. return &sample; } } } // At this point, either some sort of conversion is required, the sample is // being moved from outside the sample directory into the sample directory, // or a forced copy was requested. float *channelBuffer; // For some reason, the empty QScopedArrayPointer constructor is not // available on the Mac OSX platform. QScopedArrayPointer<float> channelBufferPtr(static_cast<float *>(0)); float *convertBuffer = new float[sampleChannelCount * 512]; QScopedArrayPointer<float> convertBufferPtr(convertBuffer); SampleRateConverter *converter; QScopedPointer<SampleRateConverter> converterPtr; float *inputBuffer = new float[inputChannels * 512]; QScopedArrayPointer<float> inputBufferPtr(inputBuffer); if (! sampleConversionRequired) { channelBuffer = convertBuffer; converter = 0; } else { if (channelConvertAlgorithm != CHANNELCONVERTALGORITHM_NONE) { channelBuffer = new float[sampleChannelCount]; channelBufferPtr.reset(channelBuffer); } else { channelBuffer = inputBuffer; } double ratio = static_cast<double>(sampleRate) / inputSampleRate; converter = new SampleRateConverter(sampleChannelCount, ratio, this); converterPtr.reset(converter); } // Create the new sample object. synthclone::Sample *outputSample = new synthclone::Sample(newPath, parent); QScopedPointer<synthclone::Sample> outputSamplePtr(outputSample); synthclone::SampleOutputStream outputStream(*outputSample, sampleRate, sampleChannelCount); // Convert. synthclone::SampleFrameCount framesRead; long outputFramesUsed; do { // Get data from input stream. framesRead = inputStream.read(inputBuffer, 512); // Channel conversion. switch (channelConvertAlgorithm) { case CHANNELCONVERTALGORITHM_TO_MONO: for (int i = 0; i < framesRead; i++) { float n = 0.0; for (int j = 0; j < inputChannels; j++) { n += inputBuffer[(i * inputChannels) + j]; } channelBuffer[i] = n / inputChannels; } break; case CHANNELCONVERTALGORITHM_FROM_MONO: for (int i = 0; i < framesRead; i++) { float n = inputBuffer[i]; for (int j = 0; j < sampleChannelCount; j++) { channelBuffer[(i * sampleChannelCount) + j] = n; } } break; case 0: // There's no channel conversion. Above, we assign the // 'channelBuffer' to 'inputBuffer' when there's no channel // conversion. So, the data is already in 'channelBuffer'. ; } // Sample rate conversion. if (sampleConversionRequired) { long inputFramesUsed = converter->convert(channelBuffer, static_cast<long>(framesRead), convertBuffer, 512, outputFramesUsed, ! framesRead); if (inputFramesUsed != framesRead) { inputStream.seek(inputFramesUsed - framesRead, synthclone::SampleStream::OFFSET_CURRENT); } } else { // If sample rate conversion isn't required, then the data to write // is already in 'convertBuffer', as 'convertBuffer' and // 'channelBuffer' point to the same memory area. outputFramesUsed = framesRead; } // Write data to output stream. if (outputFramesUsed) { outputStream.write(convertBuffer, static_cast<synthclone::SampleFrameCount> (outputFramesUsed)); } } while (framesRead); // Finish up sample rate conversion. if (sampleConversionRequired && outputFramesUsed) { for (;;) { converter->convert(channelBuffer, 0, convertBuffer, 512, outputFramesUsed, true); if (! outputFramesUsed) { break; } outputStream.write(convertBuffer, static_cast<synthclone::SampleFrameCount> (outputFramesUsed)); } } // Cleanup. outputStream.close(); return outputSamplePtr.take(); }