mmappcomponents/harvester/server/src/mpxconnectioneventhandler.cpp
branchRCL_3
changeset 42 4aca42fa4eb1
parent 34 e257e2b6459d
--- a/mmappcomponents/harvester/server/src/mpxconnectioneventhandler.cpp	Wed Jun 09 10:13:45 2010 +0300
+++ b/mmappcomponents/harvester/server/src/mpxconnectioneventhandler.cpp	Mon Jun 21 16:13:35 2010 +0300
@@ -26,7 +26,7 @@
 #include <coreapplicationuisdomainpskeys.h>
 #include <UsbWatcherInternalPSKeys.h>
 #include <usbpersonalityids.h>
-#include <MtpPrivatePSKeys.h>
+#include <mtpprivatepskeys.h>
 #include <mpxlog.h>
 #include "mpxconnectioneventhandler.h"
 
@@ -161,7 +161,7 @@
     iUSBKeyWatcher->GetValue( usbStatus );
     
     TInt mtpStatus;
-    iMTPKeyWatcher->GetValue(mtpStatus);
+    TInt err = iMTPKeyWatcher->GetValue(mtpStatus);
     
     MPX_DEBUG3("CMPXConnectionEventHandler::DoHandlePSEventL, usbStatus = %d, mtpStatus = %d", usbStatus, mtpStatus);
     MPX_DEBUG2("CMPXConnectionEventHandler::DoHandlePSEventL, iState = %d", iState);
@@ -196,20 +196,29 @@
     // after MassStorage End, it is possible that MTP is still connected
     if (iState != EMPXConnectionMassStorage)
         {
-        if ((mtpStatus == EMtpPSStatusUninitialized) && (iState != EMPXConnectionNone))
-            {
-            MPX_DEBUG1("CMPXConnectionEventHandler::DoHandlePSEvent - MTP End");
-            iObserver.HandleSystemEventL( EUSBMTPEndEvent, -1 );
-            iState = EMPXConnectionNone;
+		if (err == KErrNone)
+		    {
+            if ((mtpStatus == EMtpPSStatusUninitialized) && (iState != EMPXConnectionNone))
+                {
+                MPX_DEBUG1("CMPXConnectionEventHandler::DoHandlePSEvent - MTP End");
+                iObserver.HandleSystemEventL( EUSBMTPEndEvent, -1 );
+                iState = EMPXConnectionNone;
+                }
+            else if ((mtpStatus == EMtpPSStatusActive) && (iState != EMPXConnectionMTPActive)
+                    && ((usbStatus == KUsbPersonalityIdMTP) || (usbStatus == KUsbPersonalityIdPCSuiteMTP))) // only trigger MusicPlayer fully block and RAM Drive if USB MTP/PCSuiteMTP is connected
+                {
+                DoMTPStartEventL();
+                }
+            else if ((mtpStatus == EMtpPSStatusReadyToSync) && (iState != EMPXConnectionMTPIdle) && (iState != EMPXConnectionMTPActive))
+                {
+                DoMTPNotActiveEventL();
+                }
             }
-        else if ((mtpStatus == EMtpPSStatusActive) && (iState != EMPXConnectionMTPActive)
-                && ((usbStatus == KUsbPersonalityIdMTP) || (usbStatus == KUsbPersonalityIdPCSuiteMTP))) // only trigger MusicPlayer fully block and RAM Drive if USB MTP/PCSuiteMTP is connected
+        else
             {
-            DoMTPStartEventL();
-            }
-        else if ((mtpStatus == EMtpPSStatusReadyToSync) && (iState != EMPXConnectionMTPIdle) && (iState != EMPXConnectionMTPActive))
-            {
-            DoMTPNotActiveEventL();
+            // mtpwatcher can err out because the mtp ps key would only be defined and default after first use,
+            // and this logic here might hit before that
+            MPX_DEBUG2("CMPXConnectionEventHandler::DoHandlePSEvent - MTPWatcher err = %d", err);
             }
         }
     }