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