usbuis/usbuinotif/src/usbuinotifmsmmerror.cpp
changeset 56 f45583a69686
parent 38 218231f2b3b3
child 63 ef2686f7597e
--- a/usbuis/usbuinotif/src/usbuinotifmsmmerror.cpp	Fri Jun 11 14:38:00 2010 +0300
+++ b/usbuis/usbuinotif/src/usbuinotifmsmmerror.cpp	Wed Jun 23 19:20:39 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007, 2009 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"
@@ -18,6 +18,7 @@
 
 // INCLUDE FILES
 #include <hb/hbwidgets/hbdevicemessageboxsymbian.h>      // dialog
+#include <hb/hbwidgets/hbdevicenotificationdialogsymbian.h> //discreet
 #include <hb/hbcore/hbtextresolversymbian.h>
 #include <usb/hostms/srverr.h>
 #include <usbuinotif.h>                     // pck
@@ -27,8 +28,8 @@
 
 // CONSTANTS
 /** granularity for allocating error strings */
-const TInt KUsbMsmmErrorGranularity = 3; 
-
+const TInt KUsbMsmmErrorGranularity = 5; 
+_LIT(KUSBUIconFileName, "qtg_large_usb");
 // ================= MEMBER FUNCTIONS =========================================
 
 // ----------------------------------------------------------------------------
@@ -76,10 +77,14 @@
     _LIT(KGeneralError,"txt_usb_info_error_in_usb_connection_disconnect_d");
     _LIT(KUnknownFileSys, "txt_usb_info_unknown_file_system_disconnect_devic");
     _LIT(KOutOfMemory, "txt_usb_info_disk_full_remove_some_files_and_try");
+    _LIT(KSafeToRemove, "txt_usb_dpinfo_safe_to_remove");
+    _LIT(KUnableToEject,"txt_usb_info_unable_to_eject_the_usb_device_some" );
     
     iStringIds->AppendL(KGeneralError);
     iStringIds->AppendL(KUnknownFileSys);
     iStringIds->AppendL(KOutOfMemory);
+    iStringIds->AppendL(KSafeToRemove);
+    iStringIds->AppendL(KUnableToEject);
     }
 
 // ----------------------------------------------------------------------------
@@ -114,7 +119,7 @@
     iMessage = aMessage;
     iNeedToCompleteMessage = ETrue;
     iReplySlot = aReplySlot;
-
+    _LIT(KUsbDisconnected, "txt_usb_dpophead_usb_disconnected");
     // Get parameters 
     //    
     THostMsErrData error;
@@ -128,30 +133,61 @@
             break;        
         case  EHostMsErrOutOfMemory:
             errorId = EUsbMSMMOutOfMemory;
-            break;        
+            break;       
+        case EHostMsErrNone:
+            errorId = EUsbMSMMSafeToRemove;
+            break;
+        case EHostMsErrInUse:
+            errorId = EUsbMSMMUnableToEject;
+            break;
         default:
             errorId = EUsbMSMMGeneralError;
         }
-    
-    //Delete the query in case the client didn't cancel the notifier 
-    //or close the session after the previous query.
-    if (iQuery)
+    HBufC* stringHolder = HbTextResolverSymbian::LoadLC(iStringIds->MdcaPoint(errorId)); 
+   
+   
+    if ( errorId == EUsbMSMMSafeToRemove)
         {
-        FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::GetParamsL() deleting previous dialog"));
-        delete iQuery;
-        iQuery = NULL;
+        // "safe to remove" discreet popup
+        HBufC* header = HbTextResolverSymbian::LoadLC(KUsbDisconnected);
+        if (iDiscreet)
+            {
+             FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::StartDialogL() deleting previous dialog"));
+             delete iDiscreet;
+             iDiscreet = NULL;
+            }
+        iDiscreet = CHbDeviceNotificationDialogSymbian::NewL(this);
+        iDiscreet->SetTitleL(*header);
+        iDiscreet->SetTextL(*stringHolder);
+        iDiscreet->SetIconNameL(KUSBUIconFileName );
+        iDiscreet->ShowL();
+        CleanupStack::PopAndDestroy( header );   
         }
+    else
+        {
+         //Delete the query in case the client didn't cancel the notifier 
+   			 //or close the session after the previous query.
+   
+        if (iQuery)
+            {
+            FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::StartDialogL() deleting previous dialog"));
+            delete iQuery;
+            iQuery = NULL;
+            }
+        
+        iQuery = CHbDeviceMessageBoxSymbian::NewL(
+                CHbDeviceMessageBoxSymbian::EWarning, this);
+        iQuery->SetTimeout(0);
     
-    iQuery = CHbDeviceMessageBoxSymbian::NewL(
-            CHbDeviceMessageBoxSymbian::EWarning, this);
-    iQuery->SetTimeout(0);
-    
-    HBufC* stringHolder = HbTextResolverSymbian::LoadLC(iStringIds->MdcaPoint(errorId));
-    iQuery->SetTextL(*stringHolder);
-    iQuery->ShowL();
+  
+        iQuery->SetTextL(*stringHolder);
+        iQuery->ShowL();
+        }
+   
     CleanupStack::PopAndDestroy( stringHolder );
+   
         
-    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::GetParamsL() completed"));
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::StartDialogL() completed"));
     }
 
 // ----------------------------------------------------------------------------
@@ -171,6 +207,12 @@
         FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel iQuery deleted"));
         iQuery = NULL;
         }
+    if (iDiscreet)
+        {
+        iDiscreet->Close();
+        delete iDiscreet;
+        iDiscreet = NULL;
+        }
     CUSBUINotifierBase::Cancel();
     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel() completed"));
     }
@@ -203,4 +245,17 @@
     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::MessageBoxClosed completed"));    
     }
 
+void CUsbUiNotifMSMMError::NotificationDialogActivated(
+     const CHbDeviceNotificationDialogSymbian* /*aDialog*/)
+	{
+       
+	}
+   
+void CUsbUiNotifMSMMError::NotificationDialogClosed(
+        const CHbDeviceNotificationDialogSymbian* /*aDialog*/, TInt /*aCompletionCode*/)
+	{
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::NotificationDialogClosed()"));
+    CompleteMessage( KErrCancel ); 
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::NotificationDialogClosed() complete"));
+    }
 // End of File