usbmgmt/usbmgr/device/classdrivers/ncm/classcontroller/src/ncmiapprogresswatcher.cpp
branchRCL_3
changeset 15 f92a4f87e424
equal deleted inserted replaced
14:d3e8e7d462dd 15:f92a4f87e424
       
     1 /*
       
     2 * Copyright (c) 2010 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 /**
       
    19  * @file
       
    20  * @internalComponent
       
    21  */
       
    22 
       
    23 #include "ncmiapprogresswatcher.h"
       
    24 #include "ncmiapprogressstateobserver.h"
       
    25 #include "ncmconnectionmanager.h"
       
    26 
       
    27 // For OST Tracing
       
    28 #include "OstTraceDefinitions.h"
       
    29 #ifdef OST_TRACE_COMPILER_IN_USE
       
    30 #include "ncmiapprogresswatcherTraces.h"
       
    31 #endif
       
    32 
       
    33 /**
       
    34  * Constructor.
       
    35  * @param aObserver The object which is interested in the IAP progress stage change
       
    36  * @param aConnection The reference of the NCM connection to be used
       
    37  */
       
    38 CNcmIapProgressWatcher::CNcmIapProgressWatcher(MNcmIapProgressStateObserver& aObserver, RConnection& aConnection)
       
    39 	: CActive(CActive::EPriorityStandard)
       
    40 	, iObserver(aObserver)
       
    41 	, iConnection(aConnection) 
       
    42 	{
       
    43     OstTraceFunctionEntryExt( CNCMIAPPROGRESSWATCHER_CNCMIAPPROGRESSWATCHER_ENTRY, this );
       
    44     
       
    45 	CActiveScheduler::Add(this);		
       
    46 	OstTraceFunctionExit1( CNCMIAPPROGRESSWATCHER_CNCMIAPPROGRESSWATCHER_EXIT, this );
       
    47 	}
       
    48 
       
    49 
       
    50 /**
       
    51  * Destructor.
       
    52  */
       
    53 CNcmIapProgressWatcher::~CNcmIapProgressWatcher()
       
    54 	{
       
    55 	OstTraceFunctionEntry0( CNCMIAPPROGRESSWATCHER_CNCMIAPPROGRESSWATCHER_ENTRY_DESTRUCTOR );
       
    56 	
       
    57 	Cancel();
       
    58 	OstTraceFunctionExit0( CNCMIAPPROGRESSWATCHER_CNCMIAPPROGRESSWATCHER_ENTRY_DESTRUCTOR_EXIT );
       
    59 	}
       
    60 
       
    61 /**
       
    62  * Start observing the connection stage changes.
       
    63  */
       
    64 void CNcmIapProgressWatcher::Start()
       
    65 	{
       
    66 	OstTraceFunctionEntry0( CNCMIAPPROGRESSWATCHER_START_ENTRY );
       
    67 	
       
    68 	if (!IsActive())
       
    69 		{
       
    70 		iConnection.ProgressNotification(iProgressInfoBuf, iStatus);
       
    71 		SetActive();
       
    72 		}
       
    73 	OstTraceFunctionExit0( CNCMIAPPROGRESSWATCHER_START_EXIT );
       
    74 	}
       
    75 
       
    76 /**
       
    77  * Implements cancellation of an outstanding request. Cancels the connection progress notification request.
       
    78  */
       
    79 void CNcmIapProgressWatcher::DoCancel()
       
    80 	{
       
    81     OstTraceFunctionEntry0( CNCMIAPPROGRESSWATCHER_DOCANCEL_ENTRY );
       
    82 
       
    83 	iConnection.CancelProgressNotification();
       
    84 	OstTraceFunctionExit0( CNCMIAPPROGRESSWATCHER_DOCANCEL_EXIT );
       
    85 	}
       
    86 
       
    87 /**
       
    88  * Called when connection stage changed.
       
    89  */
       
    90 void CNcmIapProgressWatcher::RunL()
       
    91 	{
       
    92 	OstTraceFunctionEntry0( CNCMIAPPROGRESSWATCHER_RUNL_ENTRY );
       
    93 	
       
    94 	OstTrace1( TRACE_NORMAL, CNCMIAPPROGRESSWATCHER_RUNL_COMPLETION_CODE, ";iStatus.Int()=%d", iStatus.Int() );
       
    95 	OstTraceExt2( TRACE_NORMAL, CNCMIAPPROGRESSWATCHER_RUNL_INFO, ";iProgressInfoBuf().iStage=%d;iProgressInfoBuf().iError=%d", iProgressInfoBuf().iStage, iProgressInfoBuf().iError );
       
    96 	
       
    97 
       
    98 	TInt completionCode = iStatus.Int();
       
    99     if (KErrNone == completionCode)
       
   100         {
       
   101         switch (iProgressInfoBuf().iStage)
       
   102             {
       
   103             case KConnectionUninitialised:
       
   104                 {
       
   105                 iObserver.MipsoHandleClassFatalError(KErrDisconnected);
       
   106                 break;
       
   107                 }
       
   108             case ENcmPktDrvFatalError:
       
   109                 {
       
   110                 iObserver.MipsoHandleClassFatalError(iProgressInfoBuf().iError);
       
   111                 break;
       
   112                 }
       
   113             default:
       
   114                 {
       
   115                 // Request the next notification
       
   116                 OstTrace0( TRACE_NORMAL, CNCMIAPPROGRESSWATCHER_RUNL_RESTART_WATCHER, "Request the next notification" );                
       
   117                 Start();
       
   118                 }
       
   119             }
       
   120         }
       
   121 	OstTraceFunctionExit0( CNCMIAPPROGRESSWATCHER_RUNL_EXIT );
       
   122 	}