usbmgmt/usbmgr/usbman/server/SRC/cusbotgwatcher.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".
    19 
    19 
    20 /**
    20 /**
    21  @file
    21  @file
    22 */
    22 */
    23 
    23 
       
    24 #include <usb/usbshared.h>
    24 #include <usb/usblogger.h>
    25 #include <usb/usblogger.h>
    25 #include "CUsbScheduler.h"
    26 #include "CUsbScheduler.h"
    26 #include "cusbotgwatcher.h"
    27 #include "cusbotgwatcher.h"
    27 #include "CUsbOtg.h"
    28 #include "CUsbOtg.h"
    28 #include <usb/usbshared.h>
    29 #include "OstTraceDefinitions.h"
    29 
    30 #ifdef OST_TRACE_COMPILER_IN_USE
    30 #ifdef __FLOG_ACTIVE
    31 #include "cusbotgwatcherTraces.h"
    31 _LIT8(KLogComponent, "USBSVR-OTGWATCHER");
       
    32 #endif
    32 #endif
       
    33 
    33 
    34 
    34 static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
    35 static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
    35 static _LIT_SECURITY_POLICY_S1(KNetworkControlPolicy,KUsbmanSvrSid,ECapabilityNetworkControl);
    36 static _LIT_SECURITY_POLICY_S1(KNetworkControlPolicy,KUsbmanSvrSid,ECapabilityNetworkControl);
    36 static _LIT_SECURITY_POLICY_C1(KRequestSessionPolicy,ECapabilityCommDD);
    37 static _LIT_SECURITY_POLICY_C1(KRequestSessionPolicy,ECapabilityCommDD);
    37 
    38 
    48  * @param	aLdd	A reference to the USB Logical Device Driver
    49  * @param	aLdd	A reference to the USB Logical Device Driver
    49  */
    50  */
    50 CUsbOtgBaseWatcher::CUsbOtgBaseWatcher(RUsbOtgDriver& aLdd)
    51 CUsbOtgBaseWatcher::CUsbOtgBaseWatcher(RUsbOtgDriver& aLdd)
    51 	: CActive(CActive::EPriorityStandard), iLdd(aLdd)
    52 	: CActive(CActive::EPriorityStandard), iLdd(aLdd)
    52 	{
    53 	{
    53 	LOG_FUNC
    54 	OstTraceFunctionEntry0( CUSBOTGBASEWATCHER_CUSBOTGBASEWATCHER_CONS_ENTRY );
    54 	CActiveScheduler::Add(this);
    55 	CActiveScheduler::Add(this);
       
    56 	OstTraceFunctionExit0( CUSBOTGBASEWATCHER_CUSBOTGBASEWATCHER_CONS_EXIT );
    55 	}
    57 	}
    56 
    58 
    57 /**
    59 /**
    58  * The CUsbOtgBaseWatcher::~CUsbOtgBaseWatcher method
    60  * The CUsbOtgBaseWatcher::~CUsbOtgBaseWatcher method
    59  *
    61  *
    61  *
    63  *
    62  * @internalComponent
    64  * @internalComponent
    63  */
    65  */
    64 CUsbOtgBaseWatcher::~CUsbOtgBaseWatcher()
    66 CUsbOtgBaseWatcher::~CUsbOtgBaseWatcher()
    65 	{
    67 	{
    66 	LOG_FUNC
    68 	OstTraceFunctionEntry0( CUSBOTGBASEWATCHER_CUSBOTGBASEWATCHER_DES_ENTRY );
    67 	Cancel();
    69 	Cancel();
       
    70 	OstTraceFunctionExit0( CUSBOTGBASEWATCHER_CUSBOTGBASEWATCHER_DES_EXIT );
    68 	}
    71 	}
    69 
    72 
    70 /**
    73 /**
    71  * Instructs the state watcher to start watching.
    74  * Instructs the state watcher to start watching.
    72  */
    75  */
    73 void CUsbOtgBaseWatcher::Start()
    76 void CUsbOtgBaseWatcher::Start()
    74 	{
    77 	{
    75 	LOG_FUNC
    78 	OstTraceFunctionEntry0( CUSBOTGBASEWATCHER_START_ENTRY );
    76 	Post();
    79 	Post();
       
    80 	OstTraceFunctionExit0( CUSBOTGBASEWATCHER_START_EXIT );
    77 	}
    81 	}
    78 
    82 
    79 //---------------------------- Id-Pin watcher class --------------------------- 
    83 //---------------------------- Id-Pin watcher class --------------------------- 
    80 /**
    84 /**
    81  * The CUsbOtgIdPinWatcher::NewL method
    85  * The CUsbOtgIdPinWatcher::NewL method
    87  *
    91  *
    88  * @return	A new CUsbOtgWatcher object
    92  * @return	A new CUsbOtgWatcher object
    89  */
    93  */
    90 CUsbOtgIdPinWatcher* CUsbOtgIdPinWatcher::NewL(RUsbOtgDriver& aLdd)
    94 CUsbOtgIdPinWatcher* CUsbOtgIdPinWatcher::NewL(RUsbOtgDriver& aLdd)
    91 	{
    95 	{
    92 	LOG_STATIC_FUNC_ENTRY
    96 	OstTraceFunctionEntry0( CUSBOTGIDPINWATCHER_NEWL_ENTRY );
    93 
    97 
    94 	CUsbOtgIdPinWatcher* self = new (ELeave) CUsbOtgIdPinWatcher(aLdd);
    98 	CUsbOtgIdPinWatcher* self = new (ELeave) CUsbOtgIdPinWatcher(aLdd);
    95 	CleanupStack::PushL(self);
    99 	CleanupStack::PushL(self);
    96 	self->ConstructL();
   100 	self->ConstructL();
    97 	CleanupStack::Pop(self);
   101 	CleanupStack::Pop(self);
       
   102 	OstTraceFunctionExit0( CUSBOTGIDPINWATCHER_NEWL_EXIT );
    98 	return self;
   103 	return self;
    99 	}
   104 	}
   100 
   105 
   101 
   106 
   102 /**
   107 /**
   106  *
   111  *
   107  * @internalComponent
   112  * @internalComponent
   108  */
   113  */
   109 CUsbOtgIdPinWatcher::~CUsbOtgIdPinWatcher()
   114 CUsbOtgIdPinWatcher::~CUsbOtgIdPinWatcher()
   110 	{
   115 	{
   111 	LOG_FUNC
   116 	OstTraceFunctionEntry0( CUSBOTGIDPINWATCHER_CUSBOTGIDPINWATCHER_DES_ENTRY );
   112 	Cancel();
   117 	Cancel();
   113 	RProperty::Delete(KUsbOtgIdPinPresentProperty);
   118 	RProperty::Delete(KUsbOtgIdPinPresentProperty);
       
   119 	OstTraceFunctionExit0( CUSBOTGIDPINWATCHER_CUSBOTGIDPINWATCHER_DES_EXIT );
   114 	}
   120 	}
   115 
   121 
   116 void CUsbOtgIdPinWatcher::ConstructL()
   122 void CUsbOtgIdPinWatcher::ConstructL()
   117 /**
   123 /**
   118  * Performs 2nd phase construction of the OTG object.
   124  * Performs 2nd phase construction of the OTG object.
   119  */
   125  */
   120 	{
   126 	{
   121 	LOG_FUNC
   127 	OstTraceFunctionEntry0( CUSBOTGIDPINWATCHER_CONSTRUCTL_ENTRY );
   122 
   128 
   123 	TInt err = RProperty::Define(KUsbOtgIdPinPresentProperty, RProperty::EInt, KAllowAllPolicy, KNetworkControlPolicy);
   129 	TInt err = RProperty::Define(KUsbOtgIdPinPresentProperty, RProperty::EInt, KAllowAllPolicy, KNetworkControlPolicy);
   124 	if ( err != KErrNone && err != KErrAlreadyExists )
   130 	if ( err != KErrNone && err != KErrAlreadyExists )
   125 	    {
   131 	    {
   126 	    User::LeaveIfError(err);
   132 	    User::LeaveIfError(err);
   128 	err = RProperty::Set(KUidUsbManCategory,KUsbOtgIdPinPresentProperty,EFalse);
   134 	err = RProperty::Set(KUidUsbManCategory,KUsbOtgIdPinPresentProperty,EFalse);
   129 	if ( err != KErrNone )
   135 	if ( err != KErrNone )
   130 	    {
   136 	    {
   131 	    User::LeaveIfError(err);
   137 	    User::LeaveIfError(err);
   132 	    }
   138 	    }
       
   139 	OstTraceFunctionExit0( CUSBOTGIDPINWATCHER_CONSTRUCTL_EXIT );
   133 	}
   140 	}
   134 
   141 
   135 /**
   142 /**
   136  * The CUsbOtgIdPinWatcher::CUsbOtgIdPinWatcher method
   143  * The CUsbOtgIdPinWatcher::CUsbOtgIdPinWatcher method
   137  *
   144  *
   141  */
   148  */
   142 
   149 
   143 CUsbOtgIdPinWatcher::CUsbOtgIdPinWatcher(RUsbOtgDriver& aLdd)
   150 CUsbOtgIdPinWatcher::CUsbOtgIdPinWatcher(RUsbOtgDriver& aLdd)
   144 	: CUsbOtgBaseWatcher(aLdd)
   151 	: CUsbOtgBaseWatcher(aLdd)
   145 	{
   152 	{
   146 	LOG_FUNC
   153 	OstTraceFunctionEntry0( CUSBOTGIDPINWATCHER_CUSBOTGIDPINWATCHER_CONS_ENTRY );
       
   154 	OstTraceFunctionExit0( CUSBOTGIDPINWATCHER_CUSBOTGIDPINWATCHER_CONS_EXIT );
   147 	}
   155 	}
   148 
   156 
   149 /**
   157 /**
   150  * Called when the ID-Pin status change is reported
   158  * Called when the ID-Pin status change is reported
   151  */
   159  */
   152 void CUsbOtgIdPinWatcher::RunL()
   160 void CUsbOtgIdPinWatcher::RunL()
   153 	{
   161 	{
   154 	LOG_FUNC
   162 	OstTraceFunctionEntry0( CUSBOTGIDPINWATCHER_RUNL_ENTRY );
   155 	LOGTEXT2(_L8(">>CUsbOtgIdPinWatcher::RunL [iStatus=%d]"), iStatus.Int());
   163 	OstTrace1( TRACE_NORMAL, CUSBOTGIDPINWATCHER_RUNL, "CUsbOtgIdPinWatcher::RunL;iStatus=%d", iStatus.Int() );
   156 
   164 
   157 	LEAVEIFERRORL(iStatus.Int());
   165     TInt err = iStatus.Int();
       
   166     if(err < 0)
       
   167         {
       
   168         OstTrace1( TRACE_NORMAL, CUSBOTGIDPINWATCHER_RUNL_DUP1, "CUsbOtgIdPinWatcher::RunL;iStatus.Int() with error=%d", err );
       
   169         User::Leave(err);
       
   170         }
   158 	
   171 	
   159 	Post();
   172 	Post();
   160 
   173 
   161 	LOGTEXT(_L8("<<CUsbOtgIdPinWatcher::RunL"));
   174 	OstTraceFunctionExit0( CUSBOTGIDPINWATCHER_RUNL_EXIT );
   162 	}
   175 	}
   163 
   176 
   164 
   177 
   165 /**
   178 /**
   166  * Automatically called when the ID-Pin watcher is cancelled.
   179  * Automatically called when the ID-Pin watcher is cancelled.
   167  */
   180  */
   168 void CUsbOtgIdPinWatcher::DoCancel()
   181 void CUsbOtgIdPinWatcher::DoCancel()
   169 	{
   182 	{
   170 	LOG_FUNC
   183 	OstTraceFunctionEntry0( CUSBOTGIDPINWATCHER_DOCANCEL_ENTRY );
   171 	iLdd.CancelOtgIdPinNotification();
   184 	iLdd.CancelOtgIdPinNotification();
       
   185 	OstTraceFunctionExit0( CUSBOTGIDPINWATCHER_DOCANCEL_EXIT );
   172 	}
   186 	}
   173 
   187 
   174 /**
   188 /**
   175  * Sets state watcher in active state
   189  * Sets state watcher in active state
   176  */
   190  */
   177 void CUsbOtgIdPinWatcher::Post()
   191 void CUsbOtgIdPinWatcher::Post()
   178 	{
   192 	{
   179 	LOG_FUNC
   193 	OstTraceFunctionEntry0( CUSBOTGIDPINWATCHER_POST_ENTRY );
   180 
   194 
   181 	LOGTEXT(_L8("CUsbOtgIdPinWatcher::Post() - About to call QueueOtgIdPinNotification"));
   195 	OstTrace0( TRACE_NORMAL, CUSBOTGIDPINWATCHER_POST, "CUsbOtgIdPinWatcher::Post - About to call QueueOtgIdPinNotification" );
       
   196 	
   182 	iLdd.QueueOtgIdPinNotification(iOtgIdPin, iStatus);
   197 	iLdd.QueueOtgIdPinNotification(iOtgIdPin, iStatus);
   183 	switch (iOtgIdPin)
   198 	switch (iOtgIdPin)
   184 		{
   199 		{
   185 		case RUsbOtgDriver::EIdPinAPlug:
   200 		case RUsbOtgDriver::EIdPinAPlug:
   186 			if (RProperty::Set(KUidUsbManCategory,KUsbOtgIdPinPresentProperty,ETrue) != KErrNone)
   201 			if (RProperty::Set(KUidUsbManCategory,KUsbOtgIdPinPresentProperty,ETrue) != KErrNone)
   187 				{
   202 				{
   188 				LOGTEXT2(_L8(">>CUsbOtgIdPinWatcher::Post [iOtgIdPin=%d] - failed to set the property value"), iOtgIdPin);
   203 				OstTrace1( TRACE_NORMAL, CUSBOTGIDPINWATCHER_POST_DUP1, 
       
   204 				        "CUsbOtgIdPinWatcher::Post; [iOtgIdPin=%d] - failed to set the property value", iOtgIdPin );				
   189 				}
   205 				}
   190 			else
   206 			else
   191 				{
   207 				{
   192 				LOGTEXT2(_L8(">>CUsbOtgIdPinWatcher::Post [iOtgIdPin=%d] - property is set to 1"), iOtgIdPin);
   208 				OstTrace1( TRACE_NORMAL, CUSBOTGIDPINWATCHER_POST_DUP2, 
       
   209 				        "CUsbOtgIdPinWatcher::Post; [iOtgIdPin=%d] - property is set to 1", iOtgIdPin );				
   193 				}
   210 				}
   194 			break;
   211 			break;
   195 		case RUsbOtgDriver::EIdPinBPlug:
   212 		case RUsbOtgDriver::EIdPinBPlug:
   196 		case RUsbOtgDriver::EIdPinUnknown:
   213 		case RUsbOtgDriver::EIdPinUnknown:
   197 			if (RProperty::Set(KUidUsbManCategory,KUsbOtgIdPinPresentProperty,EFalse) != KErrNone)
   214 			if (RProperty::Set(KUidUsbManCategory,KUsbOtgIdPinPresentProperty,EFalse) != KErrNone)
   198 				{
   215 				{
   199 				LOGTEXT2(_L8(">>CUsbOtgIdPinWatcher::Post [iOtgIdPin=%d] - failed to set the property value"), iOtgIdPin);
   216 				OstTrace1( TRACE_NORMAL, CUSBOTGIDPINWATCHER_POST_DUP3, 
       
   217 				        "CUsbOtgIdPinWatcher::Post; [iOtgIdPin=%d] - failed to set the property value", iOtgIdPin );				
   200 				}
   218 				}
   201 			else
   219 			else
   202 				{
   220 				{
   203 				LOGTEXT2(_L8(">>CUsbOtgIdPinWatcher::Post [iOtgIdPin=%d] - property is set to 0"), iOtgIdPin);
   221 				OstTrace1( TRACE_NORMAL, CUSBOTGIDPINWATCHER_POST_DUP4, 
       
   222 				        "CUsbOtgIdPinWatcher::Post; [iOtgIdPin=%d] - property is set to 0", iOtgIdPin );				
   204 				}
   223 				}
   205 			break;
   224 			break;
   206 		default:
   225 		default:
   207 			LOGTEXT2(_L8(">>CUsbOtgIdPinWatcher::Post [iOtgIdPin=%d] is unrecognized, re-request QueueOtgIdPinNotification"), iOtgIdPin);
   226 			OstTrace1( TRACE_NORMAL, CUSBOTGIDPINWATCHER_POST_DUP5, 
       
   227 			        "CUsbOtgIdPinWatcher::Post; [iOtgIdPin=%d] is unrecognized, re-request QueueOtgIdPinNotification", iOtgIdPin );
   208 			break;
   228 			break;
   209 		}
   229 		}
   210 	SetActive();
   230 	SetActive();
       
   231 	OstTraceFunctionExit0( CUSBOTGIDPINWATCHER_POST_EXIT );
   211 	}
   232 	}
   212 
   233 
   213 //----------------------------- VBus watcher class ---------------------------- 
   234 //----------------------------- VBus watcher class ---------------------------- 
   214 /**
   235 /**
   215  * The CUsbOtgVbusWatcher::NewL method
   236  * The CUsbOtgVbusWatcher::NewL method
   221  *
   242  *
   222  * @return	A new CUsbOtgVbusWatcher object
   243  * @return	A new CUsbOtgVbusWatcher object
   223  */
   244  */
   224 CUsbOtgVbusWatcher* CUsbOtgVbusWatcher::NewL(RUsbOtgDriver& aLdd)
   245 CUsbOtgVbusWatcher* CUsbOtgVbusWatcher::NewL(RUsbOtgDriver& aLdd)
   225 	{
   246 	{
   226 	LOG_STATIC_FUNC_ENTRY
   247 	OstTraceFunctionEntry0( CUSBOTGVBUSWATCHER_NEWL_ENTRY );
   227 
   248 
   228 	CUsbOtgVbusWatcher* self = new (ELeave) CUsbOtgVbusWatcher(aLdd);
   249 	CUsbOtgVbusWatcher* self = new (ELeave) CUsbOtgVbusWatcher(aLdd);
   229 	CleanupStack::PushL(self);
   250 	CleanupStack::PushL(self);
   230 	self->ConstructL();
   251 	self->ConstructL();
   231 	CleanupStack::Pop(self);
   252 	CleanupStack::Pop(self);
       
   253 	OstTraceFunctionExit0( CUSBOTGVBUSWATCHER_NEWL_EXIT );
   232 	return self;
   254 	return self;
   233 	}
   255 	}
   234 
   256 
   235 
   257 
   236 /**
   258 /**
   240  *
   262  *
   241  * @internalComponent
   263  * @internalComponent
   242  */
   264  */
   243 CUsbOtgVbusWatcher::~CUsbOtgVbusWatcher()
   265 CUsbOtgVbusWatcher::~CUsbOtgVbusWatcher()
   244 	{
   266 	{
   245 	LOG_FUNC
   267 	OstTraceFunctionEntry0( CUSBOTGVBUSWATCHER_CUSBOTGVBUSWATCHER_DES_ENTRY );
   246 	Cancel();
   268 	Cancel();
   247 
   269 
   248 	RProperty::Delete(KUsbOtgVBusPoweredProperty);
   270 	RProperty::Delete(KUsbOtgVBusPoweredProperty);
       
   271 	OstTraceFunctionExit0( CUSBOTGVBUSWATCHER_CUSBOTGVBUSWATCHER_DES_EXIT );
   249 	}
   272 	}
   250 
   273 
   251 void CUsbOtgVbusWatcher::ConstructL()
   274 void CUsbOtgVbusWatcher::ConstructL()
   252 /**
   275 /**
   253  * Performs 2nd phase construction of the OTG object.
   276  * Performs 2nd phase construction of the OTG object.
   254  */
   277  */
   255 	{
   278 	{
   256 	LOG_FUNC
   279 	OstTraceFunctionEntry0( CUSBOTGVBUSWATCHER_CONSTRUCTL_ENTRY );
   257 
   280 
   258 	TInt err = RProperty::Define(KUsbOtgVBusPoweredProperty, RProperty::EInt, KAllowAllPolicy, KNetworkControlPolicy);
   281 	TInt err = RProperty::Define(KUsbOtgVBusPoweredProperty, RProperty::EInt, KAllowAllPolicy, KNetworkControlPolicy);
   259 	if ( err != KErrNone && err != KErrAlreadyExists )
   282 	if ( err != KErrNone && err != KErrAlreadyExists )
   260 	    {
   283 	    {
   261 	    User::LeaveIfError(err);
   284 	    User::LeaveIfError(err);
   263 	err = RProperty::Set(KUidUsbManCategory,KUsbOtgVBusPoweredProperty,EFalse);
   286 	err = RProperty::Set(KUidUsbManCategory,KUsbOtgVBusPoweredProperty,EFalse);
   264 	if ( err != KErrNone )
   287 	if ( err != KErrNone )
   265 	    {
   288 	    {
   266 	    User::LeaveIfError(err);
   289 	    User::LeaveIfError(err);
   267 	    }
   290 	    }
       
   291 	OstTraceFunctionExit0( CUSBOTGVBUSWATCHER_CONSTRUCTL_EXIT );
   268 	}
   292 	}
   269 
   293 
   270 /**
   294 /**
   271  * The CUsbOtgVbusWatcher::CUsbOtgVbusWatcher method
   295  * The CUsbOtgVbusWatcher::CUsbOtgVbusWatcher method
   272  *
   296  *
   275  * @param	aLdd	A reference to the USB OTG Logical Device Driver
   299  * @param	aLdd	A reference to the USB OTG Logical Device Driver
   276  */
   300  */
   277 CUsbOtgVbusWatcher::CUsbOtgVbusWatcher(RUsbOtgDriver& aLdd)
   301 CUsbOtgVbusWatcher::CUsbOtgVbusWatcher(RUsbOtgDriver& aLdd)
   278 	: CUsbOtgBaseWatcher(aLdd)
   302 	: CUsbOtgBaseWatcher(aLdd)
   279 	{
   303 	{
   280 	LOG_FUNC
   304 	OstTraceFunctionEntry0( CUSBOTGVBUSWATCHER_CUSBOTGVBUSWATCHER_CONS_ENTRY );
       
   305 	OstTraceFunctionExit0( CUSBOTGVBUSWATCHER_CUSBOTGVBUSWATCHER_CONS_EXIT );
   281 	}
   306 	}
   282 
   307 
   283 /**
   308 /**
   284  * Called when the Vbus status is changed
   309  * Called when the Vbus status is changed
   285  */
   310  */
   286 void CUsbOtgVbusWatcher::RunL()
   311 void CUsbOtgVbusWatcher::RunL()
   287 	{
   312 	{
   288 	LOG_FUNC
   313 	OstTraceFunctionEntry0( CUSBOTGVBUSWATCHER_RUNL_ENTRY );
   289 	LOGTEXT2(_L8(">>CUsbOtgVbusWatcher::RunL [iStatus=%d]"), iStatus.Int());
   314 	OstTrace1( TRACE_NORMAL, CUSBOTGVBUSWATCHER_RUNL, "CUsbOtgVbusWatcher::RunL;iStatus=%d", iStatus.Int() );
   290 
   315 
   291 	LEAVEIFERRORL(iStatus.Int());
   316     TInt err = iStatus.Int();
       
   317     if(err < 0)
       
   318         {
       
   319         OstTrace1( TRACE_NORMAL, CUSBOTGVBUSWATCHER_RUNL_DUP1, "CUsbOtgVbusWatcher::RunL;iStatus.Int() with error=%d", err );
       
   320         User::Leave(err);
       
   321         }
   292 
   322 
   293 	Post();
   323 	Post();
   294 
   324 
   295 	LOGTEXT(_L8("<<CUsbOtgVbusWatcher::RunL"));
   325 	OstTraceFunctionExit0( CUSBOTGVBUSWATCHER_RUNL_EXIT );
   296 	}
   326 	}
   297 
   327 
   298 
   328 
   299 /**
   329 /**
   300  * Automatically called when the VBus status watcher is cancelled.
   330  * Automatically called when the VBus status watcher is cancelled.
   301  */
   331  */
   302 void CUsbOtgVbusWatcher::DoCancel()
   332 void CUsbOtgVbusWatcher::DoCancel()
   303 	{
   333 	{
   304 	LOG_FUNC
   334 	OstTraceFunctionEntry0( CUSBOTGVBUSWATCHER_DOCANCEL_ENTRY );
   305 	iLdd.CancelOtgVbusNotification();
   335 	iLdd.CancelOtgVbusNotification();
       
   336 	OstTraceFunctionExit0( CUSBOTGVBUSWATCHER_DOCANCEL_EXIT );
   306 	}
   337 	}
   307 
   338 
   308 /**
   339 /**
   309  * Sets state watcher in active state
   340  * Sets state watcher in active state
   310  */
   341  */
   311 void CUsbOtgVbusWatcher::Post()
   342 void CUsbOtgVbusWatcher::Post()
   312 	{
   343 	{
   313 	LOG_FUNC
   344 	OstTraceFunctionEntry0( CUSBOTGVBUSWATCHER_POST_ENTRY );
   314 
   345 
   315 	LOGTEXT(_L8("CUsbOtgVbusWatcher::Post() - About to call QueueOtgVbusNotification"));
   346 	OstTrace0( TRACE_NORMAL, CUSBOTGVBUSWATCHER_POST, "CUsbOtgVbusWatcher::Post - About to call QueueOtgVbusNotification" );
       
   347 	
   316 	iLdd.QueueOtgVbusNotification(iOtgVbus, iStatus);
   348 	iLdd.QueueOtgVbusNotification(iOtgVbus, iStatus);
   317 	switch (iOtgVbus)
   349 	switch (iOtgVbus)
   318 		{
   350 		{
   319 		case RUsbOtgDriver::EVbusHigh:
   351 		case RUsbOtgDriver::EVbusHigh:
   320 			if (RProperty::Set(KUidUsbManCategory,KUsbOtgVBusPoweredProperty,ETrue) != KErrNone)
   352 			if (RProperty::Set(KUidUsbManCategory,KUsbOtgVBusPoweredProperty,ETrue) != KErrNone)
   321 				{
   353 				{
   322 				LOGTEXT2(_L8(">>CUsbOtgVbusWatcher::Post [iOtgVbus=%d](EVbusHigh) - failed to set the property value"), iOtgVbus);
   354 				OstTrace1( TRACE_NORMAL, CUSBOTGVBUSWATCHER_POST_DUP1, 
       
   355 				        "CUsbOtgVbusWatcher::Post;[iOtgVbus=%d](EVbusHigh) - failed to set the property value", iOtgVbus );
   323 				}
   356 				}
   324 			else
   357 			else
   325 				{
   358 				{
   326 				LOGTEXT2(_L8(">>CUsbOtgVbusWatcher::Post [iOtgVbus=%d](EVbusHigh) - property is set to ETrue"), iOtgVbus);
   359 				OstTrace1( TRACE_NORMAL, CUSBOTGVBUSWATCHER_POST_DUP2, 
       
   360 				        "CUsbOtgVbusWatcher::Post;[iOtgVbus=%d](EVbusHigh) - property is set to ETrue", iOtgVbus );
   327 				}
   361 				}
   328 			break;
   362 			break;
   329 		case RUsbOtgDriver::EVbusLow:
   363 		case RUsbOtgDriver::EVbusLow:
   330 		case RUsbOtgDriver::EVbusUnknown:
   364 		case RUsbOtgDriver::EVbusUnknown:
   331 			if (RProperty::Set(KUidUsbManCategory,KUsbOtgVBusPoweredProperty,EFalse) != KErrNone)
   365 			if (RProperty::Set(KUidUsbManCategory,KUsbOtgVBusPoweredProperty,EFalse) != KErrNone)
   332 				{
   366 				{
   333 				LOGTEXT2(_L8(">>CUsbOtgVbusWatcher::Post [iOtgVbus=%d](1 - EVbusLow, 2 - EVbusUnknown) - failed to set the property value"), iOtgVbus);
   367 				OstTrace1( TRACE_NORMAL, CUSBOTGVBUSWATCHER_POST_DUP3, 
       
   368 				        "CUsbOtgVbusWatcher::Post;[iOtgVbus=%d](1 - EVbusLow, 2 - EVbusUnknown) - failed to set the property value", iOtgVbus );
   334 				}
   369 				}
   335 			else
   370 			else
   336 				{
   371 				{
   337 				LOGTEXT2(_L8(">>CUsbOtgVbusWatcher::Post [iOtgVbus=%d](1 - EVbusLow, 2 - EVbusUnknown) - property is set to EFalse"), iOtgVbus);
   372 				OstTrace1( TRACE_NORMAL, CUSBOTGVBUSWATCHER_POST_DUP4, 
       
   373 				        "CUsbOtgVbusWatcher::Post;[iOtgVbus=%d](1 - EVbusLow, 2 - EVbusUnknown) - property is set to EFalse", iOtgVbus );
   338 				}
   374 				}
   339 			break;
   375 			break;
   340 		default:
   376 		default:
   341 			LOGTEXT2(_L8(">>CUsbOtgVbusWatcher::RunL [iOtgVbus=%d] is unrecognized, re-request QueueOtgVbusNotification"), iOtgVbus);
   377 			OstTrace1( TRACE_NORMAL, CUSBOTGVBUSWATCHER_POST_DUP5, 
       
   378 			        "CUsbOtgVbusWatcher::Post;iOtgVbus=%d] is unrecognized, re-request QueueOtgVbusNotification", iOtgVbus );
   342 			break;
   379 			break;
   343 		}
   380 		}
   344 	SetActive();
   381 	SetActive();
       
   382 	OstTraceFunctionExit0( CUSBOTGVBUSWATCHER_POST_EXIT );
   345 	}
   383 	}
   346 
   384 
   347 
   385 
   348 //-------------------------- OTG State watcher class -------------------------- 
   386 //-------------------------- OTG State watcher class -------------------------- 
   349 /**
   387 /**
   356  *
   394  *
   357  * @return	A new CUsbOtgWatcher object
   395  * @return	A new CUsbOtgWatcher object
   358  */
   396  */
   359 CUsbOtgStateWatcher* CUsbOtgStateWatcher::NewL(RUsbOtgDriver& aLdd)
   397 CUsbOtgStateWatcher* CUsbOtgStateWatcher::NewL(RUsbOtgDriver& aLdd)
   360 	{
   398 	{
   361 	LOG_STATIC_FUNC_ENTRY
   399 	OstTraceFunctionEntry0( CUSBOTGSTATEWATCHER_NEWL_ENTRY );
   362 
   400 
   363 	CUsbOtgStateWatcher* self = new (ELeave) CUsbOtgStateWatcher(aLdd);
   401 	CUsbOtgStateWatcher* self = new (ELeave) CUsbOtgStateWatcher(aLdd);
   364 	CleanupStack::PushL(self);
   402 	CleanupStack::PushL(self);
   365 	self->ConstructL();
   403 	self->ConstructL();
   366 	CleanupStack::Pop(self);
   404 	CleanupStack::Pop(self);
       
   405 	OstTraceFunctionExit0( CUSBOTGSTATEWATCHER_NEWL_EXIT );
   367 	return self;
   406 	return self;
   368 	}
   407 	}
   369 
   408 
   370 
   409 
   371 /**
   410 /**
   375  *
   414  *
   376  * @internalComponent
   415  * @internalComponent
   377  */
   416  */
   378 CUsbOtgStateWatcher::~CUsbOtgStateWatcher()
   417 CUsbOtgStateWatcher::~CUsbOtgStateWatcher()
   379 	{
   418 	{
   380 	LOG_FUNC
   419 	OstTraceFunctionEntry0( CUSBOTGSTATEWATCHER_CUSBOTGSTATEWATCHER_DES_ENTRY );
   381 	Cancel();
   420 	Cancel();
   382 	RProperty::Delete(KUsbOtgStateProperty);
   421 	RProperty::Delete(KUsbOtgStateProperty);
       
   422 	OstTraceFunctionExit0( CUSBOTGSTATEWATCHER_CUSBOTGSTATEWATCHER_DES_EXIT );
   383 	}
   423 	}
   384 
   424 
   385 void CUsbOtgStateWatcher::ConstructL()
   425 void CUsbOtgStateWatcher::ConstructL()
   386 /**
   426 /**
   387  * Performs 2nd phase construction of the OTG object.
   427  * Performs 2nd phase construction of the OTG object.
   388  */
   428  */
   389 	{
   429 	{
   390 	LOG_FUNC
   430 	OstTraceFunctionEntry0( CUSBOTGSTATEWATCHER_CONSTRUCTL_ENTRY );
   391 
   431 
   392 	TInt err = RProperty::Define(KUsbOtgStateProperty, RProperty::EInt, KAllowAllPolicy, KNetworkControlPolicy);
   432 	TInt err = RProperty::Define(KUsbOtgStateProperty, RProperty::EInt, KAllowAllPolicy, KNetworkControlPolicy);
   393 	if ( err != KErrNone && err != KErrAlreadyExists )
   433 	if ( err != KErrNone && err != KErrAlreadyExists )
   394 	    {
   434 	    {
   395 	    User::LeaveIfError(err);
   435 	    User::LeaveIfError(err);
   397 	err = RProperty::Set(KUidUsbManCategory,KUsbOtgStateProperty,RUsbOtgDriver::EStateReset);
   437 	err = RProperty::Set(KUidUsbManCategory,KUsbOtgStateProperty,RUsbOtgDriver::EStateReset);
   398 	if ( err != KErrNone )
   438 	if ( err != KErrNone )
   399 	    {
   439 	    {
   400 	    User::LeaveIfError(err);
   440 	    User::LeaveIfError(err);
   401 	    }
   441 	    }
       
   442 	OstTraceFunctionExit0( CUSBOTGSTATEWATCHER_CONSTRUCTL_EXIT );
   402 	}
   443 	}
   403 
   444 
   404 /**
   445 /**
   405  * The CUsbOtgIdPinWatcher::CUsbOtgIdPinWatcher method
   446  * The CUsbOtgIdPinWatcher::CUsbOtgIdPinWatcher method
   406  *
   447  *
   410  */
   451  */
   411 
   452 
   412 CUsbOtgStateWatcher::CUsbOtgStateWatcher(RUsbOtgDriver& aLdd)
   453 CUsbOtgStateWatcher::CUsbOtgStateWatcher(RUsbOtgDriver& aLdd)
   413 	: CUsbOtgBaseWatcher(aLdd)
   454 	: CUsbOtgBaseWatcher(aLdd)
   414 	{
   455 	{
   415 	LOG_FUNC
   456 	OstTraceFunctionEntry0( CUSBOTGSTATEWATCHER_CUSBOTGSTATEWATCHER_CONS_ENTRY );
   416 	iOtgState = RUsbOtgDriver::EStateReset;
   457 	iOtgState = RUsbOtgDriver::EStateReset;
       
   458 	OstTraceFunctionExit0( CUSBOTGSTATEWATCHER_CUSBOTGSTATEWATCHER_CONS_EXIT );
   417 	}
   459 	}
   418 
   460 
   419 /**
   461 /**
   420  * Called when the OTG State change is reported
   462  * Called when the OTG State change is reported
   421  */
   463  */
   422 void CUsbOtgStateWatcher::RunL()
   464 void CUsbOtgStateWatcher::RunL()
   423 	{
   465 	{
   424 	LOG_FUNC
   466 	OstTraceFunctionEntry0( CUSBOTGSTATEWATCHER_RUNL_ENTRY );
   425 	LOGTEXT2(_L8(">>CUsbOtgStateWatcher::RunL [iStatus=%d]"), iStatus.Int());
   467 	OstTrace1( TRACE_NORMAL, CUSBOTGSTATEWATCHER_RUNL, "CUsbOtgStateWatcher::RunL;iStatus.Int()=%d", iStatus.Int() );
   426 
   468 
   427 	LEAVEIFERRORL(iStatus.Int());
   469     TInt err = iStatus.Int();
       
   470     if(err < 0)
       
   471         {
       
   472         OstTrace1( TRACE_NORMAL, CUSBOTGSTATEWATCHER_RUNL_DUP1, "CUsbOtgStateWatcher::RunL;iStatus.Int() with error=%d", err );
       
   473         User::Leave(err);
       
   474         }
   428 
   475 
   429 	Post();
   476 	Post();
   430 
   477 
   431 	LOGTEXT(_L8("<<CUsbOtgStateWatcher::RunL"));
   478 	OstTraceFunctionExit0( CUSBOTGSTATEWATCHER_RUNL_EXIT );
   432 	}
   479 	}
   433 
   480 
   434 
   481 
   435 /**
   482 /**
   436  * Automatically called when the OTG State watcher is cancelled.
   483  * Automatically called when the OTG State watcher is cancelled.
   437  */
   484  */
   438 void CUsbOtgStateWatcher::DoCancel()
   485 void CUsbOtgStateWatcher::DoCancel()
   439 	{
   486 	{
   440 	LOG_FUNC
   487 	OstTraceFunctionEntry0( CUSBOTGSTATEWATCHER_DOCANCEL_ENTRY );
   441 	iLdd.CancelOtgStateNotification();
   488 	iLdd.CancelOtgStateNotification();
       
   489 	OstTraceFunctionExit0( CUSBOTGSTATEWATCHER_DOCANCEL_EXIT );
   442 	}
   490 	}
   443 
   491 
   444 /**
   492 /**
   445  * Sets state watcher in active state
   493  * Sets state watcher in active state
   446  */
   494  */
   447 void CUsbOtgStateWatcher::Post()
   495 void CUsbOtgStateWatcher::Post()
   448 	{
   496 	{
   449 	LOG_FUNC
   497 	OstTraceFunctionEntry0( CUSBOTGSTATEWATCHER_POST_ENTRY );
   450 
   498 
   451 	LOGTEXT(_L8("CUsbOtgStateWatcher::Post() - About to call QueueOtgStateNotification"));	
   499 	OstTrace0( TRACE_NORMAL, CUSBOTGSTATEWATCHER_POST, "CUsbOtgStateWatcher::Post - About to call QueueOtgStateNotification" );
   452 	iLdd.QueueOtgStateNotification(iOtgState, iStatus);
   500 	iLdd.QueueOtgStateNotification(iOtgState, iStatus);
   453 	LOGTEXT3(_L8(">>CUsbOtgStateWatcher::RunL [iStatus=%d], iOtgState = %d"), iStatus.Int(), iOtgState);
   501 	OstTraceExt2( TRACE_NORMAL, CUSBOTGSTATEWATCHER_POST_DUP1, 
       
   502 	        "CUsbOtgStateWatcher::Post;[iStatus=%d], iOtgState = %d", iStatus.Int(), iOtgState );
   454 	if (RProperty::Set(KUidUsbManCategory,KUsbOtgStateProperty,(TInt)iOtgState) != KErrNone)
   503 	if (RProperty::Set(KUidUsbManCategory,KUsbOtgStateProperty,(TInt)iOtgState) != KErrNone)
   455 	{
   504 	{
   456 		LOGTEXT3(_L8(">>CUsbOtgStateWatcher::RunL [iStatus=%d], iOtgState = %d - failed to set the property"), iStatus.Int(), iOtgState);
   505 		OstTraceExt2( TRACE_NORMAL, CUSBOTGSTATEWATCHER_POST_DUP2, 
       
   506 		        "CUsbOtgStateWatcher::Post;[iStatus=%d], iOtgState = %d - failed to set the property", iStatus.Int(), iOtgState );
   457 	}
   507 	}
   458 
   508 
   459 	SetActive();
   509 	SetActive();
       
   510 	OstTraceFunctionExit0( CUSBOTGSTATEWATCHER_POST_EXIT );
   460 	}
   511 	}
   461 
   512 
   462 //-------------------------- OTG Events watcher class ------------------------- 
   513 //-------------------------- OTG Events watcher class ------------------------- 
   463 /**
   514 /**
   464  * The CUsbOtgEventWatcher::NewL method
   515  * The CUsbOtgEventWatcher::NewL method
   473  * @return	A new CUsbOtgEventWatcher object
   524  * @return	A new CUsbOtgEventWatcher object
   474  */
   525  */
   475 CUsbOtgEventWatcher* CUsbOtgEventWatcher::NewL(CUsbOtg& aOwner, RUsbOtgDriver& aLdd,
   526 CUsbOtgEventWatcher* CUsbOtgEventWatcher::NewL(CUsbOtg& aOwner, RUsbOtgDriver& aLdd,
   476 											   RUsbOtgDriver::TOtgEvent& aOtgEvent)
   527 											   RUsbOtgDriver::TOtgEvent& aOtgEvent)
   477 	{
   528 	{
   478 	LOG_STATIC_FUNC_ENTRY
   529 	OstTraceFunctionEntry0( CUSBOTGEVENTWATCHER_NEWL_ENTRY );
   479 
   530 
   480 	CUsbOtgEventWatcher* self = new (ELeave) CUsbOtgEventWatcher(aOwner, aLdd, aOtgEvent);
   531 	CUsbOtgEventWatcher* self = new (ELeave) CUsbOtgEventWatcher(aOwner, aLdd, aOtgEvent);
   481 	CleanupStack::PushL(self);
   532 	CleanupStack::PushL(self);
   482 	self->ConstructL();
   533 	self->ConstructL();
   483 	CleanupStack::Pop(self);
   534 	CleanupStack::Pop(self);
       
   535 	OstTraceFunctionExit0( CUSBOTGEVENTWATCHER_NEWL_EXIT );
   484 	return self;
   536 	return self;
   485 	}
   537 	}
   486 
   538 
   487 
   539 
   488 /**
   540 /**
   492  *
   544  *
   493  * @internalComponent
   545  * @internalComponent
   494  */
   546  */
   495 CUsbOtgEventWatcher::~CUsbOtgEventWatcher()
   547 CUsbOtgEventWatcher::~CUsbOtgEventWatcher()
   496 	{
   548 	{
   497 	LOG_FUNC
   549 	OstTraceFunctionEntry0( CUSBOTGEVENTWATCHER_CUSBOTGEVENTWATCHER_DES_ENTRY );
   498 	Cancel();
   550 	Cancel();
       
   551 	OstTraceFunctionExit0( CUSBOTGEVENTWATCHER_CUSBOTGEVENTWATCHER_DES_EXIT );
   499 	}
   552 	}
   500 
   553 
   501 void CUsbOtgEventWatcher::ConstructL()
   554 void CUsbOtgEventWatcher::ConstructL()
   502 /**
   555 /**
   503  * Performs 2nd phase construction of the OTG object.
   556  * Performs 2nd phase construction of the OTG object.
   504  */
   557  */
   505 	{
   558 	{
   506 	LOG_FUNC
   559 	OstTraceFunctionEntry0( CUSBOTGEVENTWATCHER_CONSTRUCTL_ENTRY );
       
   560 	OstTraceFunctionExit0( CUSBOTGEVENTWATCHER_CONSTRUCTL_EXIT );
   507 	}
   561 	}
   508 
   562 
   509 /**
   563 /**
   510  * The CUsbOtgEventWatcher::CUsbOtgEventWatcher method
   564  * The CUsbOtgEventWatcher::CUsbOtgEventWatcher method
   511  *
   565  *
   517  */
   571  */
   518 CUsbOtgEventWatcher::CUsbOtgEventWatcher(CUsbOtg& aOwner, RUsbOtgDriver& aLdd, 
   572 CUsbOtgEventWatcher::CUsbOtgEventWatcher(CUsbOtg& aOwner, RUsbOtgDriver& aLdd, 
   519 										 RUsbOtgDriver::TOtgEvent& aOtgEvent)
   573 										 RUsbOtgDriver::TOtgEvent& aOtgEvent)
   520 	: CUsbOtgBaseWatcher(aLdd), iOwner(aOwner), iOtgEvent(aOtgEvent)
   574 	: CUsbOtgBaseWatcher(aLdd), iOwner(aOwner), iOtgEvent(aOtgEvent)
   521 	{
   575 	{
   522 	LOG_FUNC
   576 	OstTraceFunctionEntry0( CUSBOTGEVENTWATCHER_CUSBOTGEVENTWATCHER_CONS_ENTRY );
       
   577 	OstTraceFunctionExit0( CUSBOTGEVENTWATCHER_CUSBOTGEVENTWATCHER_CONS_EXIT );
   523 	}
   578 	}
   524 
   579 
   525 /**
   580 /**
   526  * Called when the OTG Event is reported
   581  * Called when the OTG Event is reported
   527  */
   582  */
   528 void CUsbOtgEventWatcher::RunL()
   583 void CUsbOtgEventWatcher::RunL()
   529 	{
   584 	{
   530 	LOG_FUNC
   585 	OstTraceFunctionEntry0( CUSBOTGEVENTWATCHER_RUNL_ENTRY );
   531 	LOGTEXT2(_L8(">>CUsbOtgEventWatcher::RunL [iStatus=%d]"), iStatus.Int());
   586 	OstTrace1( TRACE_NORMAL, CUSBOTGEVENTWATCHER_RUNL, "CUsbOtgEventWatcher::RunL;iStatus=%d", iStatus.Int() );
   532 
   587     TInt err = iStatus.Int();
   533 	LEAVEIFERRORL(iStatus.Int());
   588     if(err < 0)
   534 	LOGTEXT2(_L8("CUsbOtgEventWatcher::RunL() - Otg Event reported: %d"), (TInt)iOtgEvent);
   589         {
       
   590         OstTrace1( TRACE_NORMAL, CUSBOTGEVENTWATCHER_RUNL_DUP3, "CUsbOtgEventWatcher::RunL;iStatus.Int() with error=%d", err );
       
   591         User::Leave(err);
       
   592         }
       
   593     
       
   594 	OstTrace1( TRACE_NORMAL, CUSBOTGEVENTWATCHER_RUNL_DUP1, 
       
   595 	        "CUsbOtgEventWatcher::RunL; - Otg Event reported: %d", (TInt)iOtgEvent );
   535 	if (  ( iOtgEvent == RUsbOtgDriver::EEventHnpDisabled )
   596 	if (  ( iOtgEvent == RUsbOtgDriver::EEventHnpDisabled )
   536 	    ||( iOtgEvent == RUsbOtgDriver::EEventHnpEnabled )
   597 	    ||( iOtgEvent == RUsbOtgDriver::EEventHnpEnabled )
   537 	    ||( iOtgEvent == RUsbOtgDriver::EEventSrpInitiated )
   598 	    ||( iOtgEvent == RUsbOtgDriver::EEventSrpInitiated )
   538 	    ||( iOtgEvent == RUsbOtgDriver::EEventSrpReceived )
   599 	    ||( iOtgEvent == RUsbOtgDriver::EEventSrpReceived )
   539 	    ||( iOtgEvent == RUsbOtgDriver::EEventVbusRaised )
   600 	    ||( iOtgEvent == RUsbOtgDriver::EEventVbusRaised )
   540 	    ||( iOtgEvent == RUsbOtgDriver::EEventVbusDropped )
   601 	    ||( iOtgEvent == RUsbOtgDriver::EEventVbusDropped )
   541 	   )
   602 	   )
   542 		{
   603 		{
   543 		iOwner.NotifyOtgEvent();
   604 		iOwner.NotifyOtgEvent();
   544 		LOGTEXT2(_L8("CUsbOtgEventWatcher::RunL() - The owner is notified about Otg Event = %d"), (TInt)iOtgEvent);
   605 		OstTrace1( TRACE_NORMAL, CUSBOTGEVENTWATCHER_RUNL_DUP2, 
       
   606 		        "CUsbOtgEventWatcher::RunL - The owner is notified about Otg Event = %d", (TInt)iOtgEvent );
   545 		}
   607 		}
   546 	Post();
   608 	Post();
   547 	LOGTEXT(_L8("<<CUsbOtgEventWatcher::RunL"));
   609 	OstTraceFunctionExit0( CUSBOTGEVENTWATCHER_RUNL_EXIT );
   548 	}
   610 	}
   549 
   611 
   550 #ifndef __FLOG_ACTIVE
   612 #ifndef _DEBUG
   551 void CUsbOtgEventWatcher::LogEventText(RUsbOtgDriver::TOtgEvent /*aState*/)
   613 void CUsbOtgEventWatcher::LogEventText(RUsbOtgDriver::TOtgEvent /*aState*/)
   552 	{
   614 	{
   553 	}
   615 	}
   554 #else
   616 #else
   555 void CUsbOtgEventWatcher::LogEventText(RUsbOtgDriver::TOtgEvent aEvent)
   617 void CUsbOtgEventWatcher::LogEventText(RUsbOtgDriver::TOtgEvent aEvent)
   556 	{
   618 	{
   557 	switch (aEvent)
   619 	switch (aEvent)
   558 		{
   620 		{
   559 		case RUsbOtgDriver::EEventAPlugInserted:
   621 		case RUsbOtgDriver::EEventAPlugInserted:
   560 			LOGTEXT(_L8(" ***** A-Plug Inserted *****"));
   622 			OstTrace0( TRACE_NORMAL, CUSBOTGEVENTWATCHER_LOGEVENTTEXT, 
       
   623 			        "CUsbOtgEventWatcher::LogEventText ***** A-Plug Inserted *****" );
   561 			break;
   624 			break;
   562 		case RUsbOtgDriver::EEventAPlugRemoved:
   625 		case RUsbOtgDriver::EEventAPlugRemoved:
   563 			LOGTEXT(_L8(" ***** A-Plug Removed *****"));
   626 			OstTrace0( TRACE_NORMAL, CUSBOTGEVENTWATCHER_LOGEVENTTEXT_DUP1, 
       
   627 			        "CUsbOtgEventWatcher::LogEventText ***** A-Plug Removed *****" );
   564 			break;
   628 			break;
   565 		case RUsbOtgDriver::EEventVbusRaised:
   629 		case RUsbOtgDriver::EEventVbusRaised:
   566 			LOGTEXT(_L8(" ***** VBus Raised *****"));
   630 			OstTrace0( TRACE_NORMAL, CUSBOTGEVENTWATCHER_LOGEVENTTEXT_DUP2, 
       
   631 			        "CUsbOtgEventWatcher::LogEventText ***** VBus Raised *****" );
   567 			break;
   632 			break;
   568 		case RUsbOtgDriver::EEventVbusDropped:
   633 		case RUsbOtgDriver::EEventVbusDropped:
   569 			LOGTEXT(_L8(" ***** VBus Dropped *****"));
   634 			OstTrace0( TRACE_NORMAL, CUSBOTGEVENTWATCHER_LOGEVENTTEXT_DUP3, 
       
   635 			        "CUsbOtgEventWatcher::LogEventText ***** VBus Dropped *****" );
   570 			break;
   636 			break;
   571 		case RUsbOtgDriver::EEventSrpInitiated:
   637 		case RUsbOtgDriver::EEventSrpInitiated:
   572 			LOGTEXT(_L8(" ***** SRP Initiated *****"));
   638 			OstTrace0( TRACE_NORMAL, CUSBOTGEVENTWATCHER_LOGEVENTTEXT_DUP4, 
       
   639 			        "CUsbOtgEventWatcher::LogEventText ***** SRP Initiated *****" );
   573 			break;
   640 			break;
   574 		case RUsbOtgDriver::EEventSrpReceived:
   641 		case RUsbOtgDriver::EEventSrpReceived:
   575 			LOGTEXT(_L8(" ***** SRP Received *****"));
   642 			OstTrace0( TRACE_NORMAL, CUSBOTGEVENTWATCHER_LOGEVENTTEXT_DUP5, 
       
   643 			        "CUsbOtgEventWatcher::LogEventText ***** SRP Received *****" );
   576 			break;
   644 			break;
   577 		case RUsbOtgDriver::EEventHnpEnabled:
   645 		case RUsbOtgDriver::EEventHnpEnabled:
   578 			LOGTEXT(_L8(" ***** HNP Enabled *****"));
   646 			OstTrace0( TRACE_NORMAL, CUSBOTGEVENTWATCHER_LOGEVENTTEXT_DUP6, 
       
   647 			        "CUsbOtgEventWatcher::LogEventText ***** HNP Enabled *****" );
   579 			break;
   648 			break;
   580 		case RUsbOtgDriver::EEventHnpDisabled:
   649 		case RUsbOtgDriver::EEventHnpDisabled:
   581 			LOGTEXT(_L8(" ***** HNP Disabled *****"));
   650 			OstTrace0( TRACE_NORMAL, CUSBOTGEVENTWATCHER_LOGEVENTTEXT_DUP7, 
       
   651 			        "CUsbOtgEventWatcher::LogEventText ***** HNP Disabled *****" );
   582 			break;
   652 			break;
   583 		case RUsbOtgDriver::EEventRoleChangedToHost:
   653 		case RUsbOtgDriver::EEventRoleChangedToHost:
   584 			LOGTEXT(_L8(" ***** Role Changed to Host *****"));
   654 			OstTrace0( TRACE_NORMAL, CUSBOTGEVENTWATCHER_LOGEVENTTEXT_DUP8, 
       
   655 			        "CUsbOtgEventWatcher::LogEventText ***** Role Changed to Host *****" );
   585 			break;
   656 			break;
   586 		case RUsbOtgDriver::EEventRoleChangedToDevice:
   657 		case RUsbOtgDriver::EEventRoleChangedToDevice:
   587 			LOGTEXT(_L8(" ***** Role Changed to Device *****"));
   658 			OstTrace0( TRACE_NORMAL, CUSBOTGEVENTWATCHER_LOGEVENTTEXT_DUP9, 
       
   659 			        "CUsbOtgEventWatcher::LogEventText ***** Role Changed to Device *****" );
   588 			break;
   660 			break;
   589 		case RUsbOtgDriver::EEventRoleChangedToIdle:
   661 		case RUsbOtgDriver::EEventRoleChangedToIdle:
   590 			LOGTEXT(_L8(" ***** Role Changed to Idle *****"));
   662 			OstTrace0( TRACE_NORMAL, CUSBOTGEVENTWATCHER_LOGEVENTTEXT_DUP10, 
       
   663 			        "CUsbOtgEventWatcher::LogEventText ***** Role Changed to Idle *****" );
   591 			break;
   664 			break;
   592 		default:
   665 		default:
   593 			break;
   666 			break;
   594 		}
   667 		}
   595 	}
   668 	}
   598 /**
   671 /**
   599  * Automatically called when the OTG Event watcher is cancelled.
   672  * Automatically called when the OTG Event watcher is cancelled.
   600  */
   673  */
   601 void CUsbOtgEventWatcher::DoCancel()
   674 void CUsbOtgEventWatcher::DoCancel()
   602 	{
   675 	{
   603 	LOG_FUNC
   676 	OstTraceFunctionEntry0( CUSBOTGEVENTWATCHER_DOCANCEL_ENTRY );
   604 	iLdd.CancelOtgEventRequest();
   677 	iLdd.CancelOtgEventRequest();
       
   678 	OstTraceFunctionExit0( CUSBOTGEVENTWATCHER_DOCANCEL_EXIT );
   605 	}
   679 	}
   606 
   680 
   607 /**
   681 /**
   608  * Sets state watcher in active state
   682  * Sets state watcher in active state
   609  */
   683  */
   610 void CUsbOtgEventWatcher::Post()
   684 void CUsbOtgEventWatcher::Post()
   611 	{
   685 	{
   612 	LOG_FUNC
   686 	OstTraceFunctionEntry0( CUSBOTGEVENTWATCHER_POST_ENTRY );
   613 
   687 
   614 	LOGTEXT(_L8("CUsbOtgEventWatcher::Post() - About to call QueueOtgEventRequest"));	
   688 	OstTrace0( TRACE_NORMAL, CUSBOTGEVENTWATCHER_POST, "CUsbOtgEventWatcher::Post - About to call QueueOtgEventRequest" );
   615 	iLdd.QueueOtgEventRequest(iOtgEvent, iStatus);
   689 	iLdd.QueueOtgEventRequest(iOtgEvent, iStatus);
   616 	SetActive();
   690 	SetActive();
       
   691 	OstTraceFunctionExit0( CUSBOTGEVENTWATCHER_POST_EXIT );
   617 	}
   692 	}
   618 
   693 
   619 
   694 
   620 //-----------------------------------------------------------------------------
   695 //-----------------------------------------------------------------------------
   621 //----------------- OTG watcher class to monitor OTG Messages ----------------- 
   696 //----------------- OTG watcher class to monitor OTG Messages ----------------- 
   631  *
   706  *
   632  * @return	A new CUsbOtgWatcher object
   707  * @return	A new CUsbOtgWatcher object
   633  */
   708  */
   634 CUsbOtgWatcher* CUsbOtgWatcher::NewL(MUsbOtgObserver& aOwner, RUsbOtgDriver& aLdd, TUint& aOtgMessage)
   709 CUsbOtgWatcher* CUsbOtgWatcher::NewL(MUsbOtgObserver& aOwner, RUsbOtgDriver& aLdd, TUint& aOtgMessage)
   635 	{
   710 	{
   636 	LOG_STATIC_FUNC_ENTRY
   711 	OstTraceFunctionEntry0( CUSBOTGWATCHER_NEWL_ENTRY );
   637 
   712 
   638 	CUsbOtgWatcher* r = new (ELeave) CUsbOtgWatcher(aOwner, aLdd, aOtgMessage);
   713 	CUsbOtgWatcher* r = new (ELeave) CUsbOtgWatcher(aOwner, aLdd, aOtgMessage);
       
   714 	OstTraceFunctionExit0( CUSBOTGWATCHER_NEWL_EXIT );
   639 	return r;
   715 	return r;
   640 	}
   716 	}
   641 
   717 
   642 
   718 
   643 /**
   719 /**
   647  *
   723  *
   648  * @internalComponent
   724  * @internalComponent
   649  */
   725  */
   650 CUsbOtgWatcher::~CUsbOtgWatcher()
   726 CUsbOtgWatcher::~CUsbOtgWatcher()
   651 	{
   727 	{
   652 	LOG_FUNC
   728 	OstTraceFunctionEntry1( CUSBOTGWATCHER_CUSBOTGWATCHER_DES_ENTRY, this );
   653 	LOGTEXT2(_L8(">CUsbOtgWatcher::~CUsbOtgWatcher (0x%08x)"), (TUint32) this);
       
   654 	Cancel();
   729 	Cancel();
   655 	}
   730 	}
   656 
   731 
   657 
   732 
   658 /**
   733 /**
   664  * @param	aLdd	A reference to the USB Logical Device Driver
   739  * @param	aLdd	A reference to the USB Logical Device Driver
   665  */
   740  */
   666 CUsbOtgWatcher::CUsbOtgWatcher(MUsbOtgObserver& aOwner, RUsbOtgDriver& aLdd, TUint& aOtgMessage)
   741 CUsbOtgWatcher::CUsbOtgWatcher(MUsbOtgObserver& aOwner, RUsbOtgDriver& aLdd, TUint& aOtgMessage)
   667 	: CActive(CActive::EPriorityStandard), iOwner(aOwner), iLdd(aLdd), iOtgMessage(aOtgMessage)
   742 	: CActive(CActive::EPriorityStandard), iOwner(aOwner), iLdd(aLdd), iOtgMessage(aOtgMessage)
   668 	{
   743 	{
   669 	LOG_FUNC
   744 	OstTraceFunctionEntry0( CUSBOTGWATCHER_CUSBOTGWATCHER_CONS_ENTRY );
   670 	CActiveScheduler::Add(this);
   745 	CActiveScheduler::Add(this);
       
   746 	OstTraceFunctionExit0( CUSBOTGWATCHER_CUSBOTGWATCHER_CONS_EXIT );
   671 	}
   747 	}
   672 
   748 
   673 /**
   749 /**
   674  * Called when the OTG component changes its state.
   750  * Called when the OTG component changes its state.
   675  */
   751  */
   676 void CUsbOtgWatcher::RunL()
   752 void CUsbOtgWatcher::RunL()
   677 	{
   753 	{
   678 	LOG_FUNC
   754 	OstTraceFunctionEntry0( CUSBOTGWATCHER_RUNL_ENTRY );
   679 	if (iStatus.Int() != KErrNone)
   755 	if (iStatus.Int() != KErrNone)
   680 		{
   756 		{
   681 		LOGTEXT2(_L8("CUsbOtgWatcher::RunL() - Error = %d"), iStatus.Int());
   757 		OstTrace1( TRACE_NORMAL, CUSBOTGWATCHER_RUNL, "CUsbOtgWatcher::RunL;Error=%d", iStatus.Int() );
       
   758 		OstTraceFunctionExit0( CUSBOTGWATCHER_RUNL_EXIT );
   682 		return;
   759 		return;
   683 		}
   760 		}
   684 
   761 
   685 	LOGTEXT2(_L8("CUsbOtgWatcher::RunL() - Otg Message reported: %d"), iOtgMessage);
   762 	OstTrace1( TRACE_NORMAL, CUSBOTGWATCHER_RUNL_DUP1, "CUsbOtgWatcher::RunL;Otg Message reported: %d", iOtgMessage );
   686 	iOwner.NotifyMessage();
   763 	iOwner.NotifyMessage();
   687 
   764 
   688 	Post();
   765 	Post();
       
   766 	OstTraceFunctionExit0( CUSBOTGWATCHER_RUNL_EXIT_DUP1 );
   689 	}
   767 	}
   690 
   768 
   691 
   769 
   692 /**
   770 /**
   693  * Automatically called when the state watcher is cancelled.
   771  * Automatically called when the state watcher is cancelled.
   694  */
   772  */
   695 void CUsbOtgWatcher::DoCancel()
   773 void CUsbOtgWatcher::DoCancel()
   696 	{
   774 	{
   697 	LOG_FUNC
   775 	OstTraceFunctionEntry0( CUSBOTGWATCHER_DOCANCEL_ENTRY );
   698 	iLdd.CancelOtgMessageRequest();
   776 	iLdd.CancelOtgMessageRequest();
       
   777 	OstTraceFunctionExit0( CUSBOTGWATCHER_DOCANCEL_EXIT );
   699 	}
   778 	}
   700 
   779 
   701 
   780 
   702 /**
   781 /**
   703  * Instructs the state watcher to start watching.
   782  * Instructs the state watcher to start watching.
   704  */
   783  */
   705 void CUsbOtgWatcher::Start()
   784 void CUsbOtgWatcher::Start()
   706 	{
   785 	{
   707 	LOG_FUNC
   786 	OstTraceFunctionEntry0( CUSBOTGWATCHER_START_ENTRY );
   708 	Post();
   787 	Post();
       
   788 	OstTraceFunctionExit0( CUSBOTGWATCHER_START_EXIT );
   709 	}
   789 	}
   710 
   790 
   711 /**
   791 /**
   712  * Sets state watcher in active state
   792  * Sets state watcher in active state
   713  */
   793  */
   714 void CUsbOtgWatcher::Post()
   794 void CUsbOtgWatcher::Post()
   715 	{
   795 	{
   716 	LOG_FUNC
   796 	OstTraceFunctionEntry0( CUSBOTGWATCHER_POST_ENTRY );
   717 
   797 
   718 	LOGTEXT(_L8("CUsbOtgWatcher::Post() - About to call QueueOtgMessageRequest"));
   798 	OstTrace0( TRACE_NORMAL, CUSBOTGWATCHER_POST, "CUsbOtgWatcher::Post - About to call QueueOtgMessageRequest" );
   719 	iLdd.QueueOtgMessageRequest((RUsbOtgDriver::TOtgMessage&)iOtgMessage, iStatus);
   799 	iLdd.QueueOtgMessageRequest((RUsbOtgDriver::TOtgMessage&)iOtgMessage, iStatus);
   720 	SetActive();
   800 	SetActive();
       
   801 	OstTraceFunctionExit0( CUSBOTGWATCHER_POST_EXIT );
   721 	}
   802 	}
   722 
   803 
   723 
   804 
   724 
   805 
   725 
   806 
   745 void CRequestSessionWatcher::ConstructL()
   826 void CRequestSessionWatcher::ConstructL()
   746 /**
   827 /**
   747  * Performs 2nd phase construction of the OTG object.
   828  * Performs 2nd phase construction of the OTG object.
   748  */
   829  */
   749 	{
   830 	{
   750 	LOG_FUNC
   831 	OstTraceFunctionEntry0( CREQUESTSESSIONWATCHER_CONSTRUCTL_ENTRY );
   751 
   832 
   752 	TInt err = RProperty::Define(KUsbRequestSessionProperty, RProperty::EInt, KAllowAllPolicy, KRequestSessionPolicy);
   833 	TInt err = RProperty::Define(KUsbRequestSessionProperty, RProperty::EInt, KAllowAllPolicy, KRequestSessionPolicy);
   753 	if ( err != KErrNone && err != KErrAlreadyExists )
   834 	if ( err != KErrNone && err != KErrAlreadyExists )
   754 	    {
   835 	    {
   755 	    User::LeaveIfError(err);
   836 	    User::LeaveIfError(err);
   760 	    User::LeaveIfError(err);
   841 	    User::LeaveIfError(err);
   761 	    }
   842 	    }
   762 	User::LeaveIfError(iProp.Attach(KUidUsbManCategory, KUsbRequestSessionProperty));
   843 	User::LeaveIfError(iProp.Attach(KUidUsbManCategory, KUsbRequestSessionProperty));
   763 	iProp.Subscribe(iStatus);
   844 	iProp.Subscribe(iStatus);
   764 	SetActive();
   845 	SetActive();
       
   846 	OstTraceFunctionExit0( CREQUESTSESSIONWATCHER_CONSTRUCTL_EXIT );
   765 	}
   847 	}
   766 
   848 
   767 CRequestSessionWatcher::CRequestSessionWatcher(MUsbOtgObserver& aOwner)
   849 CRequestSessionWatcher::CRequestSessionWatcher(MUsbOtgObserver& aOwner)
   768 	: CActive(CActive::EPriorityStandard), iOwner(aOwner)
   850 	: CActive(CActive::EPriorityStandard), iOwner(aOwner)
   769 	{
   851 	{
   770 	LOG_FUNC
   852 	OstTraceFunctionEntry0( CREQUESTSESSIONWATCHER_CREQUESTSESSIONWATCHER_CONS_ENTRY );
   771 	CActiveScheduler::Add(this);
   853 	CActiveScheduler::Add(this);
       
   854 	OstTraceFunctionExit0( CREQUESTSESSIONWATCHER_CREQUESTSESSIONWATCHER_CONS_EXIT );
   772 	}
   855 	}
   773 
   856 
   774 /**
   857 /**
   775  * Called when the OTG Event is reported
   858  * Called when the OTG Event is reported
   776  */
   859  */
   777 void CRequestSessionWatcher::RunL()
   860 void CRequestSessionWatcher::RunL()
   778 	{
   861 	{
   779 	LOG_FUNC
   862 	OstTraceFunctionEntry0( CREQUESTSESSIONWATCHER_RUNL_ENTRY );
   780 	LOGTEXT2(_L8(">>CRequestSessionWatcher::RunL [iStatus=%d]"), iStatus.Int());
   863 	OstTrace1( TRACE_NORMAL, CREQUESTSESSIONWATCHER_RUNL, "CRequestSessionWatcher::RunL;iStatus=%d", iStatus.Int() );
   781 	RDebug::Printf(">>CRequestSessionWatcher::RunL [iStatus=%d]", iStatus.Int());
   864 	RDebug::Printf(">>CRequestSessionWatcher::RunL [iStatus=%d]", iStatus.Int());
   782 	
   865 	
   783 	iProp.Subscribe(iStatus);
   866 	iProp.Subscribe(iStatus);
   784 	SetActive();
   867 	SetActive();
   785 
   868 
   787 	User::LeaveIfError(iProp.Get(val));
   870 	User::LeaveIfError(iProp.Get(val));
   788 	RDebug::Printf(">>value=%d", val);
   871 	RDebug::Printf(">>value=%d", val);
   789 
   872 
   790 	iOwner.NotifyMessage(KUsbMessageRequestSession);
   873 	iOwner.NotifyMessage(KUsbMessageRequestSession);
   791 	
   874 	
   792 	LOGTEXT(_L8("<<CRequestSessionWatcher::RunL"));
   875 	OstTraceFunctionExit0( CREQUESTSESSIONWATCHER_RUNL_EXIT );
   793 	}
   876 	}
   794 
   877 
   795 
   878 
   796 /**
   879 /**
   797  * Automatically called when the OTG Event watcher is cancelled.
   880  * Automatically called when the OTG Event watcher is cancelled.
   798  */
   881  */
   799 void CRequestSessionWatcher::DoCancel()
   882 void CRequestSessionWatcher::DoCancel()
   800 	{
   883 	{
   801 	LOG_FUNC
   884 	OstTraceFunctionEntry0( CREQUESTSESSIONWATCHER_DOCANCEL_ENTRY );
   802 	iProp.Cancel();
   885 	iProp.Cancel();
       
   886 	OstTraceFunctionExit0( CREQUESTSESSIONWATCHER_DOCANCEL_EXIT );
   803 	}
   887 	}
   804 
   888 
   805 //---------------------------- Connection Idle watcher class --------------------------- 
   889 //---------------------------- Connection Idle watcher class --------------------------- 
   806 /**
   890 /**
   807  * The CUsbOtgConnectionIdleWatcher::NewL method
   891  * The CUsbOtgConnectionIdleWatcher::NewL method
   813  *
   897  *
   814  * @return	A new CUsbOtgWatcher object
   898  * @return	A new CUsbOtgWatcher object
   815  */
   899  */
   816 CUsbOtgConnectionIdleWatcher* CUsbOtgConnectionIdleWatcher::NewL(RUsbOtgDriver& aLdd)
   900 CUsbOtgConnectionIdleWatcher* CUsbOtgConnectionIdleWatcher::NewL(RUsbOtgDriver& aLdd)
   817 	{
   901 	{
   818 	LOG_STATIC_FUNC_ENTRY
   902 	OstTraceFunctionEntry0( CUSBOTGCONNECTIONIDLEWATCHER_NEWL_ENTRY );
   819 
   903 
   820 	CUsbOtgConnectionIdleWatcher* self = new (ELeave) CUsbOtgConnectionIdleWatcher(aLdd);
   904 	CUsbOtgConnectionIdleWatcher* self = new (ELeave) CUsbOtgConnectionIdleWatcher(aLdd);
   821 	CleanupStack::PushL(self);
   905 	CleanupStack::PushL(self);
   822 	self->ConstructL();
   906 	self->ConstructL();
   823 	CleanupStack::Pop(self);
   907 	CleanupStack::Pop(self);
       
   908 	OstTraceFunctionExit0( CUSBOTGCONNECTIONIDLEWATCHER_NEWL_EXIT );
   824 	return self;
   909 	return self;
   825 	}
   910 	}
   826 
   911 
   827 
   912 
   828 /**
   913 /**
   832  *
   917  *
   833  * @internalComponent
   918  * @internalComponent
   834  */
   919  */
   835 CUsbOtgConnectionIdleWatcher::~CUsbOtgConnectionIdleWatcher()
   920 CUsbOtgConnectionIdleWatcher::~CUsbOtgConnectionIdleWatcher()
   836 	{
   921 	{
   837 	LOG_FUNC
   922 	OstTraceFunctionEntry0( CUSBOTGCONNECTIONIDLEWATCHER_CUSBOTGCONNECTIONIDLEWATCHER_DES_ENTRY );
   838 	Cancel();
   923 	Cancel();
   839 	RProperty::Delete(KUsbOtgConnectionIdleProperty);
   924 	RProperty::Delete(KUsbOtgConnectionIdleProperty);
       
   925 	OstTraceFunctionExit0( CUSBOTGCONNECTIONIDLEWATCHER_CUSBOTGCONNECTIONIDLEWATCHER_DES_EXIT );
   840 	}
   926 	}
   841 
   927 
   842 /**
   928 /**
   843  * Performs 2nd phase construction of the OTG object.
   929  * Performs 2nd phase construction of the OTG object.
   844  */
   930  */
   845 void CUsbOtgConnectionIdleWatcher::ConstructL()
   931 void CUsbOtgConnectionIdleWatcher::ConstructL()
   846 	{
   932 	{
   847 	LOG_FUNC
   933 	OstTraceFunctionEntry0( CUSBOTGCONNECTIONIDLEWATCHER_CONSTRUCTL_ENTRY );
   848 
   934 
   849 	TInt err = RProperty::Define(KUsbOtgConnectionIdleProperty, RProperty::EInt, KAllowAllPolicy, KNetworkControlPolicy);
   935 	TInt err = RProperty::Define(KUsbOtgConnectionIdleProperty, RProperty::EInt, KAllowAllPolicy, KNetworkControlPolicy);
   850 	if ( err != KErrNone && err != KErrAlreadyExists )
   936 	if ( err != KErrNone && err != KErrAlreadyExists )
   851 	    {
   937 	    {
   852 	    User::LeaveIfError(err);
   938 	    User::LeaveIfError(err);
   854 	err = RProperty::Set(KUidUsbManCategory,KUsbOtgConnectionIdleProperty,ETrue);
   940 	err = RProperty::Set(KUidUsbManCategory,KUsbOtgConnectionIdleProperty,ETrue);
   855 	if ( err != KErrNone )
   941 	if ( err != KErrNone )
   856 	    {
   942 	    {
   857 	    User::LeaveIfError(err);
   943 	    User::LeaveIfError(err);
   858 	    }
   944 	    }
       
   945 	OstTraceFunctionExit0( CUSBOTGCONNECTIONIDLEWATCHER_CONSTRUCTL_EXIT );
   859 	}
   946 	}
   860 
   947 
   861 /**
   948 /**
   862  * The CUsbOtgConnectionIdleWatcher::CUsbOtgConnectionIdleWatcher method
   949  * The CUsbOtgConnectionIdleWatcher::CUsbOtgConnectionIdleWatcher method
   863  *
   950  *
   867  */
   954  */
   868 
   955 
   869 CUsbOtgConnectionIdleWatcher::CUsbOtgConnectionIdleWatcher(RUsbOtgDriver& aLdd)
   956 CUsbOtgConnectionIdleWatcher::CUsbOtgConnectionIdleWatcher(RUsbOtgDriver& aLdd)
   870 	: CUsbOtgBaseWatcher(aLdd)
   957 	: CUsbOtgBaseWatcher(aLdd)
   871 	{
   958 	{
   872 	LOG_FUNC
   959 	OstTraceFunctionEntry0( CUSBOTGCONNECTIONIDLEWATCHER_CUSBOTGCONNECTIONIDLEWATCHER_CONS_ENTRY );
       
   960 	OstTraceFunctionExit0( CUSBOTGCONNECTIONIDLEWATCHER_CUSBOTGCONNECTIONIDLEWATCHER_CONS_EXIT );
   873 	}
   961 	}
   874 
   962 
   875 /**
   963 /**
   876  * Called when the Connection Idle status change is reported
   964  * Called when the Connection Idle status change is reported
   877  */
   965  */
   878 void CUsbOtgConnectionIdleWatcher::RunL()
   966 void CUsbOtgConnectionIdleWatcher::RunL()
   879 	{
   967 	{
   880 	LOG_FUNC
   968 	OstTraceFunctionEntry0( CUSBOTGCONNECTIONIDLEWATCHER_RUNL_ENTRY );
   881 	LOGTEXT2(_L8(">>CUsbOtgConnectionIdleWatcher::RunL [iStatus=%d]"), iStatus.Int());
   969 	OstTrace1( TRACE_NORMAL, CUSBOTGCONNECTIONIDLEWATCHER_RUNL, 
   882 
   970 	        "CUsbOtgConnectionIdleWatcher::RunL;iStatus=%d", iStatus.Int() );
   883 	LEAVEIFERRORL(iStatus.Int());
       
   884 	
   971 	
       
   972     TInt err = iStatus.Int();
       
   973     if(err < 0)
       
   974         {
       
   975         OstTrace1( TRACE_NORMAL, CUSBOTGCONNECTIONIDLEWATCHER_RUNL_DUP1, "CUsbOtgConnectionIdleWatcher::RunL;iStatus.Int() with error=%d", err );
       
   976         User::Leave(err);
       
   977         }
       
   978     
   885 	Post();
   979 	Post();
   886 
   980 
   887 	LOGTEXT(_L8("<<CUsbOtgConnectionIdleWatcher::RunL"));
   981 	OstTraceFunctionExit0( CUSBOTGCONNECTIONIDLEWATCHER_RUNL_EXIT );
   888 	}
   982 	}
   889 
   983 
   890 
   984 
   891 /**
   985 /**
   892  * Automatically called when the Connection Idle watcher is cancelled.
   986  * Automatically called when the Connection Idle watcher is cancelled.
   893  */
   987  */
   894 void CUsbOtgConnectionIdleWatcher::DoCancel()
   988 void CUsbOtgConnectionIdleWatcher::DoCancel()
   895 	{
   989 	{
   896 	LOG_FUNC
   990 	OstTraceFunctionEntry0( CUSBOTGCONNECTIONIDLEWATCHER_DOCANCEL_ENTRY );
   897 	iLdd.CancelOtgConnectionNotification();
   991 	iLdd.CancelOtgConnectionNotification();
       
   992 	OstTraceFunctionExit0( CUSBOTGCONNECTIONIDLEWATCHER_DOCANCEL_EXIT );
   898 	}
   993 	}
   899 
   994 
   900 /**
   995 /**
   901  * Sets state watcher in active state
   996  * Sets state watcher in active state
   902  */
   997  */
   903 void CUsbOtgConnectionIdleWatcher::Post()
   998 void CUsbOtgConnectionIdleWatcher::Post()
   904 	{
   999 	{
   905 	LOG_FUNC
  1000 	OstTraceFunctionEntry0( CUSBOTGCONNECTIONIDLEWATCHER_POST_ENTRY );
   906 
  1001 
   907 	LOGTEXT(_L8("CUsbOtgConnectionIdleWatcher::Post() - About to call QueueOtgIdPinNotification"));
  1002 	OstTrace0( TRACE_NORMAL, CUSBOTGCONNECTIONIDLEWATCHER_POST, 
       
  1003 	        "CUsbOtgConnectionIdleWatcher::Post - About to call QueueOtgIdPinNotification" );
   908 	iLdd.QueueOtgConnectionNotification(iConnectionIdle, iStatus);
  1004 	iLdd.QueueOtgConnectionNotification(iConnectionIdle, iStatus);
   909 	switch (iConnectionIdle)
  1005 	switch (iConnectionIdle)
   910 		{
  1006 		{
   911 		case RUsbOtgDriver::EConnectionIdle:
  1007 		case RUsbOtgDriver::EConnectionIdle:
   912 		case RUsbOtgDriver::EConnectionUnknown:
  1008 		case RUsbOtgDriver::EConnectionUnknown:
   913 			RProperty::Set(KUidUsbManCategory,KUsbOtgConnectionIdleProperty,ETrue);
  1009 			RProperty::Set(KUidUsbManCategory,KUsbOtgConnectionIdleProperty,ETrue);
   914 			LOGTEXT2(_L8(">>CUsbOtgConnectionIdleWatcher::Post [iConnectionIdle=%d] - property is set to 1"), iConnectionIdle);
  1010 			OstTrace1( TRACE_NORMAL, CUSBOTGCONNECTIONIDLEWATCHER_POST_DUP1, 
       
  1011 			        "CUsbOtgConnectionIdleWatcher::Post;[iConnectionIdle=%d] - property is set to 1", iConnectionIdle );
   915 			break;
  1012 			break;
   916 		case RUsbOtgDriver::EConnectionBusy:
  1013 		case RUsbOtgDriver::EConnectionBusy:
   917 			RProperty::Set(KUidUsbManCategory,KUsbOtgConnectionIdleProperty,EFalse);
  1014 			RProperty::Set(KUidUsbManCategory,KUsbOtgConnectionIdleProperty,EFalse);
   918 			LOGTEXT2(_L8(">>CUsbOtgConnectionIdleWatcher::Post [iConnectionIdle=%d] - property is set to 0"), iConnectionIdle);
  1015 			OstTrace1( TRACE_NORMAL, CUSBOTGCONNECTIONIDLEWATCHER_POST_DUP2, 
       
  1016 			        "CUsbOtgConnectionIdleWatcher::Post;[iConnectionIdle=%d] - property is set to 0", iConnectionIdle );
   919 			break;
  1017 			break;
   920 		default:
  1018 		default:
   921 			LOGTEXT2(_L8(">>CUsbOtgConnectionIdleWatcher::Post [iConnectionIdle=%d] is unrecognized, re-request QueueOtgIdPinNotification"), iConnectionIdle);
  1019 			OstTrace1( TRACE_NORMAL, CUSBOTGCONNECTIONIDLEWATCHER_POST_DUP3, 
       
  1020 			        "CUsbOtgConnectionIdleWatcher::Post;[iConnectionIdle=%d] is unrecognized, re-request QueueOtgIdPinNotification", iConnectionIdle );
   922 			break;
  1021 			break;
   923 		}
  1022 		}
   924 	SetActive();
  1023 	SetActive();
   925 	}
  1024 	OstTraceFunctionExit0( CUSBOTGCONNECTIONIDLEWATCHER_POST_EXIT );
   926 
  1025 	}
   927 
  1026 
       
  1027