convergedconnectionhandler/cchclientapi/src/cchserviceimplasynchroniser.cpp
branchRCL_3
changeset 11 bddb6d4447db
child 20 be41ab7b952f
equal deleted inserted replaced
10:7117cbf1600a 11:bddb6d4447db
       
     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:  cch client api implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "cchserviceimplasynchroniser.h"
       
    20 #include "cchlogger.h"
       
    21 
       
    22 CCchServiceImplAsynchroniser::CCchServiceImplAsynchroniser(CCchImpl& aCch, TInt aServiceId, CCchUiPrivateApi& aCchUi) :
       
    23     CActive(EPriorityStandard),// Standard priority
       
    24     iCch( aCch ),
       
    25     iServiceId( aServiceId ),
       
    26     iCchUi( aCchUi ),
       
    27     iState ( EIdle )
       
    28 
       
    29     {
       
    30     }
       
    31 
       
    32 CCchServiceImplAsynchroniser* CCchServiceImplAsynchroniser::NewLC(CCchImpl& aCch, TInt aServiceId, CCchUiPrivateApi& aCchUi)
       
    33     {
       
    34     CCchServiceImplAsynchroniser* self =
       
    35             new (ELeave) CCchServiceImplAsynchroniser(aCch, aServiceId, aCchUi );
       
    36     CleanupStack::PushL(self);
       
    37     self->ConstructL();
       
    38     return self;
       
    39     }
       
    40 
       
    41 CCchServiceImplAsynchroniser* CCchServiceImplAsynchroniser::NewL(CCchImpl& aCch, TInt aServiceId, CCchUiPrivateApi& aCchUi)
       
    42     {
       
    43     CCchServiceImplAsynchroniser* self =
       
    44             CCchServiceImplAsynchroniser::NewLC(aCch, aServiceId, aCchUi );
       
    45     CleanupStack::Pop(); // self;
       
    46     return self;
       
    47     }
       
    48 
       
    49 void CCchServiceImplAsynchroniser::Enable( TCCHSubserviceType aType )
       
    50     {
       
    51     CCHLOGSTRING( "CCchServiceImplAsynchroniser::Enable IN" );
       
    52     if (iState == EIdle)
       
    53         {
       
    54         iState = EEnabling;
       
    55         TServiceSelection selection( iServiceId, aType );
       
    56         SetActive();
       
    57         iCch.CchClient().EnableService( selection, iStatus, EFalse );
       
    58         }
       
    59     else
       
    60         {
       
    61         CCHLOGSTRING( "CCchServiceImplAsynchroniser already active" );
       
    62         }
       
    63     CCHLOGSTRING( "CCchServiceImplAsynchroniser::Enable OUT" );
       
    64     }
       
    65 
       
    66 void CCchServiceImplAsynchroniser::Disable( TCCHSubserviceType aType )
       
    67     {
       
    68     CCHLOGSTRING( "CCchServiceImplAsynchroniser::Disable IN" );
       
    69     if (iState == EIdle)
       
    70         {
       
    71         iState = EDisabling;
       
    72         TRequestStatus status = KErrNone;
       
    73         TServiceSelection selection( iServiceId, aType );
       
    74         SetActive();
       
    75         iCch.CchClient().DisableService( selection, iStatus );
       
    76         }
       
    77     else
       
    78         {
       
    79         CCHLOGSTRING( "CCchServiceImplAsynchroniser already active" );
       
    80         }
       
    81     CCHLOGSTRING( "CCchServiceImplAsynchroniser::Disable OUT" );
       
    82     }
       
    83 
       
    84 
       
    85 void CCchServiceImplAsynchroniser::ConstructL()
       
    86     {
       
    87        CActiveScheduler::Add(this); // Add to scheduler
       
    88     }
       
    89 
       
    90 CCchServiceImplAsynchroniser::~CCchServiceImplAsynchroniser()
       
    91     {
       
    92     Cancel(); // Cancel any request, if outstanding
       
    93     // Delete instance variables if any
       
    94     }
       
    95 
       
    96 void CCchServiceImplAsynchroniser::DoCancel()
       
    97     {
       
    98 
       
    99     }
       
   100 
       
   101 void CCchServiceImplAsynchroniser::RunL()
       
   102     {
       
   103 	CCHLOGSTRING( "CCchServiceImplAsynchroniser::RunL IN" );
       
   104     if (iStatus.Int() != KErrCancel)
       
   105         {
       
   106         switch (iState)
       
   107             {
       
   108             case EEnabling:
       
   109                 {
       
   110                 if ( iCch.ConnectivityDialogsAllowed() )
       
   111                     {
       
   112                     iCchUi.ManualEnableResultL( iServiceId, iStatus.Int() );
       
   113                     }
       
   114                 CCHLOGSTRING( "CCchServiceImplAsynchroniser::RunL EEnabling done" );
       
   115                 iState = EIdle;
       
   116                 break;
       
   117                 }
       
   118             case EDisabling:
       
   119                 {
       
   120 				CCHLOGSTRING( "CCchServiceImplAsynchroniser::RunL EDisabling done" );
       
   121                 iState = EIdle;
       
   122                 break;
       
   123                 }
       
   124             default:
       
   125                 {
       
   126                 break;
       
   127                 }
       
   128 
       
   129             }
       
   130         }
       
   131     iState = EIdle;
       
   132     CCHLOGSTRING( "CCchServiceImplAsynchroniser::RunL OUT" );
       
   133     }
       
   134 
       
   135 TInt CCchServiceImplAsynchroniser::RunError(TInt aError)
       
   136     {
       
   137     return aError;
       
   138     }