localconnectivityservice/dun/client/src/dunactive.cpp
branchRCL_3
changeset 39 4096754ee773
parent 38 3dcb815346df
child 40 52a167391590
equal deleted inserted replaced
38:3dcb815346df 39:4096754ee773
     1 /*
       
     2 * Copyright (c) 2006-2007 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 "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:  Controls asynchronous requests between LOCOD and DUN server
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "dunactive.h"
       
    20 #include "dunplugin.h"
       
    21 #include "DunDebug.h"
       
    22 
       
    23 // ======== MEMBER FUNCTIONS ========
       
    24 
       
    25 // ---------------------------------------------------------------------------
       
    26 // Two-phased constructor.
       
    27 // ---------------------------------------------------------------------------
       
    28 //
       
    29 CDunActive* CDunActive::NewL( CDunPlugin* aPlugin,
       
    30                               TLocodBearer aBearer,
       
    31                               TBool aBearerStatus)
       
    32     {
       
    33     CDunActive* self = CDunActive::NewLC( aPlugin, aBearer, aBearerStatus );
       
    34     CleanupStack::Pop( self );
       
    35     return self;
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // Two-phased constructor.
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 CDunActive* CDunActive::NewLC( CDunPlugin* aPlugin,
       
    43                                TLocodBearer aBearer,
       
    44                                TBool aBearerStatus )
       
    45     {
       
    46     CDunActive* self = new (ELeave) CDunActive( aPlugin,
       
    47                                                 aBearer,
       
    48                                                 aBearerStatus );
       
    49     CleanupStack::PushL( self );
       
    50     self->ConstructL();
       
    51     return self;
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // Destructor.
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 CDunActive::~CDunActive()
       
    59     {
       
    60     FTRACE(FPrint( _L("CDunActive::~CDunActive()") ));
       
    61     Cancel();
       
    62     FTRACE(FPrint( _L("CDunActive::~CDunActive() complete") ));
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // Request function
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 TInt CDunActive::ServiceRequest()
       
    70     {
       
    71     FTRACE(FPrint( _L("CDunActive::ServiceRequest()") ));
       
    72     TInt err = KErrNone;
       
    73 
       
    74     iStatus = KRequestPending;
       
    75     err = (iPlugin->Server()).ManageService( this, iStatus );
       
    76     SetActive();
       
    77     FTRACE(FPrint( _L("CDunActive::ServiceRequest() complete") ));
       
    78     return err;
       
    79     }
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // CDunActive::CDunActive
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 CDunActive::CDunActive( CDunPlugin* aPlugin,
       
    86                         TLocodBearer aBearer,
       
    87                         TBool aBearerStatus )
       
    88     : CActive( EPriorityStandard ),
       
    89     iPlugin( aPlugin ),
       
    90     iBearer( aBearer ),
       
    91     iBearerStatus( aBearerStatus )
       
    92     {
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // CDunActive::ConstructL
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 void CDunActive::ConstructL()
       
   100     {
       
   101     FTRACE(FPrint( _L("CDunActive::ConstructL()") ));
       
   102     CActiveScheduler::Add( this );
       
   103     FTRACE(FPrint( _L("CDunActive::ConstructL() complete") ));
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // From class CActive.
       
   108 // Cancel current activity.
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 void CDunActive::DoCancel()
       
   112     {
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // From class CActive
       
   117 // Called when read or write operation is ready.
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 void CDunActive::RunL()
       
   121     {
       
   122     FTRACE(FPrint( _L("CDunActive::RunL()") ));
       
   123     TInt retVal = iStatus.Int();
       
   124     iPlugin->ServiceCompleted( this, retVal );
       
   125     FTRACE(FPrint( _L("CDunActive::RunL() complete (%d)"), retVal ));
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // From class MDunActive.
       
   130 // Bearer
       
   131 // ---------------------------------------------------------------------------
       
   132 //
       
   133 TLocodBearer CDunActive::Bearer()
       
   134     {
       
   135     FTRACE(FPrint( _L("CDunActive::Bearer()") ));
       
   136     FTRACE(FPrint( _L("CDunActive::Bearer() complete") ));
       
   137     return iBearer;
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // From class MDunActive.
       
   142 // Bearer status
       
   143 // ---------------------------------------------------------------------------
       
   144 //
       
   145 TBool CDunActive::BearerStatus()
       
   146     {
       
   147     FTRACE(FPrint( _L("CDunActive::BearerStatus()") ));
       
   148     FTRACE(FPrint( _L("CDunActive::BearerStatus() complete") ));
       
   149     return iBearerStatus;
       
   150     }