Revision: 201015 RCL_3 PDK_3.0.i
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 27 Apr 2010 17:33:22 +0300
branchRCL_3
changeset 15 c47ebe2ac36c
parent 12 031b9cffe6e4
child 19 2702348f1fe7
Revision: 201015 Kit: 201017
localconnectivityservice/dun/utils/inc/DunDataPusher.h
localconnectivityservice/dun/utils/inc/DunDownstream.h
localconnectivityservice/dun/utils/inc/DunSignalCopy.h
localconnectivityservice/dun/utils/inc/DunSignalNotify.h
localconnectivityservice/dun/utils/inc/DunTransporter.h
localconnectivityservice/dun/utils/src/DunDataPusher.cpp
localconnectivityservice/dun/utils/src/DunDownstream.cpp
localconnectivityservice/dun/utils/src/DunSignalCopy.cpp
localconnectivityservice/dun/utils/src/DunSignalNotify.cpp
localconnectivityservice/dun/utils/src/DunTransUtils.cpp
localconnectivityservice/obexserviceman/group/obexserviceman.mmp
localconnectivityservice/obexserviceman/utils/src/obexutilsmessagehandler.cpp
--- a/localconnectivityservice/dun/utils/inc/DunDataPusher.h	Wed Apr 14 16:52:35 2010 +0300
+++ b/localconnectivityservice/dun/utils/inc/DunDataPusher.h	Tue Apr 27 17:33:22 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -78,8 +78,7 @@
  *  @lib dunutils.lib
  *  @since S60 v3.2
  */
-NONSHARABLE_CLASS( CDunDataPusher ) : public CActive,
-                                      public MDunEndpointReady
+NONSHARABLE_CLASS( CDunDataPusher ) : public CActive
     {
 
 public:
@@ -238,24 +237,6 @@
      */
     void DoCancel();
 
-// from base class MDunEndpointReady
-
-    /**
-     * Gets called when endpoint is ready
-     *
-     * @since S60 5.0
-     * @return None
-     */
-    void NotifyEndpointReady();
-
-    /**
-     * Gets called when endpoint is not ready
-     *
-     * @since S60 5.0
-     * @return None
-     */
-    void NotifyEndpointNotReady();
-
 private:  // data
 
     /**
@@ -285,11 +266,6 @@
     TInt iEventIndex;
 
     /**
-     * Flag to be set when endpoint is ready or not
-     */
-    TBool iEPReady;
-
-    /**
      * RSocket object of local media side
      * If this is set then iComm is not used
      * Not own.
--- a/localconnectivityservice/dun/utils/inc/DunDownstream.h	Wed Apr 14 16:52:35 2010 +0300
+++ b/localconnectivityservice/dun/utils/inc/DunDownstream.h	Tue Apr 27 17:33:22 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -156,14 +156,6 @@
     TInt AddToQueueAndSend( const TDesC8 *aPushedData,
                             MDunCompletionReporter* aCallback );
 
-    /**
-     * Gets the endpoint readiness handler
-     *
-     * @since S60 5.0
-     * @return Endpoint readiness handler
-     */
-    MDunEndpointReady* EndpointReadyHandler();
-
 private:
 
     CDunDownstream( MDunTransporterUtilityAux* aUtility );
--- a/localconnectivityservice/dun/utils/inc/DunSignalCopy.h	Wed Apr 14 16:52:35 2010 +0300
+++ b/localconnectivityservice/dun/utils/inc/DunSignalCopy.h	Tue Apr 27 17:33:22 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -64,16 +64,6 @@
     TInt AddCallback( MDunConnMon* aCallback );
 
     /**
-     * Adds callback for endpoint readiness
-     * The callback will be called when the endpoint is ready or not ready
-     *
-     * @since S60 5.0
-     * @param aEPCallback Callback to call when writes can/can't be done
-     * @return Symbian error code on error, KErrNone otherwise
-     */
-    TInt AddEndpointReadyCallback( MDunEndpointReady* aEPCallback );
-
-    /**
      * Sets media to use for this endpoint monitor
      *
      * @since S60 3.2
@@ -160,15 +150,6 @@
      */
     void ChangeDownstreamSignal( TUint aSetMask, TUint aClearMask );
 
-    /**
-     * Reports endpoint ready or not ready
-     *
-     * @since S60 5.0
-     * @param aReady ETrue if endpoint ready, EFalse otherwise
-     * @return None
-     */
-    void ReportEndpointReady( TBool aReady );
-
 // from base class CActive
 
     /*
@@ -198,12 +179,6 @@
     RPointerArray<MDunConnMon> iCallbacks;
 
     /**
-     * Callback(s) to call when notification(s) via MDunEndpointReady to be made
-     * Normally contains only one callback for upstream
-     */
-    RPointerArray<MDunEndpointReady> iERCallbacks;
-
-    /**
      * Callback(s) to call when command mode starts or ends
      * Usually two needed: one for upstream and second for downstream
      */
--- a/localconnectivityservice/dun/utils/inc/DunSignalNotify.h	Wed Apr 14 16:52:35 2010 +0300
+++ b/localconnectivityservice/dun/utils/inc/DunSignalNotify.h	Tue Apr 27 17:33:22 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -65,16 +65,6 @@
     TInt AddCallback( MDunConnMon* aCallback );
 
     /**
-     * Adds callback for endpoint readiness
-     * The callback will be called when the endpoint is ready or not ready
-     *
-     * @since S60 5.0
-     * @param aERCallback Callback to call when writes can/can't be done
-     * @return Symbian error code on error, KErrNone otherwise
-     */
-    TInt AddEndpointReadyCallback( MDunEndpointReady* aERCallback );
-
-    /**
      * Sets media to use for this endpoint monitor (network side)
      *
      * @since S60 3.2
@@ -131,15 +121,6 @@
      */
     void ReportSignalChange( TUint aSetMask, TUint aClearMask );
 
-    /**
-     * Reports endpoint ready or not ready
-     *
-     * @since S60 5.0
-     * @param aReady ETrue if endpoint ready, EFalse otherwise
-     * @return None
-     */
-    void ReportEndpointReady( TBool aReady );
-
 // from base class CActive
 
     /*
@@ -169,12 +150,6 @@
     RPointerArray<MDunConnMon> iCallbacks;
 
     /**
-     * Callback(s) to call when notification(s) via MDunEndpointReady to be made
-     * Normally contains only one callback for upstream
-     */
-    RPointerArray<MDunEndpointReady> iERCallbacks;
-
-    /**
      * Pointer to common utility class
      * Not own.
      */
--- a/localconnectivityservice/dun/utils/inc/DunTransporter.h	Wed Apr 14 16:52:35 2010 +0300
+++ b/localconnectivityservice/dun/utils/inc/DunTransporter.h	Tue Apr 27 17:33:22 2010 +0300
@@ -188,35 +188,6 @@
 	};
 
 /**
- *  Notification interface class to report endpoint readiness
- *
- *  @lib dunutils.lib
- *  @since S60 v5.0
- */
-NONSHARABLE_CLASS( MDunEndpointReady )
-	{
-
-public:
-
-    /**
-     * Gets called when endpoint is ready
-     *
-     * @since S60 5.0
-     * @return None
-     */
-    virtual void NotifyEndpointReady() = 0;
-
-    /**
-     * Gets called when endpoint is not ready
-     *
-     * @since S60 5.0
-     * @return None
-     */
-    virtual void NotifyEndpointNotReady() = 0;
-
-	};
-
-/**
  *  Notification interface class to report service advertisement status changes
  *
  *  @lib dunutils.lib
--- a/localconnectivityservice/dun/utils/src/DunDataPusher.cpp	Wed Apr 14 16:52:35 2010 +0300
+++ b/localconnectivityservice/dun/utils/src/DunDataPusher.cpp	Tue Apr 27 17:33:22 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -312,7 +312,6 @@
     // Don't initialize iStreamCallback here (it is set through NewL)
     iPushState = EDunStateIdle;
     iEventIndex = 0;
-    iEPReady = EFalse;
     iSocket = NULL;
     iComm = NULL;
     }
@@ -336,13 +335,6 @@
         return KErrGeneral;
         }
     iStatus = KRequestPending;
-    if ( !iEPReady )
-        {
-        SetActive();
-        TRequestStatus* requestStatus = &iStatus;
-        User::RequestComplete( requestStatus, KErrNone );
-        return KErrNone;
-        }
     const TDesC8 *pushedData = iEventQueue[iEventIndex].iPushedData;
     if ( iComm )
         {
@@ -455,27 +447,3 @@
         }
     FTRACE(FPrint( _L("CDunDataPusher::DoCancel() complete" )));
     }
-
-// ---------------------------------------------------------------------------
-// From class MDunEndpointReady.
-// Gets called when endpoint is ready
-// ---------------------------------------------------------------------------
-//
-void CDunDataPusher::NotifyEndpointReady()
-    {
-    FTRACE(FPrint( _L("CDunDataPusher::NotifyEndpointReady()" )));
-    iEPReady = ETrue;
-    FTRACE(FPrint( _L("CDunDataPusher::NotifyEndpointReady() complete" )));
-    }
-
-// ---------------------------------------------------------------------------
-// From class MDunEndpointReady.
-// Gets called when endpoint is not ready
-// ---------------------------------------------------------------------------
-//
-void CDunDataPusher::NotifyEndpointNotReady()
-    {
-    FTRACE(FPrint( _L("CDunDataPusher::NotifyEndpointNotReady()" )));
-    iEPReady = EFalse;
-    FTRACE(FPrint( _L("CDunDataPusher::NotifyEndpointNotReady() complete" )));
-    }
--- a/localconnectivityservice/dun/utils/src/DunDownstream.cpp	Wed Apr 14 16:52:35 2010 +0300
+++ b/localconnectivityservice/dun/utils/src/DunDownstream.cpp	Tue Apr 27 17:33:22 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -143,17 +143,6 @@
     }
 
 // ---------------------------------------------------------------------------
-// Gets the endpoint readiness handler
-// ---------------------------------------------------------------------------
-//
-MDunEndpointReady* CDunDownstream::EndpointReadyHandler()
-    {
-    FTRACE(FPrint( _L("CDunDownstream::EndpointReadyHandler()" ) ));
-    FTRACE(FPrint( _L("CDunDownstream::EndpointReadyHandler() complete" ) ));
-    return iPushData.iDataPusher;
-    }
-
-// ---------------------------------------------------------------------------
 // Starts downstream by issuing read request
 // ---------------------------------------------------------------------------
 //
--- a/localconnectivityservice/dun/utils/src/DunSignalCopy.cpp	Wed Apr 14 16:52:35 2010 +0300
+++ b/localconnectivityservice/dun/utils/src/DunSignalCopy.cpp	Tue Apr 27 17:33:22 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -65,8 +65,6 @@
     Stop();
     // AddCallback()
     iCallbacks.Close();
-    // AddWriteReadyCallback()
-    iERCallbacks.Close();
     // Internal
     Initialize();
     FTRACE(FPrint( _L("CDunSignalCopy::ResetData() complete") ));
@@ -102,35 +100,6 @@
     }
 
 // ---------------------------------------------------------------------------
-// Adds callback for endpoint readiness
-// The callback will be called when the endpoint is ready or not ready
-// ---------------------------------------------------------------------------
-//
-TInt CDunSignalCopy::AddEndpointReadyCallback( MDunEndpointReady* aERCallback )
-    {
-    FTRACE(FPrint( _L("CDunSignalCopy::AddEndpointReadyCallback()" ) ));
-    if ( !aERCallback )
-        {
-        FTRACE(FPrint( _L("CDunSignalCopy::AddEndpointReadyCallback() (aERCallback) not initialized!" ) ));
-        return KErrGeneral;
-        }
-    TInt retTemp = iERCallbacks.Find( aERCallback );
-    if ( retTemp != KErrNotFound )
-        {
-        FTRACE(FPrint( _L("CDunSignalCopy::AddEndpointReadyCallback() (already exists) complete" ) ));
-        return KErrAlreadyExists;
-        }
-    retTemp = iERCallbacks.Append( aERCallback );
-    if ( retTemp != KErrNone )
-        {
-        FTRACE(FPrint( _L("CDunSignalCopy::AddEndpointReadyCallback() (append failed!) complete" ) ));
-        return retTemp;
-        }
-    FTRACE(FPrint( _L("CDunSignalCopy::AddEndpointReadyCallback() complete" ) ));
-    return KErrNone;
-    }
-
-// ---------------------------------------------------------------------------
 // Sets media to use for this endpoint monitor
 // ---------------------------------------------------------------------------
 //
@@ -336,13 +305,11 @@
         FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeUpstream() checking RTS..." ) ));
         if ( iSignals & KSignalRTS )  // RTS changed to high
             {
-            ReportEndpointReady( ETrue );
             ChangeUpstreamSignal( KSignalRTS, 0 );
             FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeUpstream() RTS changed high" ) ));
             }
         else  // RTS changed to low
             {
-            ReportEndpointReady( EFalse );
             ChangeUpstreamSignal( 0, KSignalRTS );
             FTRACE(FPrint( _L("CDunSignalCopy::ManageSignalChangeUpstream() RTS changed low" ) ));
             }
@@ -465,28 +432,6 @@
     }
 
 // ---------------------------------------------------------------------------
-// Reports endpoint ready or not ready
-// ---------------------------------------------------------------------------
-//
-void CDunSignalCopy::ReportEndpointReady( TBool aReady )
-    {
-    FTRACE(FPrint( _L("CDunSignalCopy::ReportEndpointReady()" ) ));
-    TInt count = iERCallbacks.Count();
-    for ( TInt i=0; i<count; i++ )
-        {
-        if ( aReady )
-            {
-            iERCallbacks[i]->NotifyEndpointReady();
-            }
-        else  // not ready
-            {
-            iERCallbacks[i]->NotifyEndpointNotReady();
-            }
-        }
-    FTRACE(FPrint( _L("CDunSignalCopy::ReportEndpointReady() complete" ) ));
-    }
-
-// ---------------------------------------------------------------------------
 // From class CActive.
 // Gets called when line status changes
 // ---------------------------------------------------------------------------
--- a/localconnectivityservice/dun/utils/src/DunSignalNotify.cpp	Wed Apr 14 16:52:35 2010 +0300
+++ b/localconnectivityservice/dun/utils/src/DunSignalNotify.cpp	Tue Apr 27 17:33:22 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -65,8 +65,6 @@
     Stop();
     // AddCallback()
     iCallbacks.Close();
-    // AddEndpointReadyCallback()
-    iERCallbacks.Close();
     // Internal
     Initialize();
     FTRACE(FPrint( _L("CDunSignalNotify::ResetData() complete") ));
@@ -103,37 +101,6 @@
     }
 
 // ---------------------------------------------------------------------------
-// Adds callback for endpoint readiness
-// The callback will be called when the endpoint is ready or not ready
-// ---------------------------------------------------------------------------
-//
-TInt CDunSignalNotify::AddEndpointReadyCallback(
-    MDunEndpointReady* aERCallback )
-    {
-    FTRACE(FPrint( _L("CDunSignalNotify::AddEndpointReadyCallback()" ) ));
-    if ( !aERCallback )
-        {
-        FTRACE(FPrint( _L("CDunSignalNotify::AddEndpointReadyCallback() (aERCallback) not initialized!" ) ));
-        return KErrGeneral;
-        }
-    TInt retTemp = iERCallbacks.Find( aERCallback );
-    if ( retTemp != KErrNotFound )
-        {
-        FTRACE(FPrint( _L("CDunSignalNotify::AddEndpointReadyCallback() (already exists) complete" ) ));
-        return KErrAlreadyExists;
-        }
-    retTemp = iERCallbacks.Append( aERCallback );
-    if ( retTemp != KErrNone )
-        {
-        FTRACE(FPrint( _L("CDunSignalNotify::AddEndpointReadyCallback() (append failed!) complete" ) ));
-        return retTemp;
-        }
-    ReportEndpointReady( ETrue );  // report immediately as this is a hack
-    FTRACE(FPrint( _L("CDunSignalNotify::AddEndpointReadyCallback() complete" ) ));
-    return KErrNone;
-    }
-
-// ---------------------------------------------------------------------------
 // Sets media to use for this endpoint monitor
 // ---------------------------------------------------------------------------
 //
@@ -375,28 +342,6 @@
     }
 
 // ---------------------------------------------------------------------------
-// Reports endpoint ready or not ready
-// ---------------------------------------------------------------------------
-//
-void CDunSignalNotify::ReportEndpointReady( TBool aReady )
-    {
-    FTRACE(FPrint( _L("CDunSignalNotify::ReportEndpointReady()" ) ));
-    TInt count = iERCallbacks.Count();
-    for ( TInt i=0; i<count; i++ )
-        {
-        if ( aReady )
-            {
-            iERCallbacks[i]->NotifyEndpointReady();
-            }
-        else  // not ready
-            {
-            iERCallbacks[i]->NotifyEndpointNotReady();
-            }
-        }
-    FTRACE(FPrint( _L("CDunSignalNotify::ReportEndpointReady() complete" ) ));
-    }
-
-// ---------------------------------------------------------------------------
 // From class CActive.
 // Gets called when line status changes
 // ---------------------------------------------------------------------------
--- a/localconnectivityservice/dun/utils/src/DunTransUtils.cpp	Wed Apr 14 16:52:35 2010 +0300
+++ b/localconnectivityservice/dun/utils/src/DunTransUtils.cpp	Tue Apr 27 17:33:22 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -651,7 +651,6 @@
     CDunUpstream* upstream = channelData.iUpstreamRW;
     CDunDownstream* downstream = channelData.iDownstreamRW;
 
-    // Set command notify endpoint readiness callbacks
     if ( aDirection == EDunReaderUpstream )
         {
         // Initialize stream for AT parsing (ignore errors)
@@ -676,9 +675,6 @@
             {
             // Add callback (ignore errors)
             channelData.iUpstreamSignalCopy->AddCallback( aCallback );
-            // Add endpoint readiness callback (ignore errors )
-            MDunEndpointReady* erHandler = downstream->EndpointReadyHandler();
-            channelData.iUpstreamSignalCopy->AddEndpointReadyCallback( erHandler );
             }
         }
     else if ( streamType == EDunStreamTypeDownstream )
@@ -688,8 +684,6 @@
             {
             // Add callback (ignore errors)
             channelData.iDownstreamSignalCopy->AddCallback( aCallback );
-            // Note: Nokia's adaptation doesn't support full signals so don't
-            // add the endpoint readiness callback here
             }
         }
     else
@@ -709,9 +703,6 @@
             }
         // Add callback (ignore errors)
         channelData.iSignalNotify->AddCallback( aCallback );
-        // Add endpoint readiness callback (ignore errors )
-        MDunEndpointReady* erHandler = downstream->EndpointReadyHandler();
-        channelData.iSignalNotify->AddEndpointReadyCallback( erHandler );
         }
 
     // Add callback (ignore errors)
--- a/localconnectivityservice/obexserviceman/group/obexserviceman.mmp	Wed Apr 14 16:52:35 2010 +0300
+++ b/localconnectivityservice/obexserviceman/group/obexserviceman.mmp	Tue Apr 27 17:33:22 2010 +0300
@@ -28,7 +28,7 @@
 CAPABILITY	CAP_SERVER CommDD NetworkControl LocalServices
 VENDORID	VID_DEFAULT
 
-EPOCHEAPSIZE  0x500 0x400000
+EPOCHEAPSIZE  0x500 0x800000
 
 EPOCSTACKSIZE  0x4000
 
--- a/localconnectivityservice/obexserviceman/utils/src/obexutilsmessagehandler.cpp	Wed Apr 14 16:52:35 2010 +0300
+++ b/localconnectivityservice/obexserviceman/utils/src/obexutilsmessagehandler.cpp	Tue Apr 27 17:33:22 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002,2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -137,40 +137,51 @@
     {
     FLOG(_L("[OBEXUTILS]\t StoreAsRichTextL()"));
 
-    // Read the file into buffer
-    
-    CBufFlat* buffer = CBufFlat::NewL( 16 );
-    CleanupStack::PushL(buffer);  // 1st push
-
     TInt fileLength = 0;
     User::LeaveIfError( aFile.Size( fileLength ) );
-    
-    buffer->ResizeL( fileLength );
-    TPtr8 bufferPtr = buffer->Ptr(0);
-    
-    User::LeaveIfError( aFile.Read( bufferPtr ) );
+
+    // Calculate the number of blocks to read
+    const TInt blockSize = 128 * 1024;
+    TInt fullBlockCnt = fileLength / blockSize;
+    if (fileLength % blockSize > 0)
+        {
+        fullBlockCnt++;
+        }
+
+    CRichText* richText = ConstructRichTextLC(); // 1st, 2nd, 3rd push
+
+    RBuf8 buffer8;
+    CleanupClosePushL(buffer8);  // 4th push
+    buffer8.CreateL( blockSize );
+    RBuf buffer16;
+    CleanupClosePushL(buffer16); // 5th push
+    buffer16.CreateL(blockSize);
     
-    // In order for Bio to understand 8-bit binary data, 
-    // it needs to be stored in wide rich text object
-    // in the low byte of each word with the upper byte as 0.
-    // Do not use UTF8, just convert 8-bit to 16-bit.
-
-    CRichText* richText = ConstructRichTextLC(); // 2nd, 3rd, 4th push
-    HBufC* convert8BitTo16Bit = HBufC::NewLC(fileLength);  // 5th push
-    convert8BitTo16Bit->Des().Copy( bufferPtr );
-    buffer->Reset();  // free unused memory before InsertL()
+    // Read the file into buffer in small chunks  
+    TInt readBytes = 0;
+    for (TInt i = 0; i < fullBlockCnt; ++i)
+        {
+        User::LeaveIfError( aFile.Read( buffer8 ) );
     
-    richText->InsertL(0, *convert8BitTo16Bit);
-    CleanupStack::PopAndDestroy(convert8BitTo16Bit);
-    // -1 pop: free unused memory before StoreBodyTextL()
+        // In order for Bio to understand 8-bit binary data, 
+        // it needs to be stored in wide rich text object
+        // in the low byte of each word with the upper byte as 0.
+        // Do not use UTF8, just convert 8-bit to 16-bit.  
+        buffer16.Copy( buffer8 );
+        
+        richText->InsertL(readBytes, buffer16);
+        readBytes += buffer8.Length();
+        }
+    CleanupStack::PopAndDestroy(2, &buffer8);
+    // -2 pop: free unused memory before StoreBodyTextL()
 
     CMsvStore* parentStore = aParentEntry->EditStoreL();
-    CleanupStack::PushL(parentStore);   // 5th push
+    CleanupStack::PushL(parentStore);   // 4th push
     parentStore->StoreBodyTextL(*richText);
     parentStore->CommitL();
 
-    CleanupStack::PopAndDestroy(5);  // parentStore, richText, richParaFormatLayer,
-                                     // richCharFormatLayer, buffer
+    CleanupStack::PopAndDestroy(4);  // parentStore, richText, richParaFormatLayer,
+                                     // richCharFormatLayer
 
     FLOG(_L("[OBEXUTILS]\t StoreAsRichTextL() completed"));
     }
@@ -327,10 +338,10 @@
     TPtrC mimeType16(buf16->Des());
     CleanupStack::PopAndDestroy();   //   buf16
     
-    CUpdateMusicCollection* updateMusiccollection =CUpdateMusicCollection::NewL() ;
-    if (updateMusiccollection->isSupported(mimeType16))
+    CUpdateMusicCollection* updateMusicCollection = CUpdateMusicCollection::NewL() ;
+    if (updateMusicCollection->isSupported(mimeType16))
         {
-        updateMusiccollection->addToCollectionL(aFileName);
+        updateMusicCollection->addToCollectionL(aFileName);
         }
     
     aAttachInfo->SetMimeTypeL( mimeType );