--- a/usbuis/usbuinotif/src/usbuinotifotgerror.cpp Thu Aug 19 10:54:11 2010 +0300
+++ b/usbuis/usbuinotif/src/usbuinotifotgerror.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, 2009 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"
@@ -17,21 +17,16 @@
// 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 <featmgr.h>
-
+#include <hb/hbwidgets/hbdevicemessageboxsymbian.h> // dialog
+#include <hb/hbcore/hbtextresolversymbian.h>
#include <usbuinotif.h> // pck
-#include <usbuinotif.rsg> // Own resources
-#include <secondarydisplay/usbuinotifsecondarydisplay.h> // Dialog index for cover UI
-
#include "usbuinotifotgerror.h" // Own class definition
#include "usbuinotifdebug.h" // Debugging macros
+// CONSTANTS
+/** granularity for allocating error strings */
+const TInt KUsbOtgErrorGranularity = 7;
+
// ================= MEMBER FUNCTIONS =========================================
@@ -56,7 +51,7 @@
// ----------------------------------------------------------------------------
//
CUsbUiNotifOtgError::CUsbUiNotifOtgError() :
- iStringIds( KUsbUiNotifOtgGeneralQueryGranularity)
+ iStringIds(NULL)
{
}
@@ -69,21 +64,29 @@
//Make sure that the request is completed. Note that inside the destructor,
//this virtual function call is to local CUsbUiNotifOtgError::Cancel,
//not to any possibly derived class implementation.
+ delete iStringIds;
Cancel();
- delete iDialerWatcher;
- delete iQuery;
}
void CUsbUiNotifOtgError::ConstructL()
{
CUSBUINotifierBase::ConstructL();
- iStringIds.AppendL( R_USB_OTG_ERROR_CURRENT_LIMIT);
- iStringIds.AppendL( R_USB_OTG_ERROR_TOO_MUCH_CURRENT_REQUIRED);
- iStringIds.AppendL( R_USB_OTG_ERROR_UNSUPPORTED);
- iStringIds.AppendL( R_USB_OTG_ERROR_HUB_UNSUPPORTED);
- iStringIds.AppendL( R_USB_OTG_ERROR_UNRECOVERABLE);
- iStringIds.AppendL( R_USB_OTG_ERROR_ATTACH_TIMEDOUT);
- iStringIds.AppendL( R_USB_ERROR_MEMORY_NOT_ENOUGH);
+ iStringIds = new (ELeave) CDesCArrayFlat(KUsbOtgErrorGranularity);
+ _LIT(KCurrentLimit, "txt_usb_info_error_in_usb_connection_disconnect_d");
+ _LIT(KTooMuchCurrent, "txt_usb_info_unsupported_usb_device_disconnect_de");
+ _LIT(KUnsupported, "txt_usb_info_unsupported_usb_device_disconnect_de");
+ _LIT(KHubUnsupported, "txt_usb_info_hubs_are_not_supported_disconnect_us");
+ _LIT(KUnRecoverable, "txt_usb_info_error_in_usb_connection_disconnect_d");
+ _LIT(KAttachTimeOut, "txt_usb_info_remove_usb_cable_or_connect_a_device");
+ _LIT(KNotEnoughMemory, "txt_usb_info_memory_full_close_some_applications");
+ iStringIds->AppendL( KCurrentLimit);
+ iStringIds->AppendL( KTooMuchCurrent);
+ iStringIds->AppendL( KUnsupported);
+ iStringIds->AppendL( KHubUnsupported);
+ iStringIds->AppendL( KUnRecoverable);
+ iStringIds->AppendL( KAttachTimeOut);
+ iStringIds->AppendL( KNotEnoughMemory);
+
}
// ----------------------------------------------------------------------------
@@ -104,74 +107,47 @@
// Jump to RunL as soon as possible.
// ----------------------------------------------------------------------------
//
-void CUsbUiNotifOtgError::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot,
+void CUsbUiNotifOtgError::StartDialogL(const TDesC8& aBuffer, TInt aReplySlot,
const RMessagePtr2& aMessage)
{
- FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::GetParamsL"));
- if (iQuery || iReplySlot != 0 || iNeedToCompleteMessage)
+ FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::StartDialogL"));
+ if (iReplySlot != 0 || iNeedToCompleteMessage)
{
User::Leave( KErrInUse );
}
-
- // Get parameters
- //
+
+ InitializeTextResolver();
- TPckgC<TInt> pckg( iErrorId );
+ TInt errorId = 0;
+ TPckgC<TInt> pckg( errorId );
pckg.Set( aBuffer );
- iErrorId = pckg();
+ errorId = pckg();
- FTRACE(FPrint(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::GetParamsL iErrorId: %d"), iErrorId ));
- if ( iErrorId < 0 || iErrorId >= iStringIds.Count() )
+ FTRACE(FPrint(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::GetParamsL iErrorId: %d"), errorId ));
+ if ( errorId < 0 || errorId >= iStringIds->MdcaCount())
{
User::Leave( KErrArgument);
}
-
iMessage = aMessage;
iNeedToCompleteMessage = ETrue;
- iReplySlot = aReplySlot;
-
- SetActive();
- iStatus = KRequestPending;
- TRequestStatus* stat = &iStatus;
- User::RequestComplete( stat, KErrNone );
+ iReplySlot = aReplySlot;
+
+ if (iQuery)
+ {
+ delete iQuery;
+ iQuery = NULL;
+ }
- FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::GetParamsL() completed"));
- }
-
-// ----------------------------------------------------------------------------
-// CUsbUiNotifOtgError::RunL
-// Ask user response and return it to caller.
-// ----------------------------------------------------------------------------
-//
-void CUsbUiNotifOtgError::RunL()
- {
- FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::RunL"));
- TInt returnValue = KErrNone;
- FeatureManager::InitializeLibL();
- if ( FeatureManager::FeatureSupported( KFeatureIdFfKeypadNoSendKey ) )
- {
- if (!iDialerWatcher)
- {
- iDialerWatcher = CUsbuinotifDialerWatcher::NewL(this);
- }
- }
- FeatureManager::UnInitializeLib();
- iDismissed=EFalse;
- DisableKeylock();
- SuppressAppSwitching( ETrue );
-
- //Excute dialog and check return value
- returnValue = QueryUserResponseL();
- if (!iDismissed)
- {
- SuppressAppSwitching( EFalse );
- RestoreKeylock();
- delete iDialerWatcher;
- iDialerWatcher = NULL;
- CompleteMessage( returnValue );
- }
-
- FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::RunL() completed"));
+ iQuery = CHbDeviceMessageBoxSymbian::NewL(
+ CHbDeviceMessageBoxSymbian::EWarning, this);
+ iQuery->SetTimeout(0);
+ HBufC* stringHolder = HbTextResolverSymbian::LoadLC(iStringIds->MdcaPoint(errorId) );
+ iQuery->SetTextL(*stringHolder);
+ iQuery->ShowL();
+ CleanupStack::PopAndDestroy( stringHolder );
+
+
+ FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::StartDialogL completed"));
}
// ----------------------------------------------------------------------------
@@ -181,93 +157,44 @@
//
void CUsbUiNotifOtgError::Cancel()
{
- FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::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 );
- }
+ FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel"));
if (iQuery)
{
+ iQuery->Close();
delete iQuery;
iQuery = NULL;
}
+ CUSBUINotifierBase::Cancel();
+
FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel() completed"));
}
-
// ----------------------------------------------------------------------------
-// CUsbUiNotifOtgError::DialerActivated
-// Release all own resources (member variables)
+// Call back function to observe device message box closing.
// ----------------------------------------------------------------------------
//
-void CUsbUiNotifOtgError::DialerActivated()
+void CUsbUiNotifOtgError::MessageBoxClosed(
+ const CHbDeviceMessageBoxSymbian* /*aMessageBox*/,
+ CHbDeviceMessageBoxSymbian::TButtonId aButton)
{
- FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::AppKeyPressed()"));
- if ( iQuery )
- {
- iDismissed=ETrue;
- Cancel();
- }
- }
+ 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.
-// ----------------------------------------------------------------------------
-// CUsbUiNotifOtgError::ReActivateDialog
-// Release all own resources (member variables)
-// ----------------------------------------------------------------------------
-//
-void CUsbUiNotifOtgError::ReActivateDialog()
- {
- FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::ReActivateDialog()"));
- if ( !IsActive())
+ if (aButton == CHbDeviceMessageBoxSymbian::EAcceptButton)
+ {
+ returnValue = KErrNone;
+ }
+ else
{
- SetActive();
- iStatus = KRequestPending;
- TRequestStatus* stat = &iStatus;
- User::RequestComplete( stat, KErrNone );
+ returnValue = KErrCancel;
}
+
+ CompleteMessage( returnValue );
+
+ FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::MessageBoxClosed completed"));
}
-// ----------------------------------------------------------------------------
-// CUsbUiNotifOtgError::QueryUserResponseL
-// Show query dialog.
-// ----------------------------------------------------------------------------
-//
-TInt CUsbUiNotifOtgError::QueryUserResponseL()
- {
- FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::QueryUserResponseL"));
- TInt returnValue = KErrNone;
- TInt resourceId = R_USB_QUERY_OTG_ERROR;
- if (iDismissed)
- {
- iQuery = CAknQueryDialog::NewL();
- }
- else
- {
- iQuery = CAknQueryDialog::NewL( CAknQueryDialog::EErrorTone );
- }
-
-
- iDismissed=EFalse;
- if (iCoverDisplaySupported)
- {
- iQuery->PublishDialogL( iErrorId, KUsbUiNotifOtgError );
- }
- HBufC *stringHolder = StringLoader::LoadLC( iStringIds[iErrorId] );
-
- TInt keypress = iQuery->ExecuteLD( resourceId, *stringHolder );
-
- CleanupStack::PopAndDestroy( stringHolder );
-
- iQuery = NULL; // Dialog destroyed
-
- returnValue = keypress ? KErrNone : KErrCancel; //OK?
-
- FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::QueryUserResponseL completed"));
- return returnValue;
- }
// End of File