meetingrequest/mrgui/src/cesmrresponsedialog.cpp
changeset 0 8466d47a6819
child 16 4ce476e64c59
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     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:  ESMR policy implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include "cesmrresponsedialog.h"
       
    19 #include "cmrresponsedialogview.h"
       
    20 #include "esmrgui.hrh"
       
    21 //<cmail>
       
    22 #include "esmrdef.h"
       
    23 //</cmail>
       
    24 #include "esmrinternaluid.h"
       
    25 
       
    26 #include <eikenv.h>
       
    27 #include <eikappui.h>
       
    28 #include <avkon.hrh>
       
    29 #include <MAgnEntryUi.h>
       
    30 #include <eikedwin.h>
       
    31 #include <esmrgui.rsg>
       
    32 #include <calentry.h>
       
    33 #include <hlplch.h>
       
    34 #include <akntoolbar.h>
       
    35 #include <aknappui.h>
       
    36 #include <aknViewAppUi.h>
       
    37 #include <aknview.h>
       
    38 #include <eikcolib.h>
       
    39 #include <akntoolbarobserver.h>
       
    40 #include <aknbutton.h>
       
    41 
       
    42 #include <featmgr.h>
       
    43 //</cmail>
       
    44 
       
    45 // <cmail> custom sw help files not avilable in Cmail
       
    46 //#include <fsmr.hlp.hrh>
       
    47 // </cmail>
       
    48 
       
    49 // DEBUG
       
    50 #include "emailtrace.h"
       
    51 
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CESMRResponseDialog::CESMRResponseDialog
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 CESMRResponseDialog::CESMRResponseDialog( HBufC*& aText ): iText(aText)
       
    58     {
       
    59     FUNC_LOG;
       
    60     // Do nothing
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CESMRResponseDialog::~CESMRResponseDialog
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CESMRResponseDialog::~CESMRResponseDialog()
       
    68     {
       
    69     FUNC_LOG;
       
    70     TRAP_IGNORE( RestoreMrGuiToolbarL() );
       
    71     // iView is deleted by framework because it uses the
       
    72     // custom control mechanism.
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // CESMRResponseDialog::NewL
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 EXPORT_C CESMRResponseDialog* CESMRResponseDialog::NewL( HBufC*& aText )
       
    80     {
       
    81     FUNC_LOG;
       
    82     CESMRResponseDialog* self =
       
    83         new (ELeave) CESMRResponseDialog( aText );
       
    84     CleanupStack::PushL( self );
       
    85     self->ConstructL();
       
    86     CleanupStack::Pop( self );
       
    87     return self;
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // CESMRResponseDialog::ConstructL
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 void CESMRResponseDialog::ConstructL()
       
    95     {
       
    96     FUNC_LOG;
       
    97     CAknDialog::ConstructL( R_RESPONSE_DIALOG_MENUBAR );
       
    98     CEikonEnv* eikonEnv = CEikonEnv::Static();// codescanner::eikonenvstatic
       
    99     TRect clientRect = eikonEnv->EikAppUi()->ClientRect();
       
   100     iView = CESMRResponseDialogView::NewL();
       
   101     iView->SetRect( clientRect );
       
   102     iView->SetSize(clientRect.Size());
       
   103 
       
   104     MakeResponseToolbarL();
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CESMRResponseDialog::ProcessCommandL
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 void CESMRResponseDialog::ProcessCommandL( TInt aCommand )
       
   112     {
       
   113     FUNC_LOG;
       
   114     CAknDialog::ProcessCommandL( aCommand );
       
   115 
       
   116     switch ( aCommand )
       
   117         {
       
   118         case EAknCmdHelp:
       
   119             {
       
   120             // <cmail>
       
   121             // TUid uid = { KUidCalendarApplication };
       
   122             // </cmail>
       
   123             CArrayFix<TCoeHelpContext>* cntx = 
       
   124 				new (ELeave) CArrayFixFlat<TCoeHelpContext>(1);
       
   125             CleanupStack::PushL( cntx );
       
   126             // <cmail>
       
   127             //cntx->AppendL( TCoeHelpContext( uid, KFSCA_HLP_RESPONSE_EDITOR ) );
       
   128             // /</cmail>
       
   129             CleanupStack::Pop( cntx );
       
   130             HlpLauncher::LaunchHelpApplicationL( iCoeEnv->WsSession(), cntx );
       
   131             break;
       
   132             }
       
   133         case EESMRCmdSendMR: // Fall through
       
   134         case EAknSoftkeyBack: // Fall through
       
   135         case EAknCmdExit:
       
   136             {
       
   137             TryExitL( aCommand );
       
   138             break;
       
   139             }
       
   140         default:
       
   141             {
       
   142             break;
       
   143             }
       
   144         }
       
   145     }
       
   146 // ---------------------------------------------------------------------------
       
   147 // CESMRResponseDialog::DynInitMenuPaneL()
       
   148 // ---------------------------------------------------------------------------
       
   149 //
       
   150 void CESMRResponseDialog::DynInitMenuPaneL(
       
   151         /*TInt aResourceId,*/
       
   152         CEikMenuPane* aMenuPane )
       
   153     {
       
   154     FUNC_LOG;
       
   155 	if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
       
   156 		{
       
   157 		// remove help support in pf5250
       
   158 		aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue);      
       
   159 		}
       
   160     }
       
   161 // ---------------------------------------------------------------------------
       
   162 // CESMRResponseDialog::OfferKeyEventL
       
   163 // ---------------------------------------------------------------------------
       
   164 //
       
   165 TKeyResponse CESMRResponseDialog::OfferKeyEventL(
       
   166         const TKeyEvent& aEvent,
       
   167         TEventCode aType)
       
   168     {
       
   169     FUNC_LOG;
       
   170     TKeyResponse response( EKeyWasNotConsumed );
       
   171     if ( !MenuShowing() )
       
   172         {
       
   173         response = iView->OfferKeyEventL( aEvent, aType );
       
   174         }
       
   175 
       
   176     if ( response == EKeyWasNotConsumed )
       
   177         {
       
   178         response = CAknDialog::OfferKeyEventL( aEvent, aType );
       
   179         }
       
   180 
       
   181     return response;
       
   182     }
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // CESMRResponseDialog::OkToExitL
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 TBool CESMRResponseDialog::OkToExitL(TInt aButtonId)
       
   189     {
       
   190     FUNC_LOG;
       
   191     TBool res( EFalse );
       
   192     // show options
       
   193     if ( aButtonId == EAknSoftkeyOptions )
       
   194         {
       
   195         CAknDialog::DisplayMenuL();
       
   196         }
       
   197     // exit dialog
       
   198     if ( aButtonId == EESMRCmdSendMR ||
       
   199          aButtonId == EAknSoftkeyBack ||
       
   200          aButtonId == EAknCmdExit )
       
   201         {
       
   202         iText = iView->GetTextL();
       
   203         res = ETrue;
       
   204         }
       
   205 
       
   206     return res;
       
   207     }
       
   208 
       
   209 // ---------------------------------------------------------------------------
       
   210 // CESMRResponseDialog::CreateCustomControlL
       
   211 // ---------------------------------------------------------------------------
       
   212 //
       
   213 SEikControlInfo CESMRResponseDialog::CreateCustomControlL( TInt aType )
       
   214     {
       
   215     FUNC_LOG;
       
   216     SEikControlInfo controlInfo;
       
   217     controlInfo.iControl = NULL;
       
   218     controlInfo.iFlags = 0;
       
   219     controlInfo.iTrailerTextId = 0;
       
   220 
       
   221     if ( aType == EEsMrResponseDialogType )
       
   222         {
       
   223         controlInfo.iControl = iView;
       
   224         }
       
   225 
       
   226     return controlInfo;
       
   227     }
       
   228 
       
   229 // ---------------------------------------------------------------------------
       
   230 // CESMRResponseDialog::ExecuteViewLD
       
   231 // ---------------------------------------------------------------------------
       
   232 //
       
   233 EXPORT_C TInt CESMRResponseDialog::ExecuteDlgLD()
       
   234     {
       
   235     FUNC_LOG;
       
   236     return ExecuteLD( R_RESPONSE_DIALOG );
       
   237     }
       
   238 
       
   239 // ---------------------------------------------------------------------------
       
   240 // CESMRViewerDialog::OfferToolbarEventL
       
   241 // ---------------------------------------------------------------------------
       
   242 //
       
   243 void CESMRResponseDialog::OfferToolbarEventL( TInt aCommand ) 
       
   244     {
       
   245     TryExitL( aCommand );
       
   246     }
       
   247 
       
   248 // ---------------------------------------------------------------------------
       
   249 // CESMRViewerDialog::MakeResponseToolbarL
       
   250 // ---------------------------------------------------------------------------
       
   251 //
       
   252 void CESMRResponseDialog::MakeResponseToolbarL()
       
   253     {
       
   254     CAknToolbar* currentToolbar = static_cast<CEikAppUiFactory*>( iEikonEnv->AppUiFactory() )->CurrentFixedToolbar();
       
   255     iOldObserver = currentToolbar->ToolbarObserver();
       
   256     currentToolbar->SetToolbarObserver( this );
       
   257 
       
   258     CAknButton* buttonSend = CAknButton::NewL();
       
   259     buttonSend->ConstructFromResourceL( R_SEND_BUTTON );
       
   260     CAknButton* buttonEmpty1 = CAknButton::NewL();
       
   261     CAknButton* buttonEmpty2 = CAknButton::NewL();
       
   262     
       
   263     currentToolbar->AddItemL( buttonSend, EAknCtButton, EESMRCmdSendMR, 0, 0 );
       
   264     currentToolbar->AddItemL( buttonEmpty1, EAknCtButton, EESMRCmdUndefined, 0, 1 );
       
   265     currentToolbar->AddItemL( buttonEmpty2, EAknCtButton, EESMRCmdUndefined, 0, 2 );
       
   266     }
       
   267 
       
   268 // ---------------------------------------------------------------------------
       
   269 // CESMRViewerDialog::RestoreMrGuiToolbarL
       
   270 // ---------------------------------------------------------------------------
       
   271 //
       
   272 void CESMRResponseDialog::RestoreMrGuiToolbarL()
       
   273     {
       
   274     CAknToolbar* currentToolbar = static_cast<CEikAppUiFactory*>( iEikonEnv->AppUiFactory() )->CurrentFixedToolbar();
       
   275 
       
   276     currentToolbar->SetToolbarObserver( iOldObserver );
       
   277 
       
   278     CAknButton* buttonAccept    = CAknButton::NewL();
       
   279     CAknButton* buttonTentative = CAknButton::NewL();
       
   280     CAknButton* buttonDecline   = CAknButton::NewL();
       
   281     buttonAccept->ConstructFromResourceL( R_ACCEPT_BUTTON );
       
   282     buttonTentative->ConstructFromResourceL( R_TENTATIVE_BUTTON );
       
   283     buttonDecline->ConstructFromResourceL( R_DECLINE_BUTTON );
       
   284     currentToolbar->AddItemL( buttonAccept, EAknCtButton, EESMRCmdAcceptMR, 0, 0 );
       
   285     currentToolbar->AddItemL( buttonTentative, EAknCtButton, EESMRCmdTentativeMR, 0, 1 );
       
   286     currentToolbar->AddItemL( buttonDecline, EAknCtButton, EESMRCmdDeclineMR, 0, 2 );
       
   287     }
       
   288 // EOF