void CHttpController::ProcessResponseBodyDataL( RHTTPTransaction& aTransaction ) { MHTTPDataSupplier* body = aTransaction.Response().Body(); TPtrC8 dataPart; body->GetNextDataPart( dataPart ); if ( iOutputStream ) { iOutputStream->WriteL( dataPart ); } else { TInt bufLength( iResponseData->Des().Length() ); TInt maxBufLength( iResponseData->Des().MaxLength() ); if ( bufLength + dataPart.Length() > maxBufLength ) { iResponseData = iResponseData->ReAllocL( bufLength + dataPart.Length() ); } iResponseData->Des().Append( dataPart ); } body->ReleaseData(); StartTimeout(); }
// --------------------------------------------------------------------------- // CEmailInterfaceFactoryImpl::AppendOrRemoveUidL // --------------------------------------------------------------------------- void CEmailInterfaceFactoryImpl::AppendOrRemoveUidL( const TEmailUidAppendRemoveMode aMode ) { // Read buffer length TInt bufLength( 0 ); User::LeaveIfError( RProperty::Get( KEmailShutdownPsCategory, EEmailPsKeyPlatformApiAppsToCloseLength, bufLength ) ); // Allocate buffer for reading and then read the list of UIDs from P&S. // Adding some extra buffer just in case the size key and actual list // are out of sync. This shouldn't happen, but you never know. HBufC8* readBuf = HBufC8::NewLC( bufLength + KEmailUidExtraBuffer ); TPtr8 readPtr = readBuf->Des(); User::LeaveIfError( RProperty::Get( KEmailShutdownPsCategory, EEmailPsKeyPlatformApiAppsToClose, readPtr ) ); // For writing get the size of the original buffer + room for our own UID // if needed TInt writeBufSize = readPtr.Length(); if( aMode == EEmailUidModeAppend ) { writeBufSize += KEmailPlatformApiUidItemSize; } HBufC8* writeBuf = HBufC8::NewLC( writeBufSize ); TPtr8 writePtr = writeBuf->Des(); // Read and write streams used to read/write the UIDs from/to descriptors RDesReadStream readStream( readPtr ); CleanupClosePushL( readStream ); RDesWriteStream writeStream( writePtr ); CleanupClosePushL( writeStream ); // Get our own process UID RProcess ownProcess; TUid ownUid = ownProcess.SecureId(); ownProcess.Close(); TInt itemsCount = readPtr.Length() / KEmailPlatformApiUidItemSize; TBool ownUidFound = EFalse; TInt writeLength = 0; for ( TInt ii = 0;ii < itemsCount; ++ii ) { // Read next UID from the stream TUid item = TUid::Uid( readStream.ReadInt32L() ); // We can skip our own UID. If we are removing, then we don't want // our UID to be written. If we are adding, we don't need to set // the new values as our UID already exists in the list. if( item == ownUid ) { ownUidFound = ETrue; if( aMode == EEmailUidModeAppend ) { // Our own UID is already in the list, so no need to update // the list. Hence we can quit here. break; } } else { writeStream.WriteInt32L( item.iUid ); writeLength += KEmailPlatformApiUidItemSize; } } // If we are appending our UID and it wasn't found from the list, // write it to the stream if( aMode == EEmailUidModeAppend && !ownUidFound ) { writeStream.WriteInt32L( ownUid.iUid ); writeLength += KEmailPlatformApiUidItemSize; } // Set correct length for the write ptr buffer as it might not be // updated correctly by the write stream writePtr.SetLength( writeLength ); // Set new values to P&S only if something has changed, so either: // 1) We are appending our UID and it didn't exist before // 2) We are removing our UID and it did exist before if( ( aMode == EEmailUidModeAppend && !ownUidFound ) || ( aMode == EEmailUidModeRemove && ownUidFound ) ) { // Write first the UID list as it is more probable to fail, writing // plain integer value shouldn't fail in any case. This way these // values stay in sync also in case of error, as the list length // gets updated only if the list itself is updated succesfully. User::LeaveIfError( RProperty::Set( KEmailShutdownPsCategory, EEmailPsKeyPlatformApiAppsToClose, writePtr ) ); User::LeaveIfError( RProperty::Set( KEmailShutdownPsCategory, EEmailPsKeyPlatformApiAppsToCloseLength, writeLength ) ); } CleanupStack::PopAndDestroy( 4, readBuf ); }