usbmgmt/usbmgr/usbman/server/SRC/CUsbSession.cpp
branchRCL_3
changeset 60 25c602fd1f26
parent 43 012cc2ee6408
equal deleted inserted replaced
52:3d9964be03bc 60:25c602fd1f26
     1 /*
     1 /*
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    76 	: iUsbServer(aServer)
    76 	: iUsbServer(aServer)
    77 	{
    77 	{
    78 	LOG_FUNC
    78 	LOG_FUNC
    79 
    79 
    80 	iUsbServer->IncrementSessionCount();
    80 	iUsbServer->IncrementSessionCount();
       
    81 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV
       
    82 	iThernalLevelMsgPending = EFalse;
       
    83 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV
    81 	}
    84 	}
    82 
    85 
    83 
    86 
    84 /**
    87 /**
    85  * Destructor.
    88  * Destructor.
   411 
   414 
   412  		// UsbDeviceDequeueEvent() will read from queue when RegisterObserver()
   415  		// UsbDeviceDequeueEvent() will read from queue when RegisterObserver()
   413 		// is next called.
   416 		// is next called.
   414 		}
   417 		}
   415 	}
   418 	}
   416 
   419 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV
       
   420 void CUsbSession::UsbThermalStateChange(TInt /*aLastError*/, TInt aNewValue)
       
   421 #else
       
   422 void CUsbSession::UsbThermalStateChange(TInt /*aLastError*/, TInt /*aNewValue*/)
       
   423 #endif
       
   424 	{
       
   425 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV	
       
   426 	LOG_FUNC
       
   427 	
       
   428 	// Update local copy with the latest value from P&S key
       
   429 	iUsbThermalLevel = aNewValue;
       
   430 	
       
   431 	// Forward it to upper layer if there is a client pending there
       
   432  	if (iMsgObserverOutstanding)
       
   433 		{
       
   434 		ForwardThermalMessage();
       
   435 		}
       
   436 	else
       
   437 		{
       
   438 		iThernalLevelMsgPending = ETrue;
       
   439 		}
       
   440 #endif //SYMBIAN_ENABLE_USB_OTG_HOST_PRIV 		
       
   441 	}
       
   442 	
   417 /**
   443 /**
   418  * Dequeues an event and completes the observer's request with it.
   444  * Dequeues an event and completes the observer's request with it.
   419  */
   445  */
   420 void CUsbSession::UsbDeviceDequeueEvent()
   446 void CUsbSession::UsbDeviceDequeueEvent()
   421  	{
   447  	{
   448  			break;
   474  			break;
   449    			}
   475    			}
   450    		}
   476    		}
   451    	}
   477    	}
   452 
   478 
       
   479 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV	
       
   480 
       
   481 void CUsbSession::ForwardThermalMessage()
       
   482 	{
       
   483 	LOG_FUNC
       
   484 		
       
   485 	TPckg<TUint32> pckg(iUsbThermalLevel);
       
   486 	
       
   487 	// Mark no pending since we're going to complete client request.
       
   488 	iMsgObserverOutstanding = EFalse;
       
   489 	
       
   490 	// Mark no new thermal message need to be forward
       
   491 	iThernalLevelMsgPending = EFalse;
       
   492 	
       
   493 	const TInt err = iMsgObserverMessage.Write(0, pckg);
       
   494 	iMsgObserverMessage.Complete(err);
       
   495 	}
       
   496 #endif //SYMBIAN_ENABLE_USB_OTG_HOST_PRIV 
       
   497 	
   453 /**
   498 /**
   454  * Handles the request (in the form of a the message) received from the client
   499  * Handles the request (in the form of a the message) received from the client
   455  *
   500  *
   456  * @internalComponent
   501  * @internalComponent
   457  * @param	aMessage	The received message
   502  * @param	aMessage	The received message
   881  		// This is the first observer after c'tor or DeregisterObserver(),
   926  		// This is the first observer after c'tor or DeregisterObserver(),
   882  		// so zap the device event queue.
   927  		// so zap the device event queue.
   883  		LOGTEXT(_L8("    Reset Device Event Queue"));
   928  		LOGTEXT(_L8("    Reset Device Event Queue"));
   884  		iDevStateQueueHead = 0;
   929  		iDevStateQueueHead = 0;
   885  		iDevStateQueueTail = 0;
   930  		iDevStateQueueTail = 0;
   886  		iObserverQueueEvents = ETrue;
   931 		iObserverQueueEvents = ETrue;
   887 	 	}
   932 	 	}
   888  	else if (iDevStateQueueHead != iDevStateQueueTail)
   933  	else if (iDevStateQueueHead != iDevStateQueueTail)
   889 	 	{
   934 	 	{
   890  		// event(s) queued, we can de-queue one now
   935  		// event(s) queued, we can de-queue one now
   891  		UsbDeviceDequeueEvent();
   936  		UsbDeviceDequeueEvent();
   892 	 	}
   937 	 	}
   893 
   938 		
   894 	return KErrNone;
   939 	return KErrNone;
   895 	}
   940 	}
   896 
   941 
   897 /**
   942 /**
   898  * Client request to observe the service (for state changes)
   943  * Client request to observe the service (for state changes)
   913 		return KErrInUse;
   958 		return KErrInUse;
   914 		}
   959 		}
   915 
   960 
   916 	iServiceObserverMessage = aMessage;
   961 	iServiceObserverMessage = aMessage;
   917 	iServiceObserverOutstanding = ETrue;
   962 	iServiceObserverOutstanding = ETrue;
       
   963 	
   918 	aComplete = EFalse;
   964 	aComplete = EFalse;
       
   965 		
   919 	return KErrNone;
   966 	return KErrNone;
   920 	}
   967 	}
   921 
   968 
   922 
   969 
   923 /**
   970 /**
  1922  	else if (iMsgQueueHead != iMsgQueueTail)
  1969  	else if (iMsgQueueHead != iMsgQueueTail)
  1923 	 	{
  1970 	 	{
  1924  		// event(s) queued, we can de-queue one now
  1971  		// event(s) queued, we can de-queue one now
  1925  		UsbMsgDequeue();
  1972  		UsbMsgDequeue();
  1926 	 	}
  1973 	 	}
  1927 
  1974 		
       
  1975 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV
       
  1976 	if (iThernalLevelMsgPending)
       
  1977 		{
       
  1978 		ForwardThermalMessage();
       
  1979 		aComplete = ETrue;
       
  1980 		}
       
  1981 #endif
       
  1982 		
  1928 	return KErrNone;
  1983 	return KErrNone;
  1929 	}
  1984 	}
  1930 
  1985 
  1931 /**
  1986 /**
  1932  * Deregister the client as an observer of OTG/HOST events and errors.
  1987  * Deregister the client as an observer of OTG/HOST events and errors.