atcommands/modematplugin/src/modematplugin.cpp
changeset 63 bcf742120177
parent 37 91746b151f97
--- a/atcommands/modematplugin/src/modematplugin.cpp	Wed Aug 18 09:59:05 2010 +0300
+++ b/atcommands/modematplugin/src/modematplugin.cpp	Fri Sep 17 08:30:56 2010 +0300
@@ -246,14 +246,18 @@
         TRACE_FUNC_EXIT
         return KErrNotFound;
         }
-    aDstBuffer.Create( iReplyBuffer, partLength );
-    iReplyBuffer.Delete( 0, partLength );
+    aDstBuffer.Close();
+    TInt err = aDstBuffer.Create( iReplyBuffer, partLength );
+    if ( !err )
+    	{
+    	iReplyBuffer.Delete( 0, partLength );
+    	}
     if ( iReplyBuffer.Length() == 0 )
         {
         iReplyBuffer.Close();
         }
     TRACE_FUNC_EXIT
-    return KErrNone;
+    return err;
     }
 
 // ---------------------------------------------------------------------------
@@ -261,46 +265,40 @@
 // request to ATEXT. Uses iReplyBuffer for reply storage.
 // ---------------------------------------------------------------------------
 //
-TInt CModemAtPlugin::CreateReplyAndComplete( TATExtensionReplyType aReplyType,
+void CModemAtPlugin::CreateReplyAndComplete( TATExtensionReplyType aReplyType,
                                               const TDesC8& aSrcBuffer,
                                               TInt aError )
     {
     TRACE_FUNC_ENTRY
     iReplyBuffer.Close();
-    if ( aError != KErrNone )
-        {
-        HandleCommandCompleted( aError, EReplyTypeUndefined );
-        iHcCmd = NULL;
-        iHcReply = NULL;
-        TRACE_FUNC_EXIT
-        return KErrNone;
-        }
-    if ( !iHcReply )
-        {
-        TRACE_FUNC_EXIT
-        return KErrGeneral;
-        }
-    switch ( aReplyType )
+    ASSERT(iHcReply); 
+    if ( !aError )
         {
-        case EReplyTypeOther:
-            iReplyBuffer.Create( aSrcBuffer );
-            break;
-        case EReplyTypeOk:
-            CreateOkOrErrorReply( iReplyBuffer, ETrue );
-            break;
-        case EReplyTypeError:
-            CreateOkOrErrorReply( iReplyBuffer, EFalse );
-            break;
-        default:
-            TRACE_FUNC_EXIT
-            return KErrGeneral;
+		switch ( aReplyType )
+			{
+			case EReplyTypeOther:
+				aError = iReplyBuffer.Create( aSrcBuffer );
+				break;
+			case EReplyTypeOk:
+				aError = CreateOkOrErrorReply( iReplyBuffer, ETrue );
+				break;
+			case EReplyTypeError:
+				aError = CreateOkOrErrorReply( iReplyBuffer, EFalse );
+				break;
+			default:
+				TRACE_FUNC_EXIT
+				aError = KErrGeneral;
+			}
         }
-    CreatePartOfReply( *iHcReply );
-    HandleCommandCompleted( KErrNone, aReplyType );
+    
+    if ( !aError )
+    	{
+    	aError = CreatePartOfReply( *iHcReply );
+    	}
     iHcCmd = NULL;
     iHcReply = NULL;
+    HandleCommandCompleted( aError, aError ? EReplyTypeUndefined : aReplyType );
     TRACE_FUNC_EXIT
-    return KErrNone;
     }
 
 // ---------------------------------------------------------------------------