usbuis/usbuinotif/src/usbuinotifotgwarning.cpp
changeset 35 9d8b04ca6939
child 38 218231f2b3b3
equal deleted inserted replaced
34:7858bc6ead78 35:9d8b04ca6939
       
     1 /*
       
     2 * Copyright (c) 2007, 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  USB UI notes notifier class.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <eikenv.h>             // Eikon environment
       
    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 "usbuinotifotgwarning.h"        // Own class definition
       
    27 #include "usbuinotifdebug.h"                // Debugging macros
       
    28 #include "usbuinotifsecondarydisplay.h"     // Dialog index for cover UI
       
    29 // ================= MEMBER FUNCTIONS =========================================
       
    30 
       
    31 // ----------------------------------------------------------------------------
       
    32 // CUsbUiNotifOtgWarning::NewL
       
    33 // Two-phased constructor.
       
    34 // ----------------------------------------------------------------------------
       
    35 //
       
    36 CUsbUiNotifOtgWarning* CUsbUiNotifOtgWarning::NewL()
       
    37     {
       
    38     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::NewL()"));
       
    39     CUsbUiNotifOtgWarning* self = new (ELeave) CUsbUiNotifOtgWarning();
       
    40     CleanupStack::PushL( self );
       
    41     self->ConstructL();
       
    42     CleanupStack::Pop( self );
       
    43     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::NewL completed()"));
       
    44     return self;
       
    45     }
       
    46 
       
    47 // ----------------------------------------------------------------------------
       
    48 // CUsbUiNotifOtgWarning::CUsbUiNotifOtgWarning
       
    49 // C++ default constructor can NOT contain any code, that
       
    50 // might leave.
       
    51 // ----------------------------------------------------------------------------
       
    52 //
       
    53 CUsbUiNotifOtgWarning::CUsbUiNotifOtgWarning() :
       
    54     iStringIds( KUsbUiNotifOtgGeneralNoteGranularity), iNote( NULL)
       
    55     {
       
    56     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::constructor()"));
       
    57     }
       
    58 
       
    59 // ----------------------------------------------------------------------------
       
    60 // Destructor
       
    61 // ----------------------------------------------------------------------------
       
    62 //
       
    63 CUsbUiNotifOtgWarning::~CUsbUiNotifOtgWarning()
       
    64     {
       
    65         FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::destructor()"));
       
    66     //Make sure that the request is completed. Note that inside the destructor,
       
    67     //this virtual function call is to local CUsbUiNotifOtgWarning::Cancel, 
       
    68     //not to any possibly derived class implementation. 
       
    69     Cancel();
       
    70     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::destructor completed()"));
       
    71     }
       
    72 
       
    73 void CUsbUiNotifOtgWarning::ConstructL()
       
    74     {
       
    75     CUSBUINotifierBase::ConstructL();
       
    76     iStringIds.AppendL( R_USB_OTG_WARNING_PARTIAL_SUPPORT);
       
    77     }
       
    78 
       
    79 // ----------------------------------------------------------------------------
       
    80 // CUsbUiNotifOtgWarning::RegisterL
       
    81 // Register notifier.
       
    82 // ----------------------------------------------------------------------------
       
    83 //
       
    84 CUsbUiNotifOtgWarning::TNotifierInfo CUsbUiNotifOtgWarning::RegisterL()
       
    85     {
       
    86     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::RegisterL"));
       
    87     iInfo.iUid = KUsbUiNotifOtgWarning;
       
    88     iInfo.iChannel = KUsbUiNotifOtgWarning;
       
    89     iInfo.iPriority = ENotifierPriorityVHigh;
       
    90         FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::RegisterL completed()"));
       
    91     return iInfo;
       
    92     }
       
    93 
       
    94 // ----------------------------------------------------------------------------
       
    95 // CUsbUiNotifOtgWarning::Cancel
       
    96 // Release all own resources (member variables)
       
    97 // ----------------------------------------------------------------------------
       
    98 //
       
    99 void CUsbUiNotifOtgWarning::Cancel()
       
   100     {
       
   101     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel"));
       
   102     if (iNote)
       
   103         {
       
   104         FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel - delete iNote"));
       
   105         delete iNote;
       
   106         iNote = NULL;
       
   107         }
       
   108     CompleteMessage( KErrNone );
       
   109 
       
   110     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::Cancel() completed"));
       
   111     }
       
   112 
       
   113 // ----------------------------------------------------------------------------
       
   114 // CUsbUiNotifOtgWarning::GetParamsL
       
   115 // Mandatory for USB UI Notifiers when using asynchronous launch. 
       
   116 // This notifier is synchronous so this function is not used.
       
   117 // ----------------------------------------------------------------------------
       
   118 //
       
   119 void CUsbUiNotifOtgWarning::GetParamsL(const TDesC8& aBuffer,
       
   120         TInt aReplySlot, const RMessagePtr2& aMessage)
       
   121     {
       
   122     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::GetParamsL"));
       
   123     if (iNote || iReplySlot != 0 || iNeedToCompleteMessage)
       
   124         {
       
   125         User::Leave( KErrInUse );
       
   126         }    
       
   127 
       
   128     // Get parameters 
       
   129     //    
       
   130     TPckgC<TInt> pckg( iNoteId );
       
   131     pckg.Set( aBuffer );
       
   132     iNoteId = pckg();
       
   133     
       
   134     FTRACE(FPrint(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::GetParamsL iNoteId: %d"), iNoteId ));  
       
   135     if ( iNoteId < 0 || iNoteId >= iStringIds.Count() )
       
   136         {        
       
   137         User::Leave( KErrArgument);        
       
   138         }   
       
   139 
       
   140     iMessage = aMessage;
       
   141     iNeedToCompleteMessage = ETrue;
       
   142     iReplySlot = aReplySlot;
       
   143     
       
   144     SetActive();
       
   145     iStatus = KRequestPending;
       
   146     TRequestStatus* stat = &iStatus;
       
   147     User::RequestComplete( stat, KErrNone );
       
   148     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::GetParamsL() completed"));
       
   149     }
       
   150 
       
   151 // ----------------------------------------------------------------------------
       
   152 // CUsbUiNotifOtgWarning::RunL
       
   153 // Mandatory for Active Objects. This notifier is synchronous 
       
   154 // so this function is not used.
       
   155 // ----------------------------------------------------------------------------
       
   156 //
       
   157 void CUsbUiNotifOtgWarning::RunL()
       
   158     {
       
   159     FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::RunL"));
       
   160 
       
   161     // Create confirmation note
       
   162     //    
       
   163     HBufC* str = StringLoader::LoadL( iStringIds[iNoteId] );
       
   164     CleanupStack::PushL( str );
       
   165     iNote = new (ELeave) CAknWarningNote( ETrue );
       
   166 
       
   167     iNote->SetTimeout( CAknNoteDialog::ENoTimeout );
       
   168 
       
   169     if (iCoverDisplaySupported)
       
   170         {
       
   171         iNote->PublishDialogL( iNoteId, KUsbUiNotifOtgWarning );
       
   172         }
       
   173 
       
   174     TInt t = iNote->ExecuteLD( *str );
       
   175     iNote = NULL;
       
   176     CleanupStack::PopAndDestroy( str );
       
   177 
       
   178     CompleteMessage( KErrNone );
       
   179   FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::RunL() completed"));
       
   180     }
       
   181 
       
   182 // End of File