localconnectivityservice/dun/utils/src/DunSignalWaiter.cpp
changeset 60 841f70763fbe
parent 52 866b4af7ffbe
equal deleted inserted replaced
52:866b4af7ffbe 60:841f70763fbe
   128 // ---------------------------------------------------------------------------
   128 // ---------------------------------------------------------------------------
   129 //
   129 //
   130 TInt CDunSignalWaiter::IssueRequest()
   130 TInt CDunSignalWaiter::IssueRequest()
   131     {
   131     {
   132     FTRACE(FPrint( _L("CDunSignalWaiter::IssueRequest()" )));
   132     FTRACE(FPrint( _L("CDunSignalWaiter::IssueRequest()" )));
   133     if ( iSignalWaiterState != EDunStateIdle )
   133     if ( IsActive() )
   134         {
   134         {
   135         FTRACE(FPrint( _L("CDunSignalWaiter::IssueRequest() (not ready) complete" )));
   135         FTRACE(FPrint( _L("CDunSignalWaiter::IssueRequest() (not ready) complete" )));
   136         return KErrNotReady;
   136         return KErrNotReady;
   137         }
   137         }
   138     if ( !iComm )
   138     if ( !iComm )
   139         {
   139         {
   140         FTRACE(FPrint( _L("CDunSignalWaiter::IssueRequest() (iComm) not initialized!" ) ));
   140         FTRACE(FPrint( _L("CDunSignalWaiter::IssueRequest() (iComm) not initialized!" ) ));
   141         return KErrGeneral;
   141         return KErrGeneral;
   142         }
   142         }
   143     iStatus = KRequestPending;
       
   144     iSignalWaiterState = EDunStateSignalWaiting;
       
   145     iComm->NotifySignalChange( iStatus, iSignals, KSignalDCEInputs );
   143     iComm->NotifySignalChange( iStatus, iSignals, KSignalDCEInputs );
   146     SetActive();
   144     SetActive();
   147     FTRACE(FPrint( _L("CDunSignalWaiter::IssueRequest() complete" )));
   145     FTRACE(FPrint( _L("CDunSignalWaiter::IssueRequest() complete" )));
   148     return KErrNone;
   146     return KErrNone;
   149     }
   147     }
   150 
   148 
   151 // ---------------------------------------------------------------------------
   149 // ---------------------------------------------------------------------------
   152 // Stops monitoring for new data
   150 // Stops monitoring for new data
   153 // ---------------------------------------------------------------------------
   151 // ---------------------------------------------------------------------------
   154 //
   152 //
   155 TInt CDunSignalWaiter::Stop()
   153 void CDunSignalWaiter::Stop()
   156     {
   154     {
   157     FTRACE(FPrint( _L("CDunSignalWaiter::Stop()" )));
   155     FTRACE(FPrint( _L("CDunSignalWaiter::Stop()" )));
   158     if ( iSignalWaiterState != EDunStateSignalWaiting )
       
   159         {
       
   160         FTRACE(FPrint( _L("CDunSignalWaiter::Stop() (not ready) complete" )));
       
   161         return KErrNotReady;
       
   162         }
       
   163     if ( !iComm )
       
   164         {
       
   165         FTRACE(FPrint( _L("CDunSignalWaiter::Stop() (iComm) not initialized!" )));
       
   166         return KErrGeneral;
       
   167         }
       
   168     iComm->NotifySignalChangeCancel();
       
   169     Cancel();
   156     Cancel();
   170     iSignalWaiterState = EDunStateIdle;
       
   171     FTRACE(FPrint( _L("CDunSignalWaiter::Stop() complete" )));
   157     FTRACE(FPrint( _L("CDunSignalWaiter::Stop() complete" )));
   172     return KErrNone;
       
   173     }
   158     }
   174 
   159 
   175 // ---------------------------------------------------------------------------
   160 // ---------------------------------------------------------------------------
   176 // CDunSignalWaiter::CDunSignalWaiter
   161 // CDunSignalWaiter::CDunSignalWaiter
   177 // ---------------------------------------------------------------------------
   162 // ---------------------------------------------------------------------------
   204 //
   189 //
   205 void CDunSignalWaiter::Initialize()
   190 void CDunSignalWaiter::Initialize()
   206     {
   191     {
   207     FTRACE(FPrint( _L("CDunSignalWaiter::Initialize()" ) ));
   192     FTRACE(FPrint( _L("CDunSignalWaiter::Initialize()" ) ));
   208     // Don't initialize iChannelCallback here (it is set through NewL)
   193     // Don't initialize iChannelCallback here (it is set through NewL)
   209     iSignalWaiterState = EDunStateIdle;
       
   210     iSignals = 0;
   194     iSignals = 0;
   211     iComm = NULL;
   195     iComm = NULL;
   212     FTRACE(FPrint( _L("CDunSignalWaiter::Initialize() complete" ) ));
   196     FTRACE(FPrint( _L("CDunSignalWaiter::Initialize() complete" ) ));
   213     }
   197     }
   214 
   198 
   218 // ---------------------------------------------------------------------------
   202 // ---------------------------------------------------------------------------
   219 //
   203 //
   220 void CDunSignalWaiter::RunL()
   204 void CDunSignalWaiter::RunL()
   221     {
   205     {
   222     FTRACE(FPrint( _L("CDunSignalWaiter::RunL()" ) ));
   206     FTRACE(FPrint( _L("CDunSignalWaiter::RunL()" ) ));
   223     iSignalWaiterState = EDunStateIdle;
       
   224     TInt retTemp = iStatus.Int();
   207     TInt retTemp = iStatus.Int();
   225     if ( retTemp != KErrNone )
   208     if ( retTemp != KErrNone )
   226         {
   209         {
   227         FTRACE(FPrint( _L("CDunSignalWaiter::RunL() (failed) complete (%d)"), retTemp));
   210         FTRACE(FPrint( _L("CDunSignalWaiter::RunL() (failed) complete (%d)"), retTemp));
   228         TInt count = iCallbacks.Count();
   211         TInt count = iCallbacks.Count();
   252 // Gets called on cancel
   235 // Gets called on cancel
   253 // ---------------------------------------------------------------------------
   236 // ---------------------------------------------------------------------------
   254 //
   237 //
   255 void CDunSignalWaiter::DoCancel()
   238 void CDunSignalWaiter::DoCancel()
   256     {
   239     {
   257     }
   240     FTRACE(FPrint( _L("CDunSignalWaiter::RunL()" ) ));
       
   241     iComm->NotifySignalChangeCancel();
       
   242     FTRACE(FPrint( _L("CDunSignalWaiter::RunL() complete" ) ));
       
   243     }