localconnectivityservice/dun/utils/src/DunSignalNotify.cpp
branchRCL_3
changeset 11 c47ebe2ac36c
parent 0 c3e98f10fcf4
equal deleted inserted replaced
10:031b9cffe6e4 11:c47ebe2ac36c
     1 /*
     1 /*
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2006-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".
    63     // APIs affecting this:
    63     // APIs affecting this:
    64     // IssueRequest()
    64     // IssueRequest()
    65     Stop();
    65     Stop();
    66     // AddCallback()
    66     // AddCallback()
    67     iCallbacks.Close();
    67     iCallbacks.Close();
    68     // AddEndpointReadyCallback()
       
    69     iERCallbacks.Close();
       
    70     // Internal
    68     // Internal
    71     Initialize();
    69     Initialize();
    72     FTRACE(FPrint( _L("CDunSignalNotify::ResetData() complete") ));
    70     FTRACE(FPrint( _L("CDunSignalNotify::ResetData() complete") ));
    73     }
    71     }
    74 
    72 
    97         {
    95         {
    98         FTRACE(FPrint( _L("CDunSignalNotify::AddCallback() (append failed!) complete" ) ));
    96         FTRACE(FPrint( _L("CDunSignalNotify::AddCallback() (append failed!) complete" ) ));
    99         return retTemp;
    97         return retTemp;
   100         }
    98         }
   101     FTRACE(FPrint( _L("CDunSignalNotify::AddCallback() complete" ) ));
    99     FTRACE(FPrint( _L("CDunSignalNotify::AddCallback() complete" ) ));
   102     return KErrNone;
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // Adds callback for endpoint readiness
       
   107 // The callback will be called when the endpoint is ready or not ready
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 TInt CDunSignalNotify::AddEndpointReadyCallback(
       
   111     MDunEndpointReady* aERCallback )
       
   112     {
       
   113     FTRACE(FPrint( _L("CDunSignalNotify::AddEndpointReadyCallback()" ) ));
       
   114     if ( !aERCallback )
       
   115         {
       
   116         FTRACE(FPrint( _L("CDunSignalNotify::AddEndpointReadyCallback() (aERCallback) not initialized!" ) ));
       
   117         return KErrGeneral;
       
   118         }
       
   119     TInt retTemp = iERCallbacks.Find( aERCallback );
       
   120     if ( retTemp != KErrNotFound )
       
   121         {
       
   122         FTRACE(FPrint( _L("CDunSignalNotify::AddEndpointReadyCallback() (already exists) complete" ) ));
       
   123         return KErrAlreadyExists;
       
   124         }
       
   125     retTemp = iERCallbacks.Append( aERCallback );
       
   126     if ( retTemp != KErrNone )
       
   127         {
       
   128         FTRACE(FPrint( _L("CDunSignalNotify::AddEndpointReadyCallback() (append failed!) complete" ) ));
       
   129         return retTemp;
       
   130         }
       
   131     ReportEndpointReady( ETrue );  // report immediately as this is a hack
       
   132     FTRACE(FPrint( _L("CDunSignalNotify::AddEndpointReadyCallback() complete" ) ));
       
   133     return KErrNone;
   100     return KErrNone;
   134     }
   101     }
   135 
   102 
   136 // ---------------------------------------------------------------------------
   103 // ---------------------------------------------------------------------------
   137 // Sets media to use for this endpoint monitor
   104 // Sets media to use for this endpoint monitor
   373 
   340 
   374     FTRACE(FPrint( _L("CDunSignalNotify::ReportSignalChange() complete" ) ));
   341     FTRACE(FPrint( _L("CDunSignalNotify::ReportSignalChange() complete" ) ));
   375     }
   342     }
   376 
   343 
   377 // ---------------------------------------------------------------------------
   344 // ---------------------------------------------------------------------------
   378 // Reports endpoint ready or not ready
       
   379 // ---------------------------------------------------------------------------
       
   380 //
       
   381 void CDunSignalNotify::ReportEndpointReady( TBool aReady )
       
   382     {
       
   383     FTRACE(FPrint( _L("CDunSignalNotify::ReportEndpointReady()" ) ));
       
   384     TInt count = iERCallbacks.Count();
       
   385     for ( TInt i=0; i<count; i++ )
       
   386         {
       
   387         if ( aReady )
       
   388             {
       
   389             iERCallbacks[i]->NotifyEndpointReady();
       
   390             }
       
   391         else  // not ready
       
   392             {
       
   393             iERCallbacks[i]->NotifyEndpointNotReady();
       
   394             }
       
   395         }
       
   396     FTRACE(FPrint( _L("CDunSignalNotify::ReportEndpointReady() complete" ) ));
       
   397     }
       
   398 
       
   399 // ---------------------------------------------------------------------------
       
   400 // From class CActive.
   345 // From class CActive.
   401 // Gets called when line status changes
   346 // Gets called when line status changes
   402 // ---------------------------------------------------------------------------
   347 // ---------------------------------------------------------------------------
   403 //
   348 //
   404 void CDunSignalNotify::RunL()
   349 void CDunSignalNotify::RunL()