diff -r 5b2a402e96ac -r 25fce757be94 usbuis/usbuinotif/src/usbuinqueriesnotifiermdrv.cpp --- a/usbuis/usbuinotif/src/usbuinqueriesnotifiermdrv.cpp Thu Aug 19 10:54:11 2010 +0300 +++ b/usbuis/usbuinotif/src/usbuinqueriesnotifiermdrv.cpp Tue Aug 31 16:13:57 2010 +0300 @@ -16,17 +16,10 @@ */ // INCLUDE FILES -#include // Eikon environment -#include // BAFL utils (for language file) -#include // Unicode character conversion utilities -#include // Localisation stringloader -#include -#include +#include +#include #include // pck -#include // Own resources -#include // Dialog index for cover UI - #include "usbuinqueriesnotifiermdrv.h" // Own class definition #include "usbuinotifdebug.h" // Debugging macros @@ -85,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 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; @@ -141,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")); } // ---------------------------------------------------------------------------- @@ -206,134 +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; - } - case EUSBDiskFull: - { - FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::EUSBDiskFull")); - stringHolder = StringLoader::LoadLC( R_USB_ERROR_DISK_FULL ); - 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