usbmgmt/usbmgr/usbman/server/SRC/cusbhostwatcher.cpp
branchRCL_3
changeset 15 f92a4f87e424
parent 0 c9bc50fca66e
child 16 012cc2ee6408
equal deleted inserted replaced
14:d3e8e7d462dd 15:f92a4f87e424
     1 /*
     1 /*
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008-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".
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include "cusbhostwatcher.h"
    19 #include "cusbhostwatcher.h"
    20 #include <usb/usblogger.h>
       
    21 #include "cusbhost.h"
    20 #include "cusbhost.h"
    22 
    21 
       
    22 #include "OstTraceDefinitions.h"
       
    23 #ifdef OST_TRACE_COMPILER_IN_USE
       
    24 #include "cusbhostwatcherTraces.h"
       
    25 #endif
    23 
    26 
    24 #ifdef __FLOG_ACTIVE
    27 
    25 _LIT8(KLogComponent, "hoststatewatcher");
       
    26 #endif
       
    27 
    28 
    28 /*
    29 /*
    29  * 	Base class for USB Host watchers
    30  * 	Base class for USB Host watchers
    30  */
    31  */
    31 CActiveUsbHostWatcher::CActiveUsbHostWatcher(RUsbHostStack& aUsbHostStack, 
    32 CActiveUsbHostWatcher::CActiveUsbHostWatcher(RUsbHostStack& aUsbHostStack, 
    34 	CActive(CActive::EPriorityStandard),
    35 	CActive(CActive::EPriorityStandard),
    35 	iUsbHostStack(aUsbHostStack),
    36 	iUsbHostStack(aUsbHostStack),
    36 	iOwner(aOwner),
    37 	iOwner(aOwner),
    37 	iWatcherId(aWatcherId)
    38 	iWatcherId(aWatcherId)
    38 	{
    39 	{
    39 	LOG_FUNC
    40     OstTraceFunctionEntry0( CACTIVEUSBHOSTWATCHER_CACTIVEUSBHOSTWATCHER_CONS_ENTRY );
    40 	CActiveScheduler::Add(this);
    41 	CActiveScheduler::Add(this);
       
    42 	OstTraceFunctionExit0( CACTIVEUSBHOSTWATCHER_CACTIVEUSBHOSTWATCHER_CONS_EXIT );
    41 	}
    43 	}
    42 
    44 
    43 CActiveUsbHostWatcher::~CActiveUsbHostWatcher()
    45 CActiveUsbHostWatcher::~CActiveUsbHostWatcher()
    44 	{
    46 	{
    45 	LOG_FUNC
    47 	OstTraceFunctionEntry0( CACTIVEUSBHOSTWATCHER_CACTIVEUSBHOSTWATCHER_DES_ENTRY );	
    46 	Cancel();
    48 	Cancel();
       
    49 	OstTraceFunctionExit0( CACTIVEUSBHOSTWATCHER_CACTIVEUSBHOSTWATCHER_DES_EXIT );
    47 	}
    50 	}
    48 
    51 
    49 void CActiveUsbHostWatcher::RunL()
    52 void CActiveUsbHostWatcher::RunL()
    50 	{
    53 	{
    51 	LOG_FUNC
    54 	OstTraceFunctionEntry0( CACTIVEUSBHOSTWATCHER_RUNL_ENTRY );
    52 
    55 
    53 	ASSERT(iStatus.Int() == KErrNone);
    56 	ASSERT(iStatus.Int() == KErrNone);
    54 	iOwner.NotifyHostEvent(iWatcherId);
    57 	iOwner.NotifyHostEvent(iWatcherId);
    55 	Post();
    58 	Post();
       
    59 	OstTraceFunctionExit0( CACTIVEUSBHOSTWATCHER_RUNL_EXIT );
    56 	}
    60 	}
    57 
    61 
    58 
    62 
    59 
    63 
    60 /*
    64 /*
    78 														   aOwner,
    82 														   aOwner,
    79 														   KHostEventMonitor)
    83 														   KHostEventMonitor)
    80 														 , iHostEventInfo(aHostEventInfo)
    84 														 , iHostEventInfo(aHostEventInfo)
    81 
    85 
    82 	{
    86 	{
    83 	LOG_FUNC
    87 	OstTraceFunctionEntry0( CACTIVEUSBHOSTEVENTWATCHER_CACTIVEUSBHOSTEVENTWATCHER_CONS_ENTRY );
       
    88 	OstTraceFunctionExit0( CACTIVEUSBHOSTEVENTWATCHER_CACTIVEUSBHOSTEVENTWATCHER_CONS_EXIT );
    84 	}
    89 	}
    85 
    90 
    86 CActiveUsbHostEventWatcher::~CActiveUsbHostEventWatcher()
    91 CActiveUsbHostEventWatcher::~CActiveUsbHostEventWatcher()
    87 	{
    92 	{
    88 	LOG_FUNC
    93     OstTraceFunctionEntry0( CACTIVEUSBHOSTEVENTWATCHER_CACTIVEUSBHOSTEVENTWATCHER_DES_ENTRY );
    89 	Cancel();
    94 	Cancel();
       
    95 	OstTraceFunctionExit0( CACTIVEUSBHOSTEVENTWATCHER_CACTIVEUSBHOSTEVENTWATCHER_DES_EXIT );
    90 	}
    96 	}
    91 
    97 
    92 void CActiveUsbHostEventWatcher::Post()
    98 void CActiveUsbHostEventWatcher::Post()
    93 	{
    99 	{
    94 	LOG_FUNC
   100     OstTraceFunctionEntry0( CACTIVEUSBHOSTEVENTWATCHER_POST_ENTRY );
    95 
   101 
    96 	iUsbHostStack.NotifyDeviceEvent(iStatus, iHostEventInfo);
   102 	iUsbHostStack.NotifyDeviceEvent(iStatus, iHostEventInfo);
    97 	SetActive();
   103 	SetActive();
       
   104 	OstTraceFunctionExit0( CACTIVEUSBHOSTEVENTWATCHER_POST_EXIT );
    98 	}
   105 	}
    99 
   106 
   100 void CActiveUsbHostEventWatcher::DoCancel()
   107 void CActiveUsbHostEventWatcher::DoCancel()
   101 	{
   108 	{
   102 	LOG_FUNC
   109 	OstTraceFunctionEntry0( CACTIVEUSBHOSTEVENTWATCHER_DOCANCEL_ENTRY );
   103 
   110 
   104 	iUsbHostStack.NotifyDeviceEventCancel();
   111 	iUsbHostStack.NotifyDeviceEventCancel();
       
   112 	OstTraceFunctionExit0( CACTIVEUSBHOSTEVENTWATCHER_DOCANCEL_EXIT );
   105 	}
   113 	}
   106 
   114 
   107 
   115 
   108 /*
   116 /*
   109  * 	Monitors device monitor events
   117  * 	Monitors device monitor events
   118 	return self;
   126 	return self;
   119 	}
   127 	}
   120 
   128 
   121 CActiveUsbHostMessageWatcher::~CActiveUsbHostMessageWatcher()
   129 CActiveUsbHostMessageWatcher::~CActiveUsbHostMessageWatcher()
   122 	{
   130 	{
   123 	LOG_FUNC
   131 	OstTraceFunctionEntry0( CACTIVEUSBHOSTMESSAGEWATCHER_CACTIVEUSBHOSTMESSAGEWATCHER_DES_ENTRY ); 
   124 
       
   125 	Cancel();
   132 	Cancel();
       
   133 	OstTraceFunctionExit0( CACTIVEUSBHOSTMESSAGEWATCHER_CACTIVEUSBHOSTMESSAGEWATCHER_DES_EXIT );
   126 	}
   134 	}
   127 
   135 
   128 CActiveUsbHostMessageWatcher::CActiveUsbHostMessageWatcher(
   136 CActiveUsbHostMessageWatcher::CActiveUsbHostMessageWatcher(
   129 										RUsbHostStack& aUsbHostStack,
   137 										RUsbHostStack& aUsbHostStack,
   130 										MUsbHostObserver& aOwner,
   138 										MUsbHostObserver& aOwner,
   132 										:CActiveUsbHostWatcher(aUsbHostStack,
   140 										:CActiveUsbHostWatcher(aUsbHostStack,
   133 															   aOwner,
   141 															   aOwner,
   134 															   KHostMessageMonitor)
   142 															   KHostMessageMonitor)
   135 										, iHostMessage(aHostMessage)
   143 										, iHostMessage(aHostMessage)
   136 	{
   144 	{
   137 	LOG_FUNC
   145 	OstTraceFunctionEntry0( CACTIVEUSBHOSTMESSAGEWATCHER_CACTIVEUSBHOSTMESSAGEWATCHER_CONS_ENTRY );
       
   146 	OstTraceFunctionExit0( CACTIVEUSBHOSTMESSAGEWATCHER_CACTIVEUSBHOSTMESSAGEWATCHER_CONS_EXIT );
   138 	}
   147 	}
   139 
   148 
   140 void CActiveUsbHostMessageWatcher::Post()
   149 void CActiveUsbHostMessageWatcher::Post()
   141 	{
   150 	{
   142 	LOG_FUNC
   151     OstTraceFunctionEntry0( CACTIVEUSBHOSTMESSAGEWATCHER_POST_ENTRY );
   143 	
   152 	
   144 	iUsbHostStack.NotifyDevmonEvent(iStatus, iHostMessage);
   153 	iUsbHostStack.NotifyDevmonEvent(iStatus, iHostMessage);
   145 	SetActive();
   154 	SetActive();
       
   155 	OstTraceFunctionExit0( CACTIVEUSBHOSTMESSAGEWATCHER_POST_EXIT );
   146 	}
   156 	}
   147 
   157 
   148 
   158 
   149 void CActiveUsbHostMessageWatcher::DoCancel()
   159 void CActiveUsbHostMessageWatcher::DoCancel()
   150 	{
   160 	{
   151 	LOG_FUNC
   161 	OstTraceFunctionEntry0( CACTIVEUSBHOSTMESSAGEWATCHER_DOCANCEL_ENTRY );
   152 	
   162 	
   153 	iUsbHostStack.NotifyDevmonEventCancel();
   163 	iUsbHostStack.NotifyDevmonEventCancel();
       
   164 	OstTraceFunctionExit0( CACTIVEUSBHOSTMESSAGEWATCHER_DOCANCEL_EXIT );
   154 	}
   165 	}
   155 
   166