uiservicetab/vimpstutils/src/vimpstutilswaitnote.cpp
branchRCL_3
changeset 29 9a48e301e94b
equal deleted inserted replaced
28:3104fc151679 29:9a48e301e94b
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Helper class for wait notes
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "vimpstutilswaitnote.h"
       
    22 
       
    23 #include    <vimpstuires.rsg>
       
    24 #include "uiservicetabtracer.h"
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CVIMPSTUtilsWaitNote::CVIMPSTUtilsWaitNote
       
    30 // C++ default constructor can NOT contain any code, that
       
    31 // might leave.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CVIMPSTUtilsWaitNote::CVIMPSTUtilsWaitNote()
       
    35     {
       
    36     }
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CVIMPSTUtilsWaitNote::ConstructL
       
    40 // Symbian 2nd phase constructor can leave.
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 EXPORT_C void CVIMPSTUtilsWaitNote::ConstructL( const TDesC& aText,
       
    44 							  TBool aShowImmediately,
       
    45         					  TBool aCanBeCanceledByUser,
       
    46         					  MVIMPSTUtilsWaitNoteObserver* aObserver )
       
    47     {
       
    48 	TRACER_AUTO;
       
    49 	// don't give dialog pointer as a parameter because
       
    50 	// it gets invalid after deletion of this instance
       
    51 	iWaitDialog = new( ELeave )CAknWaitDialog( NULL, aShowImmediately );
       
    52 	if( aCanBeCanceledByUser )
       
    53 	    {
       
    54         iWaitDialog->PrepareLC( R_IM_WAIT_NOTE_TEMPLATE_WITH_CANCEL );	    
       
    55 	    }
       
    56 	else
       
    57 	    {
       
    58 	    iWaitDialog->PrepareLC( R_IM_WAIT_NOTE_TEMPLATE );
       
    59 	    }    
       
    60     iWaitDialog->SetTone( CAknNoteDialog::ENoTone );
       
    61     iWaitDialog->SetTextL( aText );
       
    62     iWaitDialog->SetCallback( this );
       
    63 
       
    64     SetObserver( aObserver );
       
    65     iWaitDialog->RunLD();   // CSI: 50 # iWaitDialog is not owned by us
       
    66     }
       
    67 
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CVIMPSTUtilsWaitNote::ShowWaitNoteL
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 EXPORT_C CVIMPSTUtilsWaitNote* CVIMPSTUtilsWaitNote::ShowWaitNoteL( const TDesC& aText,
       
    74 		        			 			  TBool aShowImmediately /*= EFalse*/,
       
    75         								  TBool aCanBeCanceledByUser /*= EFalse*/,
       
    76         								  MVIMPSTUtilsWaitNoteObserver* aObserver /*= NULL*/ )
       
    77     {
       
    78 	TRACER_AUTO;
       
    79     CVIMPSTUtilsWaitNote* self = ShowWaitNoteLC(aText,aShowImmediately,aCanBeCanceledByUser,aObserver);
       
    80     CleanupStack::Pop( self );
       
    81     return self;
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CVIMPSTUtilsWaitNote::ShowWaitNoteLC
       
    86 // Two-phased constructor.
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 EXPORT_C CVIMPSTUtilsWaitNote* CVIMPSTUtilsWaitNote::ShowWaitNoteLC( const TDesC& aText,
       
    90 		        			 			  TBool aShowImmediately /*= EFalse*/,
       
    91         								  TBool aCanBeCanceledByUser /*= EFalse*/,
       
    92         								  MVIMPSTUtilsWaitNoteObserver* aObserver /*= NULL*/ )
       
    93     {
       
    94 	TRACER_AUTO;
       
    95     CVIMPSTUtilsWaitNote* self = new( ELeave ) CVIMPSTUtilsWaitNote();
       
    96     CleanupStack::PushL( self );
       
    97     self->ConstructL( aText, aShowImmediately, aCanBeCanceledByUser, aObserver );
       
    98     return self;
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CVIMPSTUtilsWaitNote::ShowWaitNoteLC
       
   103 // Two-phased constructor.
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 EXPORT_C CVIMPSTUtilsWaitNote* CVIMPSTUtilsWaitNote::ShowWaitNoteLC( TInt aTextResource,
       
   107 		        			 			  TBool aShowImmediately /*= EFalse*/,
       
   108         								  TBool aCanBeCanceledByUser /*= EFalse*/,
       
   109         								  MVIMPSTUtilsWaitNoteObserver* aObserver /*= NULL*/ )
       
   110     {
       
   111 	TRACER_AUTO;
       
   112 	CVIMPSTUtilsWaitNote* self = new( ELeave ) CVIMPSTUtilsWaitNote();
       
   113     CleanupStack::PushL( self );
       
   114 
       
   115     HBufC* text = CCoeEnv::Static()->AllocReadResourceLC( aTextResource );
       
   116     self->ConstructL( *text, aShowImmediately, aCanBeCanceledByUser, aObserver );
       
   117     CleanupStack::PopAndDestroy( text );
       
   118 
       
   119     return self;
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CVIMPSTUtilsWaitNote::ShowWaitNoteL
       
   124 // Two-phased constructor.
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 EXPORT_C CVIMPSTUtilsWaitNote* CVIMPSTUtilsWaitNote::ShowWaitNoteL( TInt aTextResource,
       
   128 		        			 			 TBool aShowImmediately /*= EFalse*/,
       
   129         								 TBool aCanBeCanceledByUser /*= EFalse*/,
       
   130         								 MVIMPSTUtilsWaitNoteObserver* aObserver /*= NULL*/ )
       
   131     {
       
   132 	TRACER_AUTO;
       
   133 	CVIMPSTUtilsWaitNote* self = ShowWaitNoteLC( aTextResource,
       
   134 	                                    aShowImmediately,
       
   135 	                                    aCanBeCanceledByUser,
       
   136 	                                    aObserver );
       
   137     
       
   138     CleanupStack::Pop( self );
       
   139     return self;
       
   140     }
       
   141 
       
   142 
       
   143 
       
   144 
       
   145 // Destructor
       
   146 CVIMPSTUtilsWaitNote::~CVIMPSTUtilsWaitNote()
       
   147     {
       
   148 	DismissDialog();
       
   149     }
       
   150 
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 // CVIMPSTUtilsWaitNote::DialogDismissedL
       
   154 // Called when dialog is dismissed
       
   155 // (other items were commented in a header).
       
   156 // -----------------------------------------------------------------------------
       
   157 //
       
   158 EXPORT_C void CVIMPSTUtilsWaitNote::DialogDismissedL( TInt aButtonId )
       
   159     {
       
   160 	TRACER_AUTO;
       
   161     iWaitDialog = NULL;
       
   162     if( iObserver )
       
   163         {
       
   164         iObserver->NoteCanceled( aButtonId );
       
   165         }
       
   166     }
       
   167 
       
   168 // -----------------------------------------------------------------------------
       
   169 // CVIMPSTUtilsWaitNote::DismissDialog
       
   170 // Dismisses the dialog
       
   171 // (other items were commented in a header).
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 EXPORT_C void CVIMPSTUtilsWaitNote::DismissDialog()
       
   175 	{
       
   176 	TRACER_AUTO;
       
   177 	if( iWaitDialog )
       
   178         {
       
   179         iWaitDialog->SetCallback( NULL );
       
   180         TRAPD( err, iWaitDialog->ProcessFinishedL() );
       
   181         
       
   182         if( err != KErrNone )
       
   183             {
       
   184             // don't know for sure that ProcessFinishedL deletes the dialog
       
   185             // in all cases, so let's delete it
       
   186             delete iWaitDialog;
       
   187             iWaitDialog = NULL;
       
   188             CActiveScheduler::Current()->Error( err );
       
   189             }
       
   190 
       
   191         TRAP_IGNORE( DialogDismissedL( 0 ) );
       
   192         }
       
   193 	}
       
   194 
       
   195 // -----------------------------------------------------------------------------
       
   196 // CVIMPSTUtilsWaitNote::SetObserver
       
   197 // (other items were commented in a header).
       
   198 // -----------------------------------------------------------------------------
       
   199 //
       
   200 EXPORT_C void CVIMPSTUtilsWaitNote::SetObserver( MVIMPSTUtilsWaitNoteObserver* aObserver )
       
   201     {
       
   202     iObserver = aObserver;
       
   203     }
       
   204 
       
   205 //  End of File