eventsui/eventshandlerui/eventshandlerapp/src/evtdlglauncher.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     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:  Events Dialog Launcher.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // System Includes
       
    20 #include <e32base.h>
       
    21 #include <eikenv.h>
       
    22 #include <eikappui.h>
       
    23 #include <NpdApi.h>					// Notepad
       
    24 #include <avkon.hrh>	
       
    25 
       
    26 // User Includes
       
    27 #include "evtdlglauncher.h"
       
    28 #include "evteventsdlg.h"
       
    29 #include "evtrequest.h"
       
    30 
       
    31 // ================ Member funtions for CEvtDlgLauncher class ===============
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // CEvtDlgLauncher::CEvtDlgLauncher
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CEvtDlgLauncher::CEvtDlgLauncher( CEvtMgmtUiEngine& aEngine, MEvtDlgObserver& aObserver ):
       
    38 							CActive( EPriorityStandard ),iObserver(aObserver),iEngine(aEngine)
       
    39 	{
       
    40 	}
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // CEvtDlgLauncher::~CEvtDlgLauncher
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 CEvtDlgLauncher::~CEvtDlgLauncher()
       
    47 	{
       
    48     CActive::Cancel();
       
    49     iEngine.RemoveObserver(this);
       
    50 	}
       
    51 	
       
    52 // ---------------------------------------------------------------------------
       
    53 // CEvtDlgLauncher::NewL
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CEvtDlgLauncher* CEvtDlgLauncher::NewL( CEvtMgmtUiEngine& aEngine, MEvtDlgObserver& aObserver )
       
    57     {
       
    58 	CEvtDlgLauncher* self = NewLC( aEngine, aObserver );
       
    59 	CleanupStack::Pop( self );
       
    60 	return self;
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CEvtDlgLauncher::NewLC
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CEvtDlgLauncher* CEvtDlgLauncher::NewLC( CEvtMgmtUiEngine& aEngine, MEvtDlgObserver& aObserver )
       
    68     {
       
    69 	CEvtDlgLauncher* self = new ( ELeave )CEvtDlgLauncher( aEngine, aObserver );
       
    70 	CleanupStack::PushL( self );
       
    71 	self->ConstructL( );
       
    72 	return self;
       
    73     } 
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // CEvtDlgLauncher::ConstructL
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 void CEvtDlgLauncher::ConstructL()
       
    80     {
       
    81     // Add the object to the Active scheduler
       
    82     CActiveScheduler::Add( this );
       
    83     iEngine.SetObserver(this);
       
    84     }
       
    85     
       
    86 // ---------------------------------------------------------------------------
       
    87 // void CEvtDlgLauncher::RunL()
       
    88 // ---------------------------------------------------------------------------
       
    89 //                             
       
    90 void CEvtDlgLauncher::RunL()
       
    91     {
       
    92     switch( iRequest->RequestType() )
       
    93     	{
       
    94     	case ERequestEditor:
       
    95     		{
       
    96 		    iDialog = CEvtEventsDlg::NewL( 
       
    97 		    	EFalse, 
       
    98 		    	iRequest->Event(),  
       
    99 		    	iEngine, EFalse );            
       
   100 		     
       
   101 		    iDialog->ExecuteLD( );
       
   102             iObserver.NotifyDlgDismissedL();
       
   103             
       
   104     		break;
       
   105     		}
       
   106     	case ERequestNotepad:        
       
   107 	    	{
       
   108 	    	TInt ret = CNotepadApi::ExecReadOnlyTextViewerL( iRequest->Event().Description(), iRequest->Event().Subject(), KNullDesC );
       
   109 		    if( !ret )
       
   110 	            {
       
   111 	            iObserver.NotifyDlgDismissedL();
       
   112 	            }
       
   113     		break;
       
   114     		}
       
   115     	default:
       
   116     		break;
       
   117     	}
       
   118     }
       
   119     
       
   120 // ---------------------------------------------------------------------------
       
   121 // void CEvtDlgLauncher::DoCancel()
       
   122 // ---------------------------------------------------------------------------
       
   123 // 
       
   124 void CEvtDlgLauncher::DoCancel()
       
   125     {
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // TInt CEvtDlgLauncher::RunError()
       
   130 // ---------------------------------------------------------------------------
       
   131 //    
       
   132 TInt CEvtDlgLauncher::RunError( TInt aError )
       
   133 	{
       
   134 	return CActive::RunError( aError );	
       
   135 	}
       
   136 	
       
   137 // ---------------------------------------------------------------------------
       
   138 // CEvtDlgLauncher::LaunchEventDlg
       
   139 // ---------------------------------------------------------------------------
       
   140 //
       
   141 void CEvtDlgLauncher::LaunchDlgL( CEvtRequest& aRequest )
       
   142 	{
       
   143     if ( IsActive( ) )
       
   144         {
       
   145         User::Leave ( KErrInUse );
       
   146         }
       
   147     
       
   148     iRequest = &aRequest;
       
   149     
       
   150     TRequestStatus* status = &iStatus;
       
   151     SetActive();    
       
   152     User::RequestComplete( status, KErrNone );
       
   153 
       
   154 	}
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // CEvtDlgLauncher::CancelDlgL
       
   158 // ---------------------------------------------------------------------------
       
   159 //
       
   160 void CEvtDlgLauncher::CancelDlgL( TBool aIsForcedCancel )
       
   161 	{
       
   162 	// We have to dismiss any Dialog which is launched on top of Editor
       
   163 	// So are looking for dismiss.
       
   164 	if( iDialog )
       
   165 		{
       
   166 	    delete iDialog;
       
   167 	    iDialog = NULL;	
       
   168 		}
       
   169 	if( aIsForcedCancel )
       
   170 		{
       
   171 	    TKeyEvent key;
       
   172 	    key.iCode = EKeyEscape;
       
   173 	    key.iModifiers = 0;
       
   174 	    CEikonEnv::Static()->SimulateKeyEventL( key, EEventKey );
       
   175 		}
       
   176     CActive::Cancel();
       
   177 	}
       
   178 		
       
   179 // ---------------------------------------------------------------------------
       
   180 // CEvtDlgLauncher::NotifyEventChangeL()
       
   181 // Derived from MEvtMgmtUiEngineObserver
       
   182 // ---------------------------------------------------------------------------
       
   183 //
       
   184 void CEvtDlgLauncher::NotifyEventChangeL(TInt /*aErrorCode*/, TInt /*aState */)
       
   185     {
       
   186     // Not needed     
       
   187     }
       
   188 
       
   189 // ---------------------------------------------------------------------------
       
   190 // CEvtDlgLauncher::NotifyModelChangeL()
       
   191 // Derived from MEvtMgmtUiEngineObserver
       
   192 // ---------------------------------------------------------------------------
       
   193 //
       
   194 void CEvtDlgLauncher::NotifyModelChangeL()
       
   195     {
       
   196     // Not needed 
       
   197     }  
       
   198