usbuis/usbuinotif/src/usbuinotifotgwarning.cpp
branchRCL_3
changeset 24 e02eb84a14d2
parent 23 25fce757be94
equal deleted inserted replaced
23:25fce757be94 24:e02eb84a14d2
     1 /*
     1 /*
     2 * Copyright (c) 2007, 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    15  *
    15  *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include <hb/hbwidgets/hbdevicemessageboxsymbian.h>  
    20 #include <eikenv.h>             // Eikon environment
    21 #include <hb/hbcore/hbtextresolversymbian.h>
    21 #include <aknnotedialog.h>
       
    22 #include <bautils.h>            // BAFL utils (for language file)
       
    23 #include <StringLoader.h>       // Localisation stringloader
       
    24 #include <AknMediatorFacade.h>  // for cover display support
       
    25 #include <usbuinotif.rsg>       // Own resources
       
    26 #include <secondarydisplay/usbuinotifsecondarydisplay.h> // Dialog index for cover UI
       
    27 
    22 #include "usbuinotifotgwarning.h"        // Own class definition
    28 #include "usbuinotifotgwarning.h"        // Own class definition
    23 #include "usbuinotifdebug.h"                // Debugging macros
    29 #include "usbuinotifdebug.h"             // Debugging macros
    24 
    30 
    25 
       
    26 // CONSTANTS
       
    27 /** granularity for allocating warning strings */
       
    28 const TInt KUsbOtgWarningGranularity = 1; 
       
    29 
    31 
    30 // ================= MEMBER FUNCTIONS =========================================
    32 // ================= MEMBER FUNCTIONS =========================================
    31 
    33 
    32 // ----------------------------------------------------------------------------
    34 // ----------------------------------------------------------------------------
    33 // CUsbUiNotifOtgWarning::NewL
    35 // CUsbUiNotifOtgWarning::NewL
    50 // C++ default constructor can NOT contain any code, that
    52 // C++ default constructor can NOT contain any code, that
    51 // might leave.
    53 // might leave.
    52 // ----------------------------------------------------------------------------
    54 // ----------------------------------------------------------------------------
    53 //
    55 //
    54 CUsbUiNotifOtgWarning::CUsbUiNotifOtgWarning() :
    56 CUsbUiNotifOtgWarning::CUsbUiNotifOtgWarning() :
    55     iStringIds(NULL), iNote( NULL)
    57     iStringIds( KUsbUiNotifOtgGeneralNoteGranularity), iNote( NULL)
    56     {
    58     {
    57     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::constructor()"));
    59     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::constructor()"));
    58     }
    60     }
    59 
    61 
    60 // ----------------------------------------------------------------------------
    62 // ----------------------------------------------------------------------------
    65     {
    67     {
    66         FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::destructor()"));
    68         FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::destructor()"));
    67     //Make sure that the request is completed. Note that inside the destructor,
    69     //Make sure that the request is completed. Note that inside the destructor,
    68     //this virtual function call is to local CUsbUiNotifOtgWarning::Cancel, 
    70     //this virtual function call is to local CUsbUiNotifOtgWarning::Cancel, 
    69     //not to any possibly derived class implementation. 
    71     //not to any possibly derived class implementation. 
    70     delete iStringIds;
       
    71     Cancel();
    72     Cancel();
    72     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::destructor completed()"));
    73     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::destructor completed()"));
    73     }
    74     }
    74 
    75 
    75 void CUsbUiNotifOtgWarning::ConstructL()
    76 void CUsbUiNotifOtgWarning::ConstructL()
    76     {
    77     {
    77     CUSBUINotifierBase::ConstructL();
    78     CUSBUINotifierBase::ConstructL();
    78     iStringIds = new (ELeave) CDesCArrayFlat(KUsbOtgWarningGranularity);
    79     iStringIds.AppendL( R_USB_OTG_WARNING_PARTIAL_SUPPORT);
    79     _LIT(KPartiallySupported, "txt_usb_info_partially_supported_usb_device_connec");
       
    80     iStringIds->AppendL( KPartiallySupported);
       
    81     }
    80     }
    82 
    81 
    83 // ----------------------------------------------------------------------------
    82 // ----------------------------------------------------------------------------
    84 // CUsbUiNotifOtgWarning::RegisterL
    83 // CUsbUiNotifOtgWarning::RegisterL
    85 // Register notifier.
    84 // Register notifier.
   104     {
   103     {
   105     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel"));
   104     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel"));
   106     if (iNote)
   105     if (iNote)
   107         {
   106         {
   108         FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel - delete iNote"));
   107         FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel - delete iNote"));
   109         iNote->Close();
       
   110         delete iNote;
   108         delete iNote;
   111         iNote = NULL;
   109         iNote = NULL;
   112         }
   110         }
   113     CUSBUINotifierBase::Cancel();
   111     CompleteMessage( KErrNone );
   114 
   112 
   115     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel() completed"));
   113     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel() completed"));
   116     }
   114     }
   117 
   115 
   118 // ----------------------------------------------------------------------------
   116 // ----------------------------------------------------------------------------
   119 // CUsbUiNotifOtgWarning::GetParamsL
   117 // CUsbUiNotifOtgWarning::GetParamsL
   120 // Mandatory for USB UI Notifiers when using asynchronous launch. 
   118 // Mandatory for USB UI Notifiers when using asynchronous launch. 
   121 // This notifier is synchronous so this function is not used.
   119 // This notifier is synchronous so this function is not used.
   122 // ----------------------------------------------------------------------------
   120 // ----------------------------------------------------------------------------
   123 //
   121 //
   124 void CUsbUiNotifOtgWarning::StartDialogL(const TDesC8& aBuffer,
   122 void CUsbUiNotifOtgWarning::GetParamsL(const TDesC8& aBuffer,
   125         TInt aReplySlot, const RMessagePtr2& aMessage)
   123         TInt aReplySlot, const RMessagePtr2& aMessage)
   126     {
   124     {
   127     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::StartDialogL"));
   125     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::GetParamsL"));
   128     if (iReplySlot != 0 || iNeedToCompleteMessage)
   126     if (iNote || iReplySlot != 0 || iNeedToCompleteMessage)
   129         {
   127         {
   130         User::Leave( KErrInUse );
   128         User::Leave( KErrInUse );
   131         }
   129         }
   132         
       
   133     InitializeTextResolver();
       
   134 
       
   135     iMessage = aMessage;
       
   136     iNeedToCompleteMessage = ETrue;
       
   137     iReplySlot = aReplySlot;
       
   138 
   130 
   139     // Get parameters 
   131     // Get parameters 
   140     //    
   132     //    
   141     TPckgC<TInt> pckg( iNoteId );
   133     TPckgC<TInt> pckg( iNoteId );
   142     pckg.Set( aBuffer );
   134     pckg.Set( aBuffer );
   143     iNoteId = pckg();
   135     iNoteId = pckg();
   144 	FTRACE(FPrint(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::GetParamsL iNoteId: %d"), iNoteId ));  
   136     
   145     if ( iNoteId < 0 || iNoteId >= iStringIds->MdcaCount())
   137     FTRACE(FPrint(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::GetParamsL iNoteId: %d"), iNoteId ));  
       
   138     if ( iNoteId < 0 || iNoteId >= iStringIds.Count() )
   146         {        
   139         {        
   147         User::Leave( KErrArgument);        
   140         User::Leave( KErrArgument);        
   148         }   
   141         }  
   149     if (iNote)
   142     
   150             {
   143     iMessage = aMessage;
   151             delete iNote;
   144     iNeedToCompleteMessage = ETrue;
   152             iNote = NULL;
   145     iReplySlot = aReplySlot;
   153             }
   146     
   154         
   147     SetActive();
   155     iNote = CHbDeviceMessageBoxSymbian::NewL(
   148     iStatus = KRequestPending;
   156                 CHbDeviceMessageBoxSymbian::EWarning, this);
   149     TRequestStatus* stat = &iStatus;
   157     HBufC* stringHolder = HbTextResolverSymbian::LoadLC(iStringIds->MdcaPoint(iNoteId) );
   150     User::RequestComplete( stat, KErrNone );
   158     iNote->SetTextL(*stringHolder);
   151     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::GetParamsL() completed"));
   159     iNote->ShowL();
       
   160     CleanupStack::PopAndDestroy( stringHolder );
       
   161    
       
   162     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::StartDialogL completed"));
       
   163     }
   152     }
   164 
   153 
   165 // ----------------------------------------------------------------------------
   154 // ----------------------------------------------------------------------------
   166 // Call back function to observe device message box closing.
   155 // CUsbUiNotifOtgWarning::RunL
       
   156 // Mandatory for Active Objects. This notifier is synchronous 
       
   157 // so this function is not used.
   167 // ----------------------------------------------------------------------------
   158 // ----------------------------------------------------------------------------
   168 //
   159 //
   169 void CUsbUiNotifOtgWarning::MessageBoxClosed(
   160 void CUsbUiNotifOtgWarning::RunL()
   170         const CHbDeviceMessageBoxSymbian* /*aMessageBox*/,
       
   171         CHbDeviceMessageBoxSymbian::TButtonId aButton)
       
   172     {
   161     {
   173     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::MessageBoxClosed"));
   162     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::RunL"));
   174     int returnValue = KErrNone;
       
   175     
       
   176     //iQuery will be deleted in Cancel. If Cancel is not called, it will be
       
   177     //deleted next time the query is shown. 
       
   178 
   163 
   179     if (aButton == CHbDeviceMessageBoxSymbian::EAcceptButton) 
   164     // Create confirmation note
       
   165     //    
       
   166     HBufC* str = StringLoader::LoadL( iStringIds[iNoteId] );
       
   167     CleanupStack::PushL( str );
       
   168     iNote = new (ELeave) CAknWarningNote( ETrue );
       
   169 
       
   170     iNote->SetTimeout( CAknNoteDialog::ENoTimeout );
       
   171 
       
   172     if (iCoverDisplaySupported)
   180         {
   173         {
   181         returnValue = KErrNone;
   174         iNote->PublishDialogL( iNoteId, KUsbUiNotifOtgWarning );
   182         } 
       
   183     else 
       
   184         {
       
   185         returnValue = KErrCancel;
       
   186         }
   175         }
   187 
   176 
   188     CompleteMessage( returnValue );
   177     TInt t = iNote->ExecuteLD( *str );
   189     
   178     iNote = NULL;
   190     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::MessageBoxClosed completed"));    
   179     CleanupStack::PopAndDestroy( str );
       
   180 
       
   181     CompleteMessage( KErrNone );
       
   182   FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::RunL() completed"));
   191     }
   183     }
   192 
   184 
   193 // End of File
   185 // End of File