usbuis/usbuinotif/src/usbuinqueriesnotifiermdrv.cpp
branchGCC_SURGE
changeset 63 ef2686f7597e
parent 25 8c311f9acc5e
parent 38 218231f2b3b3
--- a/usbuis/usbuinotif/src/usbuinqueriesnotifiermdrv.cpp	Mon Jun 21 22:40:15 2010 +0100
+++ b/usbuis/usbuinotif/src/usbuinqueriesnotifiermdrv.cpp	Thu Jul 22 16:44:03 2010 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+ * Copyright (c) 2005-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"
@@ -16,18 +16,12 @@
  */
 
 // INCLUDE FILES
-#include <eikenv.h>          // Eikon environment
-#include <bautils.h>         // BAFL utils (for language file)
-#include <utf.h>             // Unicode character conversion utilities
-#include <StringLoader.h>    // Localisation stringloader
-#include <AknQueryDialog.h> 
-#include <aknnotewrappers.h>
 
+#include <hb/hbwidgets/hbdevicemessageboxsymbian.h>
+#include <hb/hbcore/hbtextresolversymbian.h>
 #include <usbuinotif.h>                     // pck
-#include <usbuinotif.rsg>                   // Own resources
 #include "usbuinqueriesnotifiermdrv.h"      // Own class definition
 #include "usbuinotifdebug.h"                // Debugging macros
-#include <SecondaryDisplay/usbuinotifsecondarydisplay.h>     // Dialog index for cover UI
 
 // ================= MEMBER FUNCTIONS =========================================
 
@@ -84,49 +78,21 @@
     return iInfo;
     }
 
-// ----------------------------------------------------------------------------
-// CUSBUIQueriesNotifier::StartL
-// Synchronic notifier launch. 
-// ----------------------------------------------------------------------------
-//
-TPtrC8 CUSBUIQueriesNotifier::StartL(const TDesC8& aBuffer)
-    {
-    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::StartL()"));
-
-    TUSBQueriesNotiferParams params; //stores parameters from aBuffef
-    TPckgC<TUSBQueriesNotiferParams> pckg( params );
-    pckg.Set( aBuffer );
-    // Save the type of the query for later use (dialog selection)
-    //
-
-    if (pckg().iQuery == EUSBNoMemoryCard)
-        {
-        TRAPD( err, GetParamsL( aBuffer, 0, iMessage ));
-        if (err)
-            {
-            iNeedToCompleteMessage = EFalse;
-            User::Leave( err );
-            }
-        }
-
-    TPtrC8 ret( KNullDesC8 );
-    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::StartL() completed"));
-    return (ret);
-    }
 
 // ----------------------------------------------------------------------------
 // CUSBUIQueriesNotifier::GetParamsL
-//  Jump to RunL as soon as possible.
 // ----------------------------------------------------------------------------
 //
-void CUSBUIQueriesNotifier::GetParamsL(const TDesC8& aBuffer,
+void CUSBUIQueriesNotifier::StartDialogL(const TDesC8& aBuffer,
         TInt aReplySlot, const RMessagePtr2& aMessage)
     {
-    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::GetParamsL"));
-    if (iUSBQueryDlg || iReplySlot != 0 || iNeedToCompleteMessage)
+    FLOG(_L("[USBUINOTIF]\t  CUSBUIQueriesNotifier::StartDialogL"));
+    if ( iReplySlot != 0 || iNeedToCompleteMessage)
         {
         User::Leave( KErrInUse );
         }
+        
+    InitializeTextResolver();
 
     iMessage = aMessage;
     iNeedToCompleteMessage = ETrue;
@@ -140,59 +106,54 @@
     // Save the type of the query for later use (dialog selection)
     //
     iQueryType = pckg().iQuery;
-    if (iQueryType == EUSBNoMemoryCard)
+         
+    if (iUSBQueryDlg)
         {
-        iNeedToCompleteMessage = EFalse;
+        delete iUSBQueryDlg;
+        iUSBQueryDlg = NULL;
         }
-    // Call SetActive() so RunL() will be called by the active scheduler
-    //
-    SetActive();
-    iStatus = KRequestPending;
-    TRequestStatus* stat = &iStatus;
-    User::RequestComplete( stat, KErrNone );
-    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::GetParamsL() completed"));
-    }
-
-// ----------------------------------------------------------------------------
-// CUSBUIQueriesNotifier::RunL
-// Ask user response and return it to caller.
-// ----------------------------------------------------------------------------
-//
-void CUSBUIQueriesNotifier::RunL()
-    {
-    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::RunL"));
-
-    TBool isCancelKey = EFalse;
-    TBool isErrorQuery = EFalse;
-    TInt returnValue = KErrNone;
-    // for cover display support
-    TInt coverDialogId = EUSBCoverInvalidDialogId;
-
-    // Choose text and other query attributes
-    //
-    HBufC* stringHolder = GetQueryAttributesLC( coverDialogId, isCancelKey, isErrorQuery );
-
-    //check if query text string loading was successful
-    if (NULL != stringHolder)
+    iUSBQueryDlg = CHbDeviceMessageBoxSymbian::NewL(
+                       CHbDeviceMessageBoxSymbian::EWarning, this);
+    iUSBQueryDlg->SetTimeout(0);
+    HBufC* stringHolder = NULL;
+    switch (iQueryType)
+            {
+            case EUSBStorageMediaFailure:
+                {
+                _LIT(KMassStorageFail, "txt_usb_info_unable_to_show_a_memory_to_other_devi");
+                stringHolder = HbTextResolverSymbian::LoadLC( KMassStorageFail );
+                 break;
+                }
+            case EUSBDiskFull:
+                {
+                _LIT(KDiskFull, "txt_usb_info_disk_full_remove_some_files_and_try");
+                stringHolder = HbTextResolverSymbian::LoadLC( KDiskFull );
+		         break;
+                }
+            case EUSBNotEnoughRam:
+                {
+                _LIT(KNotEnoughMemory, "txt_usb_info_memory_full_close_some_applications");
+                 stringHolder = HbTextResolverSymbian::LoadLC( KNotEnoughMemory );
+                 break;
+                }
+            default:
+                {
+                FTRACE( FPrint( _L( "[USBUINOTIF]\t CUSBUIQueriesNotifier::ERROR! Unknown query type: %d" ),iQueryType ) );
+                }
+            }
+   
+    if (stringHolder)
         {
-        DisableKeylock();
-        SuppressAppSwitching( ETrue );
-        returnValue = QueryUserResponseL( *stringHolder, coverDialogId,
-                isCancelKey, isErrorQuery );
-        SuppressAppSwitching( EFalse );
-        RestoreKeylock();
-        CleanupStack::PopAndDestroy( stringHolder );
+        iUSBQueryDlg->SetTextL(*stringHolder);
         }
-    else
-        {
-        returnValue = KErrUnknown;
-        }
-
-    CompleteMessage( returnValue );
-    // cancelling the notifier so that next one on the queue can be displayed.
-    // it may be that the client calls cancel too, but it is ok
-    iManager->CancelNotifier( iInfo.iUid );
-    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::RunL() completed"));
+        
+    iUSBQueryDlg->ShowL();
+    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::StartDialogL() ShowL returned"));     
+    
+    CleanupStack::PopAndDestroy( stringHolder );
+    
+    
+    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::StartDialogL completed"));
     }
 
 // ----------------------------------------------------------------------------
@@ -205,127 +166,40 @@
     FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::Cancel"));
     if (iUSBQueryDlg)
         {
+        iUSBQueryDlg->Close();
         delete iUSBQueryDlg;
         iUSBQueryDlg = NULL;
         }
-    CompleteMessage( KErrCancel );
-
+ 
     CUSBUINotifierBase::Cancel();
     FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::Cancel() completed"));
     }
 
-// ----------------------------------------------------------------------------
-// CUSBUIQueriesNotifier::QueryUserResponseL
-// Show query dialog. 
-// ----------------------------------------------------------------------------
-//
-TInt CUSBUIQueriesNotifier::QueryUserResponseL(const TDesC& aStringHolder,
-        TInt aCoverDialogId, TBool aIsCancelKey, TBool aIsErrorQuery)
-    {
-    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::QueryUserResponseL"));
-    TInt returnValue = KErrNone;
-
-    iUSBQueryDlg = CAknQueryDialog::NewL( CAknQueryDialog::EConfirmationTone );
 
-    // Show dialog with or without the Cancel
-    //
-    if (aIsErrorQuery) 
+void CUSBUIQueriesNotifier::MessageBoxClosed(
+        const CHbDeviceMessageBoxSymbian* /*aMessageBox*/,
+        CHbDeviceMessageBoxSymbian::TButtonId aButton)
+    {
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::MessageBoxClosed"));
+    int returnValue = KErrNone;
+    
+    //iQuery will be deleted in Cancel. If Cancel is not called, it will be
+    //deleted next time the query is shown. 
+
+    if (aButton == CHbDeviceMessageBoxSymbian::EAcceptButton) 
         {
-        // aIsErrorQuery flag is set in GetQueryAttributesLC()
-        // there is no defined QueryDialogError in resources so QueryOTGerror is used (contains Stop icon)
-        iUSBQueryDlg->PrepareLC( R_USB_QUERY_OTG_ERROR );
-        }
-    else if (aIsCancelKey)
+        returnValue = KErrNone;
+        } 
+    else 
         {
-        iUSBQueryDlg->PrepareLC( R_USB_QUERY_WITH_CANCEL );
-        }
-    else
-        {
-        iUSBQueryDlg->PrepareLC( R_USB_QUERY_WITHOUT_CANCEL );
+        returnValue = KErrCancel;
         }
 
-    if (iCoverDisplaySupported)
-        {
-        iUSBQueryDlg->PublishDialogL( aCoverDialogId, KUSBUINotifCategory );
-        }
-
-    iUSBQueryDlg->SetPromptL( aStringHolder );
-    iUSBQueryDlg->SetFocus( ETrue );
-        FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::QueryUserResponseL calling RunLD"));
-    TInt keypress = iUSBQueryDlg->RunLD();
-
-    iUSBQueryDlg = NULL;
-
-    if (keypress) // User has accepted the dialog
-        {
-        returnValue = KErrNone;
-            FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::QueryUserResponseL keypress"));
-        }
-    else
-        {
-        returnValue = KErrCancel;
-            FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::QueryUserResponseL NO keypress"));
-        }
-
-        FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::QueryUserResponseL completed"));
-    return returnValue;
+    CompleteMessage( returnValue );
+    
+    FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::MessageBoxClosed completed"));    
     }
 
-// ----------------------------------------------------------------------------
-// CUSBUIQueriesNotifier::GetQueryAttributesLC
-// Get query text and the other attributes for the query dialog. 
-// ----------------------------------------------------------------------------
-//
-HBufC* CUSBUIQueriesNotifier::GetQueryAttributesLC(TInt& aCoverDialogId,
-        TBool& aIsCancelKey, TBool& aIsErrorQuery)
-    {
-    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::GetQueryAttributesLC"));
-    HBufC* stringHolder = NULL; // The text for the query
-    aIsCancelKey = EFalse;
-    aIsErrorQuery = EFalse;
-    switch (iQueryType)
-        {
-        case EUSBStorageMediaFailure:
-            {
-                FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::EUSBStorageMediaFailure"));
-            stringHolder = StringLoader::LoadLC( R_USB_STORAGE_MEDIA_FAILURE );
-            aCoverDialogId = EUSBCoverStorageMediaFailure;
-            break;
-            }
-        case EUSBChangeFromMassStorage:
-            {
-                FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::EUSBChangeFromMassStorage"));
-            stringHolder = StringLoader::LoadLC(
-                    R_USB_CHANGE_FROM_MASS_STORAGE );
-            aIsCancelKey = ETrue;
-            aCoverDialogId = EUSBCoverChangeFromMassStorage;
-            break;
-            }
-        case EUSBNoMemoryCard:
-            {
-                FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::EUSBNoMemoryCard"));
-            stringHolder = StringLoader::LoadLC( R_USB_NO_MEMORY_CARD );
-            aCoverDialogId = EUSBCoverNoMemoryCard;
-            break;
-            } 
-        case EUSBNotEnoughRam:
-          	{
-            FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::EUSBNotEnoughRam"));
-            stringHolder = StringLoader::LoadLC( R_USB_ERROR_MEMORY_NOT_ENOUGH );
-            aCoverDialogId = EUSBCoverNoMemoryCard;
-            //set flag to change the icon of querydialog (see QueryUserResponseL())
-            aIsErrorQuery = ETrue;
-            break;
-            }
-        default:
-            {
-                FTRACE( FPrint(
-                                _L( "[USBUINOTIF]\t CUSBUIQueriesNotifier::ERROR! Unknown query type: %d" ),
-                                iQueryType ) );
-            }
-        }
-    FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::GetQueryAttributesLC completed"));
-    return stringHolder;
-    }
+
 
 // End of File