usbmgmt/usbmgr/usbman/server/SRC/CUsbDeviceStateWatcher.cpp
branchRCL_3
changeset 42 f92a4f87e424
parent 0 c9bc50fca66e
child 43 012cc2ee6408
equal deleted inserted replaced
37:d3e8e7d462dd 42:f92a4f87e424
     1 /*
     1 /*
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 1997-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".
    19 
    19 
    20 /**
    20 /**
    21  @file
    21  @file
    22 */
    22 */
    23 
    23 
    24 #include <usb/usblogger.h>
       
    25 #include "CUsbScheduler.h"
    24 #include "CUsbScheduler.h"
    26 #include "CUsbDeviceStateWatcher.h"
    25 #include "CUsbDeviceStateWatcher.h"
    27 #include "CUsbDevice.h"
    26 #include "CUsbDevice.h"
       
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "CUsbDeviceStateWatcherTraces.h"
       
    30 #endif
    28 
    31 
    29 #ifdef __FLOG_ACTIVE
    32 
    30 _LIT8(KLogComponent, "USBSVR");
       
    31 #endif
       
    32 
    33 
    33 /**
    34 /**
    34  * The CUsbDeviceStateWatcher::NewL method
    35  * The CUsbDeviceStateWatcher::NewL method
    35  *
    36  *
    36  * Constructs a new CUsbDeviceStateWatcher object
    37  * Constructs a new CUsbDeviceStateWatcher object
    41  *
    42  *
    42  * @return	A new CUsbDeviceStateWatcher object
    43  * @return	A new CUsbDeviceStateWatcher object
    43  */
    44  */
    44 CUsbDeviceStateWatcher* CUsbDeviceStateWatcher::NewL(CUsbDevice& aOwner, RDevUsbcClient& aLdd)
    45 CUsbDeviceStateWatcher* CUsbDeviceStateWatcher::NewL(CUsbDevice& aOwner, RDevUsbcClient& aLdd)
    45 	{
    46 	{
    46 	LOG_STATIC_FUNC_ENTRY
    47 	OstTraceFunctionEntry0( CUSBDEVICESTATEWATCHER_NEWL_ENTRY );
    47 
    48 
    48 	CUsbDeviceStateWatcher* r = new (ELeave) CUsbDeviceStateWatcher(aOwner, aLdd);
    49 	CUsbDeviceStateWatcher* r = new (ELeave) CUsbDeviceStateWatcher(aOwner, aLdd);
       
    50 	OstTraceFunctionExit0( CUSBDEVICESTATEWATCHER_NEWL_EXIT );
    49 	return r;
    51 	return r;
    50 	}
    52 	}
    51 
    53 
    52 
    54 
    53 /**
    55 /**
    57  *
    59  *
    58  * @internalComponent
    60  * @internalComponent
    59  */
    61  */
    60 CUsbDeviceStateWatcher::~CUsbDeviceStateWatcher()
    62 CUsbDeviceStateWatcher::~CUsbDeviceStateWatcher()
    61 	{
    63 	{
    62 	LOGTEXT2(_L8(">CUsbDeviceStateWatcher::~CUsbDeviceStateWatcher (0x%08x)"), (TUint32) this);
    64 	OstTrace1( TRACE_NORMAL, CUSBDEVICESTATEWATCHER_CUSBDEVICESTATEWATCHER, 
       
    65 	        "CUsbDeviceStateWatcher::~CUsbDeviceStateWatcher;  this=(0x%08x)", (TUint32)this );
    63 	Cancel();
    66 	Cancel();
    64 	}
    67 	}
    65 
    68 
    66 
    69 
    67 /**
    70 /**
    83  */
    86  */
    84 void CUsbDeviceStateWatcher::RunL()
    87 void CUsbDeviceStateWatcher::RunL()
    85 	{
    88 	{
    86 	if (iStatus.Int() != KErrNone)
    89 	if (iStatus.Int() != KErrNone)
    87 		{
    90 		{
    88 		LOGTEXT2(_L8("CUsbDeviceStateWatcher::RunL() - Error = %d"), iStatus.Int());
    91 		OstTrace1( TRACE_NORMAL, CUSBDEVICESTATEWATCHER_RUNL, 
       
    92 		        "CUsbDeviceStateWatcher::RunL;Error=%d", iStatus.Int() );
    89 		return;
    93 		return;
    90 		}
    94 		}
    91 
    95 
    92 	LOGTEXT2(_L8("CUsbDeviceStateWatcher::RunL() - State Changed to %d"), iState);
    96 	OstTrace1( TRACE_NORMAL, CUSBDEVICESTATEWATCHER_RUNL_DUP1, "CUsbDeviceStateWatcher::RunL; - State Changed to %u", iState );
    93 
    97 	
    94 	if (!(iState & KUsbAlternateSetting))
    98 	if (!(iState & KUsbAlternateSetting))
    95 		iOwner.SetDeviceState((TUsbcDeviceState) iState);
    99 		iOwner.SetDeviceState((TUsbcDeviceState) iState);
    96 
   100 
    97 	LOGTEXT(_L8("CUsbDeviceStateWatcher::RunL() - About to call DeviceStatusNotify"));
   101 	OstTrace0( TRACE_NORMAL, CUSBDEVICESTATEWATCHER_RUNL_DUP2, 
       
   102 	        "CUsbDeviceStateWatcher::RunL - About to call DeviceStatusNotify" );
    98 	iLdd.AlternateDeviceStatusNotify(iStatus, iState);
   103 	iLdd.AlternateDeviceStatusNotify(iStatus, iState);
    99 	SetActive();
   104 	SetActive();
   100 	LOGTEXT(_L8("CUsbDeviceStateWatcher::RunL() - Called DeviceStatusNotify"));
   105 	OstTrace0( TRACE_NORMAL, CUSBDEVICESTATEWATCHER_RUNL_DUP3, "CUsbDeviceStateWatcher::RunL - Called DeviceStatusNotify" );
   101 	}
   106 	}
   102 
   107 
   103 
   108 
   104 /**
   109 /**
   105  * Automatically called when the state watcher is cancelled.
   110  * Automatically called when the state watcher is cancelled.
   106  */
   111  */
   107 void CUsbDeviceStateWatcher::DoCancel()
   112 void CUsbDeviceStateWatcher::DoCancel()
   108 	{
   113 	{
   109 	LOG_FUNC
   114 	OstTraceFunctionEntry0( CUSBDEVICESTATEWATCHER_DOCANCEL_ENTRY );
   110 	iLdd.AlternateDeviceStatusNotifyCancel();
   115 	iLdd.AlternateDeviceStatusNotifyCancel();
       
   116 	OstTraceFunctionExit0( CUSBDEVICESTATEWATCHER_DOCANCEL_EXIT );
   111 	}
   117 	}
   112 
   118 
   113 
   119 
   114 /**
   120 /**
   115  * Instructs the state watcher to start watching.
   121  * Instructs the state watcher to start watching.
   116  */
   122  */
   117 void CUsbDeviceStateWatcher::Start()
   123 void CUsbDeviceStateWatcher::Start()
   118 	{
   124 	{
   119 	LOG_FUNC
   125 	OstTraceFunctionEntry0( CUSBDEVICESTATEWATCHER_START_ENTRY );
   120 	iLdd.AlternateDeviceStatusNotify(iStatus, iState);
   126 	iLdd.AlternateDeviceStatusNotify(iStatus, iState);
   121 	SetActive();
   127 	SetActive();
       
   128 	OstTraceFunctionExit0( CUSBDEVICESTATEWATCHER_START_EXIT );
   122 	}
   129 	}