userlibandfileserver/fileserver/shostmassstorage/server/src/cusbhostmssession.cpp
branchRCL_3
changeset 268 345b1ca54e88
parent 248 0ffb4e86fcc9
child 294 039a3e647356
equal deleted inserted replaced
263:9e2d4f7f5028 268:345b1ca54e88
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
   112 			{
   112 			{
   113 			aMessage.Complete(r);
   113 			aMessage.Complete(r);
   114 			return;
   114 			return;
   115 			}
   115 			}
   116 		break;
   116 		break;
   117 	case EUsbHostMsUnRegisterInterface:
   117     case EUsbHostMsUnRegisterInterface:
   118 		iCleanupInProgress = ETrue;
   118         if(iCleanupInProgress)
       
   119             {
       
   120             aMessage.Complete(KErrInUse);
       
   121             return;
       
   122             }
       
   123         else
       
   124             {
       
   125             iCleanupInProgress = ETrue;
       
   126             }
   119 		break;
   127 		break;
   120 	/* If it is a cleanup then we need to delete the iDeviceThread */
   128 	/* If it is a cleanup then we need to delete the iDeviceThread */
   121 	case EUsbHostMsFinalCleanup:	
   129 	case EUsbHostMsFinalCleanup:	
   122 		delete iDeviceThread;
   130 		delete iDeviceThread;
   123 		iDeviceThread = NULL;
   131 		iDeviceThread = NULL;
   126 		return;
   134 		return;
   127 	default:
   135 	default:
   128 		break;
   136 		break;
   129 		}
   137 		}
   130 
   138 
   131 	if (iDeviceThread == NULL || iCleanupInProgress ) 
   139 	if (iDeviceThread == NULL) 
   132 		{
   140 		{
   133 		aMessage.Complete(KErrBadHandle);
   141 		aMessage.Complete(KErrBadHandle);
   134 		return;
   142 		return;
   135 		}
   143 		}
   136 
   144 
       
   145     if (iCleanupInProgress && aMessage.Function() != EUsbHostMsUnRegisterInterface) 
       
   146         {
       
   147         aMessage.Complete(KErrBadHandle);
       
   148         return;
       
   149         }
   137 
   150 
   138 	r = iDeviceThread->QueueMsg(aMessage);
   151 	r = iDeviceThread->QueueMsg(aMessage);
   139 	if (r != KErrNone)
   152 	if (r != KErrNone)
   140 		{
   153 		{
   141 		aMessage.Complete(r);
   154 		aMessage.Complete(r);