diff -r 5b2a402e96ac -r 25fce757be94 usbuis/usbuinotif/src/usbuinotifmsmmerror.cpp --- a/usbuis/usbuinotif/src/usbuinotifmsmmerror.cpp Thu Aug 19 10:54:11 2010 +0300 +++ b/usbuis/usbuinotif/src/usbuinotifmsmmerror.cpp Tue Aug 31 16:13:57 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2007-2010 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" @@ -11,29 +11,25 @@ * * Contributors: * -* Description: USB UI queries notifier class. +* Description: USB UI MSMM Error notifier class. * */ // INCLUDE FILES -#include // Eikon environment -#include // BAFL utils (for language file) -#include // Unicode character conversion utilities -#include // Localisation stringloader -#include -#include -#include -#include - +#include // dialog +#include //discreet +#include +#include #include // pck -#include // Own resources -#include // Dialog index for cover UI - #include "usbuinotifmsmmerror.h" // Own class definition #include "usbuinotifdebug.h" // Debugging macros +// CONSTANTS +/** granularity for allocating error strings */ +const TInt KUsbMsmmErrorGranularity = 5; +_LIT(KUSBUIconFileName, "qtg_large_usb"); // ================= MEMBER FUNCTIONS ========================================= // ---------------------------------------------------------------------------- @@ -57,7 +53,7 @@ // ---------------------------------------------------------------------------- // CUsbUiNotifMSMMError::CUsbUiNotifMSMMError() : - iStringIds( KUsbUiNotifOtgGeneralQueryGranularity) + iStringIds(NULL) { } @@ -70,17 +66,25 @@ //Make sure that the request is completed. Note that inside the destructor, //this virtual function call is to local CUsbUiNotifMSMMError::Cancel, //not to any possibly derived class implementation. + delete iStringIds; Cancel(); - delete iDialerWatcher; - delete iQuery; } void CUsbUiNotifMSMMError::ConstructL() { CUSBUINotifierBase::ConstructL(); - iStringIds.AppendL( R_USB_MSMM_ERROR_GENERAL_MASS_STORAGE_ERROR); - iStringIds.AppendL( R_USB_MSMM_ERROR_UNKNOWN_FILESYSTEM); - iStringIds.AppendL( R_USB_MSMM_ERROR_OUT_OF_MEMORY); + iStringIds = new (ELeave) CDesCArrayFlat(KUsbMsmmErrorGranularity); + _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); } // ---------------------------------------------------------------------------- @@ -101,76 +105,89 @@ // Jump to RunL as soon as possible. // ---------------------------------------------------------------------------- // -void CUsbUiNotifMSMMError::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, +void CUsbUiNotifMSMMError::StartDialogL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage) { - FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::GetParamsL")); - if (iQuery || iReplySlot != 0 || iNeedToCompleteMessage) + FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::StartDialogL")); + if (iReplySlot != 0 || iNeedToCompleteMessage) { User::Leave( KErrInUse ); } + InitializeTextResolver(); + iMessage = aMessage; iNeedToCompleteMessage = ETrue; iReplySlot = aReplySlot; - + _LIT(KUsbDisconnected, "txt_usb_dpophead_usb_disconnected"); // Get parameters // THostMsErrData error; - TPckgC pckg( error); + TPckgC pckg( error ); pckg.Set( aBuffer ); + int errorId = EUsbMSMMGeneralError; switch (pckg().iError) { case EHostMsErrUnknownFileSystem: - iErrorId = EUsbMSMMUnknownFileSystem; + errorId = EUsbMSMMUnknownFileSystem; break; case EHostMsErrOutOfMemory: - iErrorId = EUsbMSMMOutOfMemory; - break; + errorId = EUsbMSMMOutOfMemory; + break; + case EHostMsErrNone: + errorId = EUsbMSMMSafeToRemove; + break; + case EHostMsErrInUse: + errorId = EUsbMSMMUnableToEject; + break; default: - iErrorId = EUsbMSMMGeneralError; + errorId = EUsbMSMMGeneralError; } - - SetActive(); - iStatus = KRequestPending; - TRequestStatus* stat = &iStatus; - User::RequestComplete( stat, KErrNone ); - FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::GetParamsL() completed")); - } - -// ---------------------------------------------------------------------------- -// CUsbUiNotifMSMMError::RunL -// Ask user response and return it to caller. -// ---------------------------------------------------------------------------- -// -void CUsbUiNotifMSMMError::RunL() - { - FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::RunL")); - TInt returnValue = KErrNone; - FeatureManager::InitializeLibL(); - if ( FeatureManager::FeatureSupported( KFeatureIdFfKeypadNoSendKey ) ) - { - if (!iDialerWatcher) + HBufC* stringHolder = HbTextResolverSymbian::LoadLC(iStringIds->MdcaPoint(errorId)); + + + if ( errorId == EUsbMSMMSafeToRemove) + { + // "safe to remove" discreet popup + HBufC* header = HbTextResolverSymbian::LoadLC(KUsbDisconnected); + if (iDiscreet) { - iDialerWatcher = CUsbuinotifDialerWatcher::NewL(this); + FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::StartDialogL() deleting previous dialog")); + delete iDiscreet; + iDiscreet = NULL; } - } - iDismissed=EFalse; - DisableKeylock(); - SuppressAppSwitching( ETrue ); - - //Excute dialog and check return value - returnValue = QueryUserResponseL(); - if (!iDismissed) + iDiscreet = CHbDeviceNotificationDialogSymbian::NewL(this); + iDiscreet->SetTitleL(*header); + iDiscreet->SetTextL(*stringHolder); + iDiscreet->SetIconNameL(KUSBUIconFileName ); + iDiscreet->ShowL(); + CleanupStack::PopAndDestroy( header ); + } + else { - SuppressAppSwitching( EFalse ); - RestoreKeylock(); - delete iDialerWatcher; - iDialerWatcher = NULL; - CompleteMessage( returnValue ); + //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->SetTextL(*stringHolder); + iQuery->ShowL(); } - - FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::RunL() completed")); + + CleanupStack::PopAndDestroy( stringHolder ); + + + FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::StartDialogL() completed")); } // ---------------------------------------------------------------------------- @@ -181,92 +198,64 @@ void CUsbUiNotifMSMMError::Cancel() { FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel")); - // If dialog is not dismissed this is normal cancel and if query - // doesn't exsist notifier is canceled during dismission - if (!iDismissed || !iQuery ) - { - delete iDialerWatcher; - iDialerWatcher = NULL; - CompleteMessage( KErrCancel ); - } if (iQuery) { + FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel closing iQuery")); + iQuery->Close(); + FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel iQuery closed")); delete iQuery; + 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")); } // ---------------------------------------------------------------------------- -// CUsbUiNotifOtgError::DialerActivated -// Release all own resources (member variables) -// ---------------------------------------------------------------------------- -// -void CUsbUiNotifMSMMError::DialerActivated() - { - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::AppKeyPressed()")); - if ( iQuery ) - { - iDismissed=ETrue; - Cancel(); - } - } - -// ---------------------------------------------------------------------------- -// CUsbUiNotifOtgError::ReActivateDialog -// Release all own resources (member variables) -// ---------------------------------------------------------------------------- -// -void CUsbUiNotifMSMMError::ReActivateDialog() - { - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::ReActivateDialog()")); - if ( !IsActive()) - { - SetActive(); - iStatus = KRequestPending; - TRequestStatus* stat = &iStatus; - User::RequestComplete( stat, KErrNone ); - } - } -// ---------------------------------------------------------------------------- -// CUsbUiNotifMSMMError::QueryUserResponseL -// Show query dialog. +// Call back function to observe device message box closing. // ---------------------------------------------------------------------------- // -TInt CUsbUiNotifMSMMError::QueryUserResponseL() +void CUsbUiNotifMSMMError::MessageBoxClosed( + const CHbDeviceMessageBoxSymbian* /*aMessageBox*/, + CHbDeviceMessageBoxSymbian::TButtonId aButton) { - FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::QueryUserResponseL")); - TInt returnValue = KErrNone; - TInt resourceId = R_USB_QUERY_OTG_ERROR; - if (iDismissed) - { - iQuery = CAknQueryDialog::NewL(); - } - else - { - iQuery = CAknQueryDialog::NewL( CAknQueryDialog::EErrorTone ); - } - + FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::MessageBoxClosed")); + int returnValue = KErrNone; - iDismissed=EFalse; - if (iCoverDisplaySupported) - { - iQuery->PublishDialogL( iErrorId, KUsbUiNotifMsmmError ); - } - HBufC *stringHolder = StringLoader::LoadLC( iStringIds[iErrorId] ); - - TInt keypress = iQuery->ExecuteLD( resourceId, *stringHolder ); + //iQuery will be deleted in Cancel. If Cancel is not called, it will be + //deleted next time the query is shown. - CleanupStack::PopAndDestroy( stringHolder ); - - iQuery = NULL; // Dialog destroyed + if (aButton == CHbDeviceMessageBoxSymbian::EAcceptButton) + { + returnValue = KErrNone; + } + else + { + returnValue = KErrCancel; + } - returnValue = keypress ? KErrNone : KErrCancel; //OK? - - FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::QueryUserResponseL completed")); - return returnValue; + CompleteMessage( returnValue ); + + 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