Revision: 201013 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 14 Apr 2010 17:02:32 +0300
branchRCL_3
changeset 24 1a297fa72b1e
parent 23 bb32eca979b3
child 27 f6533aee8b2b
Revision: 201013 Kit: 201015
usbengines/usbdevcon/inc/cusbdevcon.h
usbengines/usbdevcon/src/cusbdevcon.cpp
usbuis/usbui/USBClassChangeUIPlugin/src/USBClassChangeUIPluginContainer.cpp
--- a/usbengines/usbdevcon/inc/cusbdevcon.h	Wed Mar 31 23:11:08 2010 +0300
+++ b/usbengines/usbdevcon/inc/cusbdevcon.h	Wed Apr 14 17:02:32 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2007 - 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -109,13 +109,6 @@
      */
     void StopL();
     
-    /**
-     * Take needed actions on resuming services
-     *
-     * @since S60 v.5.0
-     */
-    void ResumeL();
-    
     // from CActive
     
     /**
--- a/usbengines/usbdevcon/src/cusbdevcon.cpp	Wed Mar 31 23:11:08 2010 +0300
+++ b/usbengines/usbdevcon/src/cusbdevcon.cpp	Wed Apr 14 17:02:32 2010 +0300
@@ -116,39 +116,39 @@
 //
 CUsbDevCon::~CUsbDevCon()
     {
-        FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon" ) );
-        
-        Cancel();
-        
-        FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon Cancel" ) );
-        
-        delete iStateMachine;
-        
-        FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon StateMachine" ) );
-        
-        delete iRequestsHandler;
-        
-        FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon RequestsHandler" ) );
-        
-        delete iUsbStateWatcher;
-        
-        FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon UsbStateWatcher" ) );
-        
-        iUsbWatcher.Close();
-        
-        FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon UsbWatcher" ) );
-        
-        iUsbManager.Close();
-        
-        FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon UsbManager" ) );
-        
-        iLdd.Close();
-        
-        FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon LDD" ) );
-        
-        iShutdownTimer.Close();
-        
-        FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon Timer" ) );
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon" ) );
+    
+    Cancel();
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon Cancel" ) );
+    
+    delete iStateMachine;
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon StateMachine" ) );
+    
+    delete iRequestsHandler;
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon RequestsHandler" ) );
+    
+    delete iUsbStateWatcher;
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon UsbStateWatcher" ) );
+    
+    iUsbWatcher.Close();
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon UsbWatcher" ) );
+    
+    iUsbManager.Close();
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon UsbManager" ) );
+    
+    iLdd.Close();
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon LDD" ) );
+    
+    iShutdownTimer.Close();
+    
+    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::~CUsbDevCon Timer" ) );
     
     }   
 
@@ -165,32 +165,46 @@
             {
             
             FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Undefined" ) );
-                    
+
             StopL();
             break;
             }
                 
         case EUsbcDeviceStateAttached:
             {
-            
-            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Attached" ) );     
+            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Attached, ignored" ) );
 
             break;
             }
                 
+        case EUsbcDeviceStateSuspended:
+            {
+            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Suspended" ) );
+            // NO break here
+            }
         case EUsbcDeviceStatePowered:
             {
-            
-            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Powered" ) );      
+            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Powered" ) );
 
-            StartL();
+            // In powered or suspended state, we are not allowed to do any data 
+            // communication. Hence if there are pending read/write requests,
+            // we need cancel them. 
+            // Not call StopL() here because we do not want to shut down this
+            // process so earlier but in Undefined state.
+            if ( iStateMachine->IsStarted() )
+                {
+                iStateMachine->Stop();
+                // release device control
+                User::LeaveIfError(iLdd.ReleaseDeviceControl());
+                }
             break;
             }
                 
         case EUsbcDeviceStateDefault:
             {
-                
-            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Default" ) );      
+            // The request will only be started from default state.
+            // If it has been started already, nothing will be done.
+            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Default" ) );
 
             StartL();
             break;
@@ -198,8 +212,7 @@
                 
         case EUsbcDeviceStateAddress:
             {
-                
-            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Addressed" ) );        
+            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Addressed" ) );
 
             StartL();
             break;
@@ -207,32 +220,16 @@
                 
         case EUsbcDeviceStateConfigured:
             {
-                
-            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Configured" ) );       
+            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Configured" ) );
 
-            if(iPrevUsbState == EUsbcDeviceStateSuspended)
-                {
-                ResumeL();
-                }
-                else
-                {
-                StartL();
-                }
+            StartL();
                 
             break;
             }
-        case EUsbcDeviceStateSuspended:
-            {
-                
-            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: Suspended" ) );        
-
-            break;
-            }
-                
         default:
             {
                 
-            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: ***Undefined***" ) );      
+            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ActAccordinglyToUsbStateL State: ***Unknown***" ) );
 
             StopL();
             break;
@@ -302,9 +299,9 @@
         
         }
         
-        // Cancel shutdown timer, if it is started
-        iShutdownTimer.Cancel();
-     }
+    // Cancel shutdown timer, if it is started
+    iShutdownTimer.Cancel();
+    }
     
 // ---------------------------------------------------------------------------
 // Stops UsbDevCon services
@@ -324,34 +321,21 @@
         // release device control
         User::LeaveIfError(iLdd.ReleaseDeviceControl());
         
-         }
+        }
          
-         if(!IsActive()) // not waiting for timer
-            {
-            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::StopL Starting timer" ) );
-            // run timer
-            iShutdownTimer.Cancel();
+    if(!IsActive()) // not waiting for timer
+        {
+        FLOG( _L( "[USBDEVCON]\tCUsbDevCon::StopL Starting timer" ) );
+        // run timer
+        iShutdownTimer.Cancel();
 
-            // RunL will be called after KInactiveTimeForShutDown milliseconds
-            iShutdownTimer.After(iStatus, TTimeIntervalMicroSeconds32(KInactiveTimeForShutDown)); 
-            SetActive();
-            FLOG( _L( "[USBDEVCON]\tCUsbDevCon::StopL Timer is started" ) );
-            }
+        // RunL will be called after KInactiveTimeForShutDown milliseconds
+        iShutdownTimer.After(iStatus, TTimeIntervalMicroSeconds32(KInactiveTimeForShutDown)); 
+        SetActive();
+        FLOG( _L( "[USBDEVCON]\tCUsbDevCon::StopL Timer is started" ) );
+        }
     }
     
-// ---------------------------------------------------------------------------
-// Resumes UsbDevCon services 
-// ---------------------------------------------------------------------------
-//
-void CUsbDevCon::ResumeL()
-    {
-    
-    FLOG( _L( "[USBDEVCON]\tCUsbDevCon::ResumeL" ) );
-    
-    // Resume state machine
-    StartL();
-    
-    }
 
 // ----------------------------------------------------------------------------
 // Constructs and installs the active scheduler, constructs UsbDevCon object.
@@ -412,6 +396,3 @@
 
     return err;
     }
-
-
-
--- a/usbuis/usbui/USBClassChangeUIPlugin/src/USBClassChangeUIPluginContainer.cpp	Wed Mar 31 23:11:08 2010 +0300
+++ b/usbuis/usbui/USBClassChangeUIPlugin/src/USBClassChangeUIPluginContainer.cpp	Wed Apr 14 17:02:32 2010 +0300
@@ -310,16 +310,17 @@
                    iViewRef->HandleCommandL( EUSBUICmdSelect );
                    break;
                    }
+               case EEventPenDownOnItem:
+            	   {
+            	   ShowPopUpsL (CurrentItemIndex());
+            	   break;
+            	   }
                case EEventPanningStarted:
                case EEventPanningStopped:
                case EEventFlickStarted:
                case EEventFlickStopped:
-               case EEventPenDownOnItem:
-               case EEventItemDraggingActioned:   
-                   {
-                   ShowPopUpsL (CurrentItemIndex()) ;
-                   break;
-                   }
+               case EEventItemDraggingActioned:
+            	   break;
               default:
                      break;
                      }