localconnectivityservice/dun/atext/src/DunAtNvramListen.cpp
changeset 54 4dc88a4ac6f4
parent 52 866b4af7ffbe
equal deleted inserted replaced
52:866b4af7ffbe 54:4dc88a4ac6f4
     1 /*
     1 /*
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    77 // ---------------------------------------------------------------------------
    77 // ---------------------------------------------------------------------------
    78 //
    78 //
    79 TInt CDunAtNvramListen::IssueRequest()
    79 TInt CDunAtNvramListen::IssueRequest()
    80     {
    80     {
    81     FTRACE(FPrint( _L("CDunAtNvramListen::IssueRequest()") ));
    81     FTRACE(FPrint( _L("CDunAtNvramListen::IssueRequest()") ));
    82     if ( iNvramHandleState != EDunStateIdle )
    82     if ( IsActive() )
    83         {
    83         {
    84         FTRACE(FPrint( _L("CDunAtNvramListen::IssueRequest() (not ready) complete") ));
    84         FTRACE(FPrint( _L("CDunAtNvramListen::IssueRequest() (not ready) complete") ));
    85         return KErrNotReady;
    85         return KErrNotReady;
    86         }
    86         }
    87     if ( !iStarted )
    87     if ( !iStarted )
    88         {
    88         {
    89         iAtCmdExtCommon->GetNvramStatus( iNvramBuffer );
    89         iAtCmdExtCommon->GetNvramStatus( iNvramBuffer );
    90         iAtCmdExt->BroadcastNvramStatusChange( iNvramBuffer );
    90         iAtCmdExt->BroadcastNvramStatusChange( iNvramBuffer );
    91         iStarted = ETrue;
    91         iStarted = ETrue;
    92         }
    92         }
    93     iStatus = KRequestPending;
       
    94     iNvramHandleState = EDunStateNvramListening;
       
    95     iAtCmdExtCommon->ReceiveNvramStatusChange( iStatus, iNvramBuffer );
    93     iAtCmdExtCommon->ReceiveNvramStatusChange( iStatus, iNvramBuffer );
    96     SetActive();
    94     SetActive();
    97     FTRACE(FPrint( _L("CDunAtNvramListen::IssueRequest() complete") ));
    95     FTRACE(FPrint( _L("CDunAtNvramListen::IssueRequest() complete") ));
    98     return KErrNone;
    96     return KErrNone;
    99     }
    97     }
   100 
    98 
   101 // ---------------------------------------------------------------------------
    99 // ---------------------------------------------------------------------------
   102 // Stops waiting for NVRAM status changes
   100 // Stops waiting for NVRAM status changes
   103 // ---------------------------------------------------------------------------
   101 // ---------------------------------------------------------------------------
   104 //
   102 //
   105 TInt CDunAtNvramListen::Stop()
   103 void CDunAtNvramListen::Stop()
   106     {
   104     {
   107     FTRACE(FPrint( _L("CDunAtNvramListen::Stop()") ));
   105     FTRACE(FPrint( _L("CDunAtNvramListen::Stop()") ));
   108     if ( iNvramHandleState != EDunStateNvramListening )
       
   109         {
       
   110         FTRACE(FPrint( _L("CDunAtNvramListen::Stop() (not ready) complete" )));
       
   111         return KErrNotReady;
       
   112         }
       
   113     iAtCmdExtCommon->CancelReceiveNvramStatusChange();
       
   114     Cancel();
   106     Cancel();
   115     iNvramHandleState = EDunStateIdle;
       
   116     FTRACE(FPrint( _L("CDunAtNvramListen::Stop() complete") ));
   107     FTRACE(FPrint( _L("CDunAtNvramListen::Stop() complete") ));
   117     // Note: Don't mark iStarted to EFalse here!
   108     // Note: Don't mark iStarted to EFalse here!
   118     return KErrNone;
       
   119     }
   109     }
   120 
   110 
   121 // ---------------------------------------------------------------------------
   111 // ---------------------------------------------------------------------------
   122 // CDunAtNvramListen::CDunAtNvramListen
   112 // CDunAtNvramListen::CDunAtNvramListen
   123 // ---------------------------------------------------------------------------
   113 // ---------------------------------------------------------------------------
   152 //
   142 //
   153 void CDunAtNvramListen::Initialize()
   143 void CDunAtNvramListen::Initialize()
   154     {
   144     {
   155     // Don't initialize iAtCmdExt here (it is set through NewL)
   145     // Don't initialize iAtCmdExt here (it is set through NewL)
   156     // Don't initialize iAtCmdExtCommon here (it is set through NewL)
   146     // Don't initialize iAtCmdExtCommon here (it is set through NewL)
   157     iNvramHandleState = EDunStateIdle;
       
   158     iStarted = EFalse;
   147     iStarted = EFalse;
   159     }
   148     }
   160 
   149 
   161 // ---------------------------------------------------------------------------
   150 // ---------------------------------------------------------------------------
   162 // From class CActive.
   151 // From class CActive.
   164 // ---------------------------------------------------------------------------
   153 // ---------------------------------------------------------------------------
   165 //
   154 //
   166 void CDunAtNvramListen::RunL()
   155 void CDunAtNvramListen::RunL()
   167     {
   156     {
   168     FTRACE(FPrint( _L("CDunAtNvramListen::RunL()") ));
   157     FTRACE(FPrint( _L("CDunAtNvramListen::RunL()") ));
   169     iNvramHandleState = EDunStateIdle;
       
   170     TInt retTemp = iStatus.Int();
   158     TInt retTemp = iStatus.Int();
   171     if ( retTemp != KErrNone )
   159     if ( retTemp != KErrNone )
   172         {
   160         {
   173         FTRACE(FPrint( _L("CDunAtNvramListen::RunL() (ERROR) complete (%d)"), retTemp ));
   161         FTRACE(FPrint( _L("CDunAtNvramListen::RunL() (ERROR) complete (%d)"), retTemp ));
   174         return;
   162         return;
   184 // ---------------------------------------------------------------------------
   172 // ---------------------------------------------------------------------------
   185 //
   173 //
   186 void CDunAtNvramListen::DoCancel()
   174 void CDunAtNvramListen::DoCancel()
   187     {
   175     {
   188     FTRACE(FPrint( _L("CDunAtNvramListen::DoCancel()") ));
   176     FTRACE(FPrint( _L("CDunAtNvramListen::DoCancel()") ));
       
   177     iAtCmdExtCommon->CancelReceiveNvramStatusChange();
   189     FTRACE(FPrint( _L("CDunAtNvramListen::DoCancel() complete") ));
   178     FTRACE(FPrint( _L("CDunAtNvramListen::DoCancel() complete") ));
   190     }
   179     }