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