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