atcommands/modematplugin/src/modematplugin.cpp
changeset 63 bcf742120177
parent 37 91746b151f97
equal deleted inserted replaced
52:4545c04e61e1 63:bcf742120177
   244     if ( iReplyBuffer.Length() < partLength )
   244     if ( iReplyBuffer.Length() < partLength )
   245         {
   245         {
   246         TRACE_FUNC_EXIT
   246         TRACE_FUNC_EXIT
   247         return KErrNotFound;
   247         return KErrNotFound;
   248         }
   248         }
   249     aDstBuffer.Create( iReplyBuffer, partLength );
   249     aDstBuffer.Close();
   250     iReplyBuffer.Delete( 0, partLength );
   250     TInt err = aDstBuffer.Create( iReplyBuffer, partLength );
       
   251     if ( !err )
       
   252     	{
       
   253     	iReplyBuffer.Delete( 0, partLength );
       
   254     	}
   251     if ( iReplyBuffer.Length() == 0 )
   255     if ( iReplyBuffer.Length() == 0 )
   252         {
   256         {
   253         iReplyBuffer.Close();
   257         iReplyBuffer.Close();
   254         }
   258         }
   255     TRACE_FUNC_EXIT
   259     TRACE_FUNC_EXIT
   256     return KErrNone;
   260     return err;
   257     }
   261     }
   258 
   262 
   259 // ---------------------------------------------------------------------------
   263 // ---------------------------------------------------------------------------
   260 // Creates an AT command reply based on the reply type and completes the
   264 // Creates an AT command reply based on the reply type and completes the
   261 // request to ATEXT. Uses iReplyBuffer for reply storage.
   265 // request to ATEXT. Uses iReplyBuffer for reply storage.
   262 // ---------------------------------------------------------------------------
   266 // ---------------------------------------------------------------------------
   263 //
   267 //
   264 TInt CModemAtPlugin::CreateReplyAndComplete( TATExtensionReplyType aReplyType,
   268 void CModemAtPlugin::CreateReplyAndComplete( TATExtensionReplyType aReplyType,
   265                                               const TDesC8& aSrcBuffer,
   269                                               const TDesC8& aSrcBuffer,
   266                                               TInt aError )
   270                                               TInt aError )
   267     {
   271     {
   268     TRACE_FUNC_ENTRY
   272     TRACE_FUNC_ENTRY
   269     iReplyBuffer.Close();
   273     iReplyBuffer.Close();
   270     if ( aError != KErrNone )
   274     ASSERT(iHcReply); 
   271         {
   275     if ( !aError )
   272         HandleCommandCompleted( aError, EReplyTypeUndefined );
   276         {
   273         iHcCmd = NULL;
   277 		switch ( aReplyType )
   274         iHcReply = NULL;
   278 			{
   275         TRACE_FUNC_EXIT
   279 			case EReplyTypeOther:
   276         return KErrNone;
   280 				aError = iReplyBuffer.Create( aSrcBuffer );
   277         }
   281 				break;
   278     if ( !iHcReply )
   282 			case EReplyTypeOk:
   279         {
   283 				aError = CreateOkOrErrorReply( iReplyBuffer, ETrue );
   280         TRACE_FUNC_EXIT
   284 				break;
   281         return KErrGeneral;
   285 			case EReplyTypeError:
   282         }
   286 				aError = CreateOkOrErrorReply( iReplyBuffer, EFalse );
   283     switch ( aReplyType )
   287 				break;
   284         {
   288 			default:
   285         case EReplyTypeOther:
   289 				TRACE_FUNC_EXIT
   286             iReplyBuffer.Create( aSrcBuffer );
   290 				aError = KErrGeneral;
   287             break;
   291 			}
   288         case EReplyTypeOk:
   292         }
   289             CreateOkOrErrorReply( iReplyBuffer, ETrue );
   293     
   290             break;
   294     if ( !aError )
   291         case EReplyTypeError:
   295     	{
   292             CreateOkOrErrorReply( iReplyBuffer, EFalse );
   296     	aError = CreatePartOfReply( *iHcReply );
   293             break;
   297     	}
   294         default:
       
   295             TRACE_FUNC_EXIT
       
   296             return KErrGeneral;
       
   297         }
       
   298     CreatePartOfReply( *iHcReply );
       
   299     HandleCommandCompleted( KErrNone, aReplyType );
       
   300     iHcCmd = NULL;
   298     iHcCmd = NULL;
   301     iHcReply = NULL;
   299     iHcReply = NULL;
   302     TRACE_FUNC_EXIT
   300     HandleCommandCompleted( aError, aError ? EReplyTypeUndefined : aReplyType );
   303     return KErrNone;
   301     TRACE_FUNC_EXIT
   304     }
   302     }
   305 
   303 
   306 // ---------------------------------------------------------------------------
   304 // ---------------------------------------------------------------------------
   307 // Creates a buffer for "OK" or "ERROR" reply based on the line settings
   305 // Creates a buffer for "OK" or "ERROR" reply based on the line settings
   308 // ---------------------------------------------------------------------------
   306 // ---------------------------------------------------------------------------