adaptationlayer/modematadaptation/modematcontroller_dll/src/ccommandmodereq.cpp
changeset 0 63b37f68c1ce
child 9 8486d82aef45
equal deleted inserted replaced
-1:000000000000 0:63b37f68c1ce
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "ccommandmodereq.h"
       
    21 #include "modemattrace.h"
       
    22 #include "modematclientsrv.h"
       
    23 #include "rmodematcontroller.h"
       
    24 
       
    25 const TUint KCommandModeBufLength = 1;
       
    26 
       
    27 CCommandModeReq::CCommandModeReq( RModemAtController* aClient ) :
       
    28         CActive( EPriorityNormal ),
       
    29         iClient( aClient ),
       
    30         iResponseBuf(NULL),
       
    31         iResponse(NULL,0)
       
    32     { 
       
    33     C_TRACE((_L("CCommandModeReq::CCommandModeReq()")));
       
    34     CActiveScheduler::Add( this );
       
    35     iResponseBuf = HBufC8::NewL( KCommandModeBufLength );
       
    36     iResponse.Set( iResponseBuf->Des() );
       
    37     iClient->SendReceiveCommandMode( iResponse, iStatus );
       
    38     SetActive();
       
    39     }
       
    40 
       
    41 CCommandModeReq::~CCommandModeReq() 
       
    42     {
       
    43     C_TRACE((_L("CCommandModeReq::~CCommandModeReq()")));
       
    44     Cancel();
       
    45     delete iResponseBuf;
       
    46     iResponseBuf = NULL;
       
    47     }
       
    48 
       
    49  void CCommandModeReq::RunL() 
       
    50     {
       
    51     C_TRACE((_L("CCommandModeReq::RunL()")));
       
    52 
       
    53     if( iStatus.Int() == KErrNone ) 
       
    54         {
       
    55         C_TRACE((_L("CCommandModeReq RunL response: 0x%x"), &iResponse));
       
    56         TLex8 lex( iResponse );
       
    57         TInt mode( 0 );
       
    58         if( lex.Val( mode ) == KErrNone )
       
    59             {
       
    60             C_TRACE((_L("CCommandModeReq command mode %d changed"), mode));
       
    61             iClient->CommandModeChanged( iStatus.Int(), (TCommandMode) mode );
       
    62             // Start receiving again
       
    63             iResponse.Zero();
       
    64             iClient->SendReceiveCommandMode( iResponse, iStatus );
       
    65             SetActive();
       
    66             }
       
    67         else
       
    68             {
       
    69             C_TRACE((_L("CCommandModeReq RunL lex failed %d"), lex.Val( mode )));
       
    70             delete this;
       
    71             }
       
    72         }
       
    73     else if( iStatus.Int() == KErrCancel )
       
    74         {
       
    75         C_TRACE((_L("CCommandModeReq RunL cancelled - delete")));
       
    76         delete this;
       
    77         }
       
    78     }
       
    79  
       
    80 void CCommandModeReq::DoCancel() 
       
    81     {
       
    82     C_TRACE((_L("CCommandModeReq::DoCancel()")));
       
    83     iClient->SendReceiveCommandModeCancel();
       
    84     }
       
    85