meetingrequest/mrgui/src/cesmrviewerdialog.cpp
branchRCL_3
changeset 12 4ce476e64c59
parent 8 e1b6206813b4
child 16 b5fbb9b25d57
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
     1 /*
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    13 *
    13 *
    14 * Description:  ESMR policy implementation
    14 * Description:  ESMR policy implementation
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "emailtrace.h"
       
    19 #include "cesmrviewerdialog.h"
    18 #include "cesmrviewerdialog.h"
    20 
       
    21 #include <data_caging_path_literals.hrh>
       
    22 #include <esmrgui.rsg>
       
    23 #include <esmrpolicies.rsg>
       
    24 #include <eikenv.h>
       
    25 #include <eikappui.h>
       
    26 #include <avkon.hrh>
       
    27 #include <MAgnEntryUi.h>
       
    28 #include <eikmenup.h>
       
    29 #include <calentry.h>
       
    30 #include <apgtask.h>
       
    31 #include <apgcli.h>
       
    32 #include <AknDef.h>
       
    33 #include <AknUtils.h>
       
    34 #include <StringLoader.h>
       
    35 #include <akntitle.h>
       
    36 #include <eikspane.h>
       
    37 #include <e32keys.h>
       
    38 #include <AiwServiceHandler.h>
       
    39 #include <featmgr.h>
       
    40 #include <bldvariant.hrh>
       
    41 #include <akntoolbar.h>
       
    42 #include <aknappui.h>
       
    43 #include <aknViewAppUi.h>
       
    44 #include <aknview.h>
       
    45 #include <eikcolib.h>
       
    46 #include <aknbutton.h>
       
    47 #include <aknnavi.h>
       
    48 #include <aknnavide.h>
       
    49 #include <msvuids.h>
       
    50 //</cmail>
       
    51 #include <featmgr.h>
       
    52 //</cmail>
       
    53 #include <cmrmailboxutils.h>
       
    54 
       
    55 #include "cesmrpolicy.h"
    19 #include "cesmrpolicy.h"
    56 #include "esmrdef.h"
    20 #include "esmrdef.h"
    57 #include "cesmrpolicymanager.h"
    21 #include "cesmrpolicymanager.h"
    58 #include "cesmrurlparserplugin.h"
    22 #include "cesmrurlparserplugin.h"
    59 #include "esmricalvieweropcodes.hrh"
    23 #include "esmricalvieweropcodes.hrh"
    60 #include "tesmrinputparams.h"
    24 #include "tesmrinputparams.h"
    61 #include "cesmrattachmentinfo.h"
       
    62 #include "cesmrview.h"
    25 #include "cesmrview.h"
    63 #include "esmrgui.hrh"
    26 #include "esmrgui.hrh"
    64 #include "cesmrfield.h"
    27 #include "cesmrfield.h"
    65 #include "cesmrviewerfieldstorage.h"
    28 #include "cesmrviewerfieldstorage.h"
    66 #include "esmrentryhelper.h"
    29 #include "esmrentryhelper.h"
    76 #include "cesmruifactory.h"
    39 #include "cesmruifactory.h"
    77 #include "cesmrlocationpluginhandler.h"
    40 #include "cesmrlocationpluginhandler.h"
    78 #include "cesmrfeaturesettings.h"
    41 #include "cesmrfeaturesettings.h"
    79 #include "esmrconfig.hrh"
    42 #include "esmrconfig.hrh"
    80 #include "mesmrfieldevent.h"
    43 #include "mesmrfieldevent.h"
    81 
    44 #include "cmrtoolbar.h"
    82 #include "cfsmailbox.h"
    45 #include "cesmrlistquery.h"
       
    46 #include "mmrinfoprovider.h"
       
    47 #include "cmrfocusstrategyviewer.h"
       
    48 #include "cesmrtitlepanehandler.h"
       
    49 
       
    50 #include <data_caging_path_literals.hrh>
       
    51 #include <esmrgui.rsg>
       
    52 #include <esmrpolicies.rsg>
       
    53 #include <aknnotewrappers.h>
       
    54 #include <eikenv.h>
       
    55 #include <eikappui.h>
       
    56 #include <avkon.hrh>
       
    57 #include <magnentryui.h>
       
    58 #include <eikmenup.h>
       
    59 #include <calentry.h>
       
    60 #include <apgtask.h>
       
    61 #include <apmstd.h>
       
    62 #include <apgcli.h>
       
    63 #include <akndef.h>
       
    64 #include <aknutils.h>
       
    65 #include <stringloader.h>
       
    66 #include <eikspane.h>
       
    67 #include <e32keys.h>
       
    68 #include <caleninterimutils2.h>
       
    69 #include <w32std.h>
       
    70 
       
    71 // DEBUG
       
    72 #include "emailtrace.h"
       
    73 #include "cesmrcaldbmgr.h"
    83 
    74 
    84 /// Unnamed namespace for local definitions
    75 /// Unnamed namespace for local definitions
    85 namespace  { // codescanner::namespace
    76 namespace  { // codescanner::namespace
    86 
    77 
    87 #ifdef _DEBUG
    78 #ifdef _DEBUG
    88 
       
    89 // Literal for viewer dialog
       
    90 _LIT( KESMRViewerDlgPanicTxt, "ESMRViewerDlg" );
       
    91 
    79 
    92 enum TESMRViewerDlgPanic
    80 enum TESMRViewerDlgPanic
    93     {
    81     {
    94     EESMRViewerDlgInvalidCommand,
    82     EESMRViewerDlgInvalidCommand,
    95     EESMRViewerDlgnvalidSeriesResult,
    83     EESMRViewerDlgnvalidSeriesResult,
    96     EESMRViewerDlgInvalidEntry
    84     EESMRViewerDlgInvalidEntry
    97     };
    85     };
    98 
    86 
    99 void Panic( TESMRViewerDlgPanic aPanic )
    87 void Panic( TESMRViewerDlgPanic aPanic )
   100     {
    88     {
   101 
    89     // Literal for viewer dialog
       
    90     _LIT( KESMRViewerDlgPanicTxt, "ESMRViewerDlg" );
   102     User::Panic( KESMRViewerDlgPanicTxt, aPanic );
    91     User::Panic( KESMRViewerDlgPanicTxt, aPanic );
   103     }
    92     }
   104 
    93 
   105 #endif
    94 #endif
   106 
    95 
   107 // Definition for default buffer length
    96 // Definition for default buffer length
   108 const TInt KCalDefaultBufferLen = 40;
    97 const TInt KCalDefaultBufferLen = 40;
   109 
    98 
       
    99 // VGA resolution screen size in pixels
       
   100 const TInt KVGAOneSide( 640 );
       
   101 const TInt KVGAOtherSide( 480 );
       
   102 
   110 // Calendar command parameter
   103 // Calendar command parameter
   111 _LIT16( KCalCmdDATE, "GRAPHICDAY" );
   104 _LIT16( KCalCmdDATE, "GRAPHICDAY" );
   112 
   105 
   113 // Definition for time format ("YYYY MM DD HH MM SS MMMMMM" - 26)
   106 // Definition for time format ("YYYY MM DD HH MM SS MMMMMM" - 26)
   114 _LIT( KCalCmdTimeFormat, "%F %Y %M %D %H %T %S %C" );
   107 _LIT( KCalCmdTimeFormat, "%F %Y %M %D %H %T %S %C" );
   115 
   108 
   116 // Definition for calendar application UID
   109 // Definition for calendar application UID
   117 const TUid KCalendarAppUID = { KUidCalendarApplication };
   110 const TUid KCalendarAppUID = { KUidCalendarApplication };
   118 
   111 
   119 // Defs for prefix
       
   120 _LIT( KMailtoMatchPattern, "mailto:*" ); // these are never localized
       
   121 const TInt KMailtoLength = 7; // "mailto:" length
       
   122 
       
   123 
       
   124 // ======== LOCAL FUNCTIONS ========
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // Set empty buttons to toolbar.
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 void SetEmptyButtonsL( CAknToolbar* aToolbar )
       
   131     {
       
   132     aToolbar->AddItemL( CAknButton::NewL(), EAknCtButton, EESMRCmdUndefined, 0, 0 );
       
   133     aToolbar->AddItemL( CAknButton::NewL(), EAknCtButton, EESMRCmdUndefined, 0, 1 );
       
   134     aToolbar->AddItemL( CAknButton::NewL(), EAknCtButton, EESMRCmdUndefined, 0, 2 );
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // Set buttons for responding to meeting request to toolbar.
       
   139 // ---------------------------------------------------------------------------
       
   140 //
       
   141 void SetResponseButtonsL( CAknToolbar* aToolbar )
       
   142     {
       
   143     CAknButton* buttonAccept = CAknButton::NewLC();
       
   144     buttonAccept->ConstructFromResourceL( R_ACCEPT_BUTTON );
       
   145     aToolbar->AddItemL( buttonAccept, EAknCtButton, EESMRCmdAcceptMR, 0, 0 );
       
   146     CleanupStack::Pop( buttonAccept );
       
   147     
       
   148     CAknButton* buttonTentative = CAknButton::NewLC();
       
   149     buttonTentative->ConstructFromResourceL( R_TENTATIVE_BUTTON );
       
   150     aToolbar->AddItemL( buttonTentative, EAknCtButton, EESMRCmdTentativeMR, 0, 1 );
       
   151     CleanupStack::Pop( buttonTentative );
       
   152 
       
   153     CAknButton* buttonDecline = CAknButton::NewLC();
       
   154     buttonDecline->ConstructFromResourceL( R_DECLINE_BUTTON );
       
   155     aToolbar->AddItemL( buttonDecline, EAknCtButton, EESMRCmdDeclineMR, 0, 2 );
       
   156     CleanupStack::Pop( buttonDecline );
       
   157     }
       
   158 
   112 
   159 /**
   113 /**
   160  * Sets recurrence modification rule to entry. Rule is queried
   114  * Sets recurrence modification rule to entry. Rule is queried
   161  * from the user. Invalid result will cause panic.
   115  * from the user. Invalid result will cause panic.
   162  * @param aEntry Reference to meeting request.
   116  * @param aEntry Reference to meeting request.
   186             case EESMRThisOccurence:
   140             case EESMRThisOccurence:
   187                 {
   141                 {
   188                 aEntry.SetModifyingRuleL(
   142                 aEntry.SetModifyingRuleL(
   189                         MESMRMeetingRequestEntry::EESMRThisOnly );
   143                         MESMRMeetingRequestEntry::EESMRThisOnly );
   190                 break;
   144                 break;
   191                 }                
   145                 }
   192             case EESMRSeries:
   146             case EESMRSeries:
   193                 {
   147                 {
   194                 aEntry.SetModifyingRuleL(
   148                 aEntry.SetModifyingRuleL(
   195                         MESMRMeetingRequestEntry::EESMRAllInSeries );
   149                         MESMRMeetingRequestEntry::EESMRAllInSeries );
   196                 break;
   150                 break;
   197                 }                
   151                 }
   198             default:
   152             default:
   199             	{
   153             	{
   200                 __ASSERT_DEBUG( EFalse, 
   154                 __ASSERT_DEBUG( EFalse,
   201                 		Panic(EESMRViewerDlgnvalidSeriesResult) );
   155                 		Panic(EESMRViewerDlgnvalidSeriesResult) );
   202                 break;
   156                 break;
   203             	}
   157             	}
   204             }
   158             }
   205         }
   159         }
   216 // ---------------------------------------------------------------------------
   170 // ---------------------------------------------------------------------------
   217 // CESMRViewerDialog::CESMRViewerDialog
   171 // CESMRViewerDialog::CESMRViewerDialog
   218 // ---------------------------------------------------------------------------
   172 // ---------------------------------------------------------------------------
   219 //
   173 //
   220 CESMRViewerDialog::CESMRViewerDialog(
   174 CESMRViewerDialog::CESMRViewerDialog(
   221         MESMRCalEntry& aEntry,
   175         MMRInfoProvider& aInfoProvider,
   222         MAgnEntryUiCallback& aCallback  ) :
   176         MAgnEntryUiCallback& aCallback  ) :
   223     iEntry( aEntry ),
       
   224     iCallback( aCallback ),
   177     iCallback( aCallback ),
   225     iClearToolbar( EFalse )
   178     iInfoProvider( aInfoProvider )
   226     {
   179     {
   227     FUNC_LOG;
   180     FUNC_LOG;
   228     // Do nothing
   181     // Do nothing
   229     }
   182     }
   230 
   183 
   233 // ---------------------------------------------------------------------------
   186 // ---------------------------------------------------------------------------
   234 //
   187 //
   235 CESMRViewerDialog::~CESMRViewerDialog()
   188 CESMRViewerDialog::~CESMRViewerDialog()
   236     {
   189     {
   237     FUNC_LOG;
   190     FUNC_LOG;
   238 
   191     iESMRStatic.Close();
   239     if ( iIdleNaviEventRunner )
   192 
   240         {
   193     if ( iTitlePane )
   241         iIdleNaviEventRunner->Cancel();
   194         {
   242         delete iIdleNaviEventRunner;
   195         // Returns the previous title back to titlepane
       
   196         iTitlePane->Rollback();
       
   197         delete iTitlePane;
   243         }
   198         }
   244     
   199     
   245     iESMRStatic.Close();
       
   246 
       
   247     if ( iFeatureManagerInitialized )
       
   248         {
       
   249         FeatureManager::UnInitializeLib();
       
   250         }
       
   251 
       
   252     if ( iServiceHandler )
       
   253         {
       
   254         iServiceHandler->DetachMenu( R_MRVIEWER_MENUBAR, R_PS_AIW_INTEREST );
       
   255         delete iServiceHandler;
       
   256         }
       
   257 
       
   258     delete iESMRSendUI;
   200     delete iESMRSendUI;
   259 
       
   260     delete iLocationPluginHandler;
   201     delete iLocationPluginHandler;
   261     
       
   262     delete iFeatures;
   202     delete iFeatures;
   263     
       
   264     TRAP_IGNORE( ClearToolbarL() );
       
   265 
   203 
   266     // iView is deleted by framework because it uses the
   204     // iView is deleted by framework because it uses the
   267     // custom control mechanism.
   205     // custom control mechanism.
       
   206     delete iToolbar;
       
   207     delete iFocusStrategy;
   268     }
   208     }
   269 
   209 
   270 // ---------------------------------------------------------------------------
   210 // ---------------------------------------------------------------------------
   271 // CESMRViewerDialog::NewL
   211 // CESMRViewerDialog::NewL
   272 // ---------------------------------------------------------------------------
   212 // ---------------------------------------------------------------------------
   273 //
   213 //
   274 EXPORT_C CESMRViewerDialog* CESMRViewerDialog::NewL(
   214 EXPORT_C CESMRViewerDialog* CESMRViewerDialog::NewL(
   275         CESMRPolicy* aPolicy,
   215         MMRInfoProvider& aInfoProvider,
   276         MESMRCalEntry& aEntry,
       
   277         MAgnEntryUiCallback& aCallback )
   216         MAgnEntryUiCallback& aCallback )
   278     {
   217     {
   279     FUNC_LOG;
   218     FUNC_LOG;
   280     CESMRViewerDialog* self =
   219     CESMRViewerDialog* self =
   281         new (ELeave) CESMRViewerDialog( aEntry, aCallback );
   220         new (ELeave) CESMRViewerDialog( aInfoProvider, aCallback );
   282     CleanupStack::PushL( self );
   221     CleanupStack::PushL( self );
   283     self->ConstructL( aPolicy );
   222     self->ConstructL();
   284     CleanupStack::Pop( self );
   223     CleanupStack::Pop( self );
   285     return self;
   224     return self;
   286     }
   225     }
   287 
   226 
   288 // ---------------------------------------------------------------------------
   227 // ---------------------------------------------------------------------------
   289 // CESMRViewerDialog::ConstructL
   228 // CESMRViewerDialog::ConstructL
   290 // ---------------------------------------------------------------------------
   229 // ---------------------------------------------------------------------------
   291 //
   230 //
   292 void CESMRViewerDialog::ConstructL(
   231 void CESMRViewerDialog::ConstructL()
   293         CESMRPolicy* aPolicy )
   232     {
   294     {
   233     FUNC_LOG;
   295     FUNC_LOG;
       
   296     
       
   297     iIdleNaviEventRunner = CIdle::NewL( CActive::EPriorityStandard );
       
   298     
       
   299     iPolicy = aPolicy;
       
   300     iESMRStatic.ConnectL();
   234     iESMRStatic.ConnectL();
   301 
   235 
   302     CAknDialog::ConstructL( R_MRVIEWER_MENUBAR );
   236     CAknDialog::ConstructL( R_MRVIEWER_MENUBAR );
   303 
   237 
       
   238     // Class disables avkon toolbar by default, which
       
   239     // we want in case of non-MR
       
   240     iToolbar = CMRToolbar::NewL();
       
   241 
   304     TRect clientRect;
   242     TRect clientRect;
   305     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, clientRect );
   243     AknLayoutUtils::LayoutMetricsRect( 
       
   244             AknLayoutUtils::EMainPane, 
       
   245             clientRect );
   306 
   246 
   307     TBool responseReady(EFalse);
   247     TBool responseReady(EFalse);
       
   248     MESMRCalEntry* calEntry = iInfoProvider.EntryL();
   308     MESMRMeetingRequestEntry* mrEntry = NULL;
   249     MESMRMeetingRequestEntry* mrEntry = NULL;
   309     if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == iEntry.Type() )
   250     if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == calEntry->Type() )
   310         {
   251         {
   311         // This is meeting request
   252         // This is meeting request
   312         mrEntry = static_cast<MESMRMeetingRequestEntry*>( &iEntry );
   253         mrEntry = static_cast<MESMRMeetingRequestEntry*>( calEntry );
   313         responseReady = mrEntry->IsSentL();
   254         responseReady = mrEntry->IsSentL();
       
   255 
       
   256         // Change the status pane layout to remove navi pane
       
   257         CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
       
   258         sp->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT);
   314         }
   259         }
   315 
   260 
   316     iESMRSendUI = CESMRSendUI::NewL(EESMRCmdSendAs);
   261     iESMRSendUI = CESMRSendUI::NewL(EESMRCmdSendAs);
   317 
       
   318     FeatureManager::InitializeLibL();
       
   319     iFeatureManagerInitialized = ETrue;
       
   320 
   262 
   321     CESMRViewerFieldStorage* storage =
   263     CESMRViewerFieldStorage* storage =
   322             CESMRViewerFieldStorage::NewL(
   264             CESMRViewerFieldStorage::NewL(
   323                     aPolicy,
   265                     iInfoProvider.PolicyProvider().CurrentPolicy(),
   324                     this,
   266                     this,
   325                     responseReady,
   267                     responseReady,
   326                     *this );
   268                     *this );
   327 
   269 
       
   270     // Create focus strategy
       
   271     iFocusStrategy = CMRFocusStrategyViewer::NewL( *storage );
       
   272     // Give the strategy to the iView
       
   273 
   328     // storage ownership is transferred to CESMRView
   274     // storage ownership is transferred to CESMRView
   329     iView = CESMRView::NewL(storage, iEntry, clientRect );
   275     iView = CESMRView::NewL( 
   330 
   276             storage, 
   331     if ( iEntry.Entry().SummaryL().Length() == 0 )
   277             *calEntry, 
       
   278             clientRect, 
       
   279             *iFocusStrategy, 
       
   280             *iToolbar,
       
   281             this );
       
   282     
       
   283     iView->SetViewMode( EESMRViewMR );
       
   284 
       
   285     if ( calEntry->Entry().SummaryL().Length() == 0 )
   332         {
   286         {
   333         // if no title, set unnamed text:
   287         // if no title, set unnamed text:
   334         HBufC* title = StringLoader::LoadLC ( R_QTN_MEET_REQ_CONFLICT_UNNAMED,
   288         HBufC* title = StringLoader::LoadLC ( R_QTN_MEET_REQ_CONFLICT_UNNAMED,
   335                                               iCoeEnv );
   289                                               iCoeEnv );
   336         iView->SetTitleL( *title );
   290         iView->SetTitleL( *title );
   337         CleanupStack::PopAndDestroy( title );
   291         CleanupStack::PopAndDestroy( title );
   338         }
   292         }
   339     else
   293     else
   340         {
   294         {
   341         iView->SetTitleL( iEntry.Entry().SummaryL() );
   295         iView->SetTitleL( calEntry->Entry().SummaryL() );
   342         }
   296         }
   343 
   297 
   344     TInt titleStringId = -1;
   298     TInt titleStringId = -1;
   345     switch ( iEntry.Type() )
   299     switch ( calEntry->Type() )
   346         {
   300         {
       
   301         case MESMRCalEntry::EESMRCalEntryMeetingRequest:
       
   302         	{
       
   303             titleStringId = R_QTN_MEET_REQ_TITLE_MEETING;
       
   304             break;
       
   305         	}
   347         case MESMRCalEntry::EESMRCalEntryMeeting:
   306         case MESMRCalEntry::EESMRCalEntryMeeting:
   348         	{
   307         	{
   349             titleStringId = R_QTN_CALENDAR_TITLE_MEETING;
   308             titleStringId = R_QTN_CALENDAR_TITLE_MEETING;
   350             break;
   309             break;
   351         	}
   310         	}
   356         	}
   315         	}
   357         case MESMRCalEntry::EESMRCalEntryMemo:
   316         case MESMRCalEntry::EESMRCalEntryMemo:
   358         	{
   317         	{
   359             titleStringId = R_QTN_CALENDAR_TITLE_MEMO;
   318             titleStringId = R_QTN_CALENDAR_TITLE_MEMO;
   360             break;
   319             break;
   361         	}        
   320         	}
   362         case MESMRCalEntry::EESMRCalEntryAnniversary:
   321         case MESMRCalEntry::EESMRCalEntryAnniversary:
   363         	{
   322         	{
   364             titleStringId = R_QTN_CALENDAR_TITLE_ANNIVERSARY;
   323             titleStringId = R_QTN_CALENDAR_TITLE_ANNIVERSARY;
   365             break;
   324             break;
   366         	}
   325         	}
   367         case MESMRCalEntry::EESMRCalEntryReminder: // Fall through        	
   326         case MESMRCalEntry::EESMRCalEntryReminder: // Fall through
   368         case MESMRCalEntry::EESMRCalEntryMeetingRequest: // Fall through
       
   369         default:
   327         default:
   370         	{
   328         	{
   371             break;
   329             break;
   372         	}
   330         	}
   373         }
   331         }
   374     if ( titleStringId != -1 )
   332     if ( titleStringId != -1 )
   375         {
   333         {
   376         CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
   334         if( !iTitlePane )
   377         CAknTitlePane* tp = 
   335             {
   378 			static_cast<CAknTitlePane*>( 
   336             iTitlePane = CESMRTitlePaneHandler::NewL( *iEikonEnv );
   379 					sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle)) );
   337             }
       
   338     
   380         HBufC* titleText = StringLoader::LoadLC( titleStringId, iCoeEnv );
   339         HBufC* titleText = StringLoader::LoadLC( titleStringId, iCoeEnv );
   381         tp->SetTextL( *titleText );
   340         iTitlePane->SetNewTitle( titleText );
   382         CleanupStack::PopAndDestroy( titleText );
   341         CleanupStack::PopAndDestroy( titleText );
   383         }
   342         }
   384 
   343 
   385 
       
   386     iFeatures = CESMRFeatureSettings::NewL();
   344     iFeatures = CESMRFeatureSettings::NewL();
   387     if ( iFeatures->FeatureSupported(
       
   388             CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
       
   389         {
       
   390         iMenuBar->SetContextMenuTitleResourceId( R_MR_VIEWER_CONTEXT_MENU );
       
   391         }
       
   392     
       
   393     // start to observe navigation decorator
       
   394     CEikStatusPane* sp =
       
   395         static_cast<CEikAppUiFactory*>( 
       
   396                 iEikonEnv->AppUiFactory() )->StatusPane();
       
   397 
       
   398     CAknNavigationControlContainer* naviPane =
       
   399         static_cast<CAknNavigationControlContainer*>( 
       
   400                 sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   401 
       
   402     if ( naviPane )
       
   403         {
       
   404         iESMRNaviDecorator = naviPane->Top();
       
   405 
       
   406         if ( iESMRNaviDecorator )
       
   407             {
       
   408             iESMRNaviDecorator->SetNaviDecoratorObserver( this );
       
   409             }
       
   410         }
       
   411         
       
   412     
       
   413     //start service handler and add the interests of this class
       
   414     iServiceHandler = CAiwServiceHandler::NewL();
       
   415     iServiceHandler->AttachL( R_PS_AIW_INTEREST );
       
   416     }
   345     }
   417 
   346 
   418 // ---------------------------------------------------------------------------
   347 // ---------------------------------------------------------------------------
   419 // CESMRViewerDialog::ActivateL
   348 // CESMRViewerDialog::ActivateL
   420 // ---------------------------------------------------------------------------
   349 // ---------------------------------------------------------------------------
   422 void CESMRViewerDialog::ActivateL()
   351 void CESMRViewerDialog::ActivateL()
   423     {
   352     {
   424     FUNC_LOG;
   353     FUNC_LOG;
   425     iView->InternalizeL();
   354     iView->InternalizeL();
   426     CAknDialog::ActivateL();
   355     CAknDialog::ActivateL();
       
   356 
       
   357     // Needs to be constructed here
       
   358     ConstructToolbarL();
       
   359     
       
   360     switch ( iInfoProvider.EntryL()->Type() )
       
   361     	{
       
   362     	case MESMRCalEntry::EESMRCalEntryMeetingRequest:
       
   363     		{
       
   364     		iView->InitialScrollL();
       
   365 
       
   366             MESMRMeetingRequestEntry* entry =
       
   367                 static_cast<MESMRMeetingRequestEntry*>( 
       
   368                         iInfoProvider.EntryL() );
       
   369     		
       
   370     		if ( entry->IsOpenedFromMail() )
       
   371     		    {
       
   372                 iView->SetNaviArrowStatus(
       
   373                                  iCallback.IsCommandAvailable(
       
   374                                         EESMRCmdMailPreviousMessage ),
       
   375                                  iCallback.IsCommandAvailable(
       
   376                                         EESMRCmdMailNextMessage ) );
       
   377     		    }
       
   378 
       
   379     		}
       
   380 
       
   381         case MESMRCalEntry::EESMRCalEntryMeeting:
       
   382         case MESMRCalEntry::EESMRCalEntryMemo:
       
   383         case MESMRCalEntry::EESMRCalEntryAnniversary:
       
   384         case MESMRCalEntry::EESMRCalEntryTodo:
       
   385     	case MESMRCalEntry::EESMRCalEntryReminder: // Fall through
       
   386     	default:
       
   387     		break;
       
   388     	}
   427     }
   389     }
   428 
   390 
   429 // ---------------------------------------------------------------------------
   391 // ---------------------------------------------------------------------------
   430 // CESMRViewerDialog::PreLayoutDynInitL
   392 // CESMRViewerDialog::PreLayoutDynInitL
   431 // ---------------------------------------------------------------------------
   393 // ---------------------------------------------------------------------------
   448         TEventCode aType)
   410         TEventCode aType)
   449     {
   411     {
   450     FUNC_LOG;
   412     FUNC_LOG;
   451     TKeyResponse response( EKeyWasNotConsumed );
   413     TKeyResponse response( EKeyWasNotConsumed );
   452     if ( aEvent.iCode != EKeyEscape && !MenuShowing() )
   414     if ( aEvent.iCode != EKeyEscape && !MenuShowing() )
   453         {
   415     	{
   454         response = iView->OfferKeyEventL( aEvent, aType );
   416     	response = iView->OfferKeyEventL( aEvent, aType );
   455         }
   417     	}
   456 
   418 
   457     if ( response == EKeyWasNotConsumed )
   419     if ( response == EKeyWasNotConsumed )
   458         {
   420         {
   459         switch (aEvent.iScanCode)
   421         switch (aEvent.iScanCode)
   460             {
   422             {
   461             case EStdKeyLeftArrow:
   423             case '4':
   462                 if ( aType == EEventKey )
   424                 {
   463                     {
   425                 response = EKeyWasConsumed;
   464                     response = EKeyWasConsumed;
   426                 ProcessCommandL(EESMRCmdMailPreviousMessage);
   465                     if ( iCallback.IsCommandAvailable(
       
   466                             EESMRCmdMailPreviousMessage ) )
       
   467                         {
       
   468                         ProcessCommandL( EESMRCmdMailPreviousMessage );
       
   469                         }
       
   470                     }
       
   471                 break;
   427                 break;
   472             case EStdKeyRightArrow:
   428                 }
   473                 if ( aType == EEventKey )
   429             case '6':
   474                     {
   430                 {
   475                     response = EKeyWasConsumed;
   431                 response = EKeyWasConsumed;
   476                     if ( iCallback.IsCommandAvailable(
   432                 ProcessCommandL(EESMRCmdMailNextMessage);
   477                             EESMRCmdMailNextMessage ) )
       
   478                         {
       
   479                         ProcessCommandL( EESMRCmdMailNextMessage );
       
   480                         }
       
   481                     }
       
   482                 break;
   433                 break;
       
   434                 }
   483             default:
   435             default:
       
   436                 {
   484                 response = CAknDialog::OfferKeyEventL( aEvent, aType );
   437                 response = CAknDialog::OfferKeyEventL( aEvent, aType );
   485                 break;
   438                 break;
       
   439                 }
   486             }
   440             }
   487         }
   441         }
   488 
   442 
   489     return response;
   443     return response;
   490     }
   444     }
   491 
   445 
   492 
       
   493 // ---------------------------------------------------------------------------
   446 // ---------------------------------------------------------------------------
   494 // CESMRViewerDialog::ProcessCommandL
   447 // CESMRViewerDialog::ProcessCommandL
   495 // ---------------------------------------------------------------------------
   448 // ---------------------------------------------------------------------------
   496 //
   449 //
   497 void CESMRViewerDialog::ProcessCommandL( TInt aCommand )
   450 void CESMRViewerDialog::ProcessCommandL( TInt aCommand )
   498     {
   451     {
   499     FUNC_LOG;
   452     FUNC_LOG;
       
   453 
   500     TRAPD( err, DoProcessCommandL( aCommand ) );
   454     TRAPD( err, DoProcessCommandL( aCommand ) );
   501     if ( err != KErrNone &&
   455     if ( err != KErrNone &&
   502          err != KErrCancel &&
   456          err != KErrCancel &&
   503          err != KErrArgument )
   457          err != KErrArgument )
   504         {
   458         {
   512 //
   466 //
   513 void CESMRViewerDialog::DoProcessCommandL( TInt aCommand )
   467 void CESMRViewerDialog::DoProcessCommandL( TInt aCommand )
   514     {
   468     {
   515     FUNC_LOG;
   469     FUNC_LOG;
   516     CAknDialog::ProcessCommandL( aCommand );
   470     CAknDialog::ProcessCommandL( aCommand );
   517 
       
   518     switch ( aCommand )
   471     switch ( aCommand )
   519         {
   472         {
   520         case EESMRCmdPrint: // Fall through
       
   521         case EESMRCmdPrint_Reserved1: // Fall through
       
   522         case EESMRCmdPrint_Reserved2: // Fall through
       
   523         case EESMRCmdPrint_Reserved3: // Fall through
       
   524         case EESMRCmdPrint_Reserved4:
       
   525             {
       
   526             this->MakeVisible(EFalse); 
       
   527             HandlePrintCommandL(aCommand);
       
   528             this->MakeVisible(ETrue); 
       
   529             break;
       
   530             }
       
   531         case EESMRCmdSendAs:
   473         case EESMRCmdSendAs:
   532             {
   474             {
   533             SendCalendarEntryL(aCommand);
   475             SendCalendarEntryL(aCommand);
   534             break;
   476             break;
   535             }
   477             }
   536 
   478 
       
   479         case EESMRCmdSendMR: //Fall through
       
   480         case EESMRCmdSendMRUpdate:
       
   481             {
       
   482             TInt ret( KErrGeneral );
       
   483             ret = iCallback.ProcessCommandWithResultL ( aCommand );
       
   484 
       
   485             if ( ret == KErrNone )
       
   486                 {
       
   487                 TryExitL ( EAknSoftkeyClose );
       
   488                 }
       
   489             break;
       
   490             }
   537         // pass-through all calentryui related command to call back
   491         // pass-through all calentryui related command to call back
   538         case EESMRCmdCalEntryUISend: // Fall through
   492         case EESMRCmdCalEntryUISend: // Fall through
   539         case EESMRCmdCalEntryUIAddParticipants: // Fall through
   493         case EESMRCmdCalEntryUIAddParticipants: // Fall through
   540         case EESMRCmdCalEntryUISave: // Fall through
   494         case EESMRCmdCalEntryUISave: // Fall through
   541             {
   495             {
   542             User::LeaveIfError( 
   496             User::LeaveIfError(
   543             	iCallback.ProcessCommandWithResultL( aCommand ));
   497             	iCallback.ProcessCommandWithResultL( aCommand ));
   544             break;
   498             break;
   545             }            
   499             }
   546         case EESMRCmdCalEntryUIDelete:
   500 
   547             {
   501         // EEikBidCancel is called when Red End key is pressed or
   548             if (!(iCallback.ProcessCommandWithResultL(aCommand) == KErrCancel))
       
   549                 {
       
   550                 TryExitL( EAknSoftkeyClose );
       
   551                 }
       
   552             break;
       
   553             }            
       
   554         // EEikBidCancel is called when Red End key is pressed or 
       
   555         // application is killed via Swap Window
   502         // application is killed via Swap Window
   556         case EEikBidCancel: // Fall through
   503         case EEikBidCancel: // Fall through
   557         case EAknSoftkeyClose: // Fall through
   504         case EAknSoftkeyClose: // Fall through
   558         case EAknCmdExit:
   505         case EAknCmdExit:
   559         	{
   506         	{
   563         case EAknSoftkeySelect: // Fall through
   510         case EAknSoftkeySelect: // Fall through
   564             {
   511             {
   565             iView->ProcessEditorCommandL( aCommand );
   512             iView->ProcessEditorCommandL( aCommand );
   566             break;
   513             break;
   567             }
   514             }
   568         case EESMRCmdEdit: // Fall through
   515         case EESMRCmdEdit:              // Fall through
   569         case EESMRCmdEditLocal: // Fall through
   516         case EESMRCmdEditLocal:         // Fall through
   570         case EESMRCmdDeleteMR: // Fall through
   517         case EESMRCmdDeleteMR:          // Fall through
   571         case EESMRCmdCalEntryUIEdit:
   518         case EESMRCmdCalEntryUIEdit:    // Fall through
   572             {
   519         case EESMRCmdCalEntryUIDelete:
   573             TBool closeDialog = HandleCommandForRecurrentEventL( aCommand );
   520             {
       
   521             TBool closeDialog = HandleCommandForEventL( aCommand );
   574             if ( closeDialog )
   522             if ( closeDialog )
   575                 {
   523                 {
   576                 TryExitL( EAknSoftkeyClose );
   524                 TryExitL( EAknSoftkeyClose );
   577                 }
   525                 }
   578             break;
   526             break;
   579             }
   527             }
       
   528 
   580         case EESMRCmdReply: // Fall through
   529         case EESMRCmdReply: // Fall through
   581         case EESMRCmdReplyAll:
   530         case EESMRCmdReplyAll:
   582             {
   531             {
   583             User::LeaveIfError( 
   532             User::LeaveIfError(
   584             		iCallback.ProcessCommandWithResultL( aCommand ));
   533             		iCallback.ProcessCommandWithResultL( aCommand ));
   585             break;
   534             break;
   586             }            
   535             }
       
   536 
   587         case EAknCmdHelp:
   537         case EAknCmdHelp:
   588             {
   538             {
   589             iView->LaunchViewerHelpL();
   539             iView->LaunchViewerHelpL();
   590             break;
   540             break;
   591             }
   541             }
   598             }
   548             }
   599         case EESMRCmdAcceptMR: // Fall through
   549         case EESMRCmdAcceptMR: // Fall through
   600         case EESMRCmdTentativeMR: // Fall through
   550         case EESMRCmdTentativeMR: // Fall through
   601         case EESMRCmdDeclineMR: // Fall through
   551         case EESMRCmdDeclineMR: // Fall through
   602             {
   552             {
   603             iView->ExternalizeL(); // no forced validation
   553             if ( !UserWantToHandleAttachmentsL() )
   604             TInt res = iCallback.ProcessCommandWithResultL( aCommand );
   554                 {
   605             if ( res != KErrCancel )
   555                 iView->ExternalizeL(); // no forced validation
   606                 {
       
   607                 TryExitL( EAknSoftkeyClose );
       
   608                 }            
       
   609             break;
       
   610             }
       
   611         case EESMRCmdRemoveFromCalendar:
       
   612             {
       
   613             iView->ExternalizeL(); // no forced validation
       
   614             TryExitL( EESMRCmdRemoveFromCalendar );
       
   615             break;
       
   616             }        
       
   617         case EESMRCmdViewCalendar:
       
   618             {
       
   619             OpenInDayModeL();
       
   620             break;
       
   621             }            
       
   622         // Email commands
       
   623         case EESMRCmdMailDelete:
       
   624             {
       
   625             TBool executeCmd( CESMRConfirmationQuery::ExecuteL(
       
   626                     CESMRConfirmationQuery::EESMRDeleteMR ) );
       
   627 
       
   628             if ( executeCmd )
       
   629                 {
       
   630                 TInt res = iCallback.ProcessCommandWithResultL( aCommand );
   556                 TInt res = iCallback.ProcessCommandWithResultL( aCommand );
   631                 if ( res != KErrCancel )
   557                 if ( res != KErrCancel )
   632                     {
   558                     {
   633                     TryExitL( EAknSoftkeyClose );
   559                     TryExitL( EAknSoftkeyClose );
   634                     }
   560                     }
   635                 }
   561                 }
   636             break;
   562             break;
   637             }            
   563             }
       
   564         case EESMRCmdRemoveFromCalendar:
       
   565             {
       
   566             iView->ExternalizeL(); // no forced validation
       
   567             TryExitL( EESMRCmdRemoveFromCalendar );
       
   568             break;
       
   569             }
       
   570         case EESMRCmdViewCalendar:
       
   571             {
       
   572             OpenInDayModeL();
       
   573             break;
       
   574             }
       
   575 
       
   576             // Email commands
       
   577         case EESMRCmdMailDelete:
       
   578             {
       
   579             TBool executeCmd( CESMRConfirmationQuery::ExecuteL(
       
   580                     CESMRConfirmationQuery::EESMRDeleteMR ) );
       
   581 
       
   582             if ( executeCmd )
       
   583                 {
       
   584                 TInt res = iCallback.ProcessCommandWithResultL( aCommand );
       
   585                 if ( res != KErrCancel )
       
   586                     {
       
   587                     TryExitL( EAknSoftkeyClose );
       
   588                     }
       
   589                 }
       
   590             break;
       
   591             }
   638         case EESMRCmdClipboardCopy:
   592         case EESMRCmdClipboardCopy:
   639             {
   593             {
   640             iView->ProcessEditorCommandL( aCommand );
   594             iView->ProcessEditorCommandL( aCommand );
   641             break;
   595             break;
   642             }            
   596             }
   643         case EESMRCmdMailPreviousMessage: // Fall through
   597         case EESMRCmdMailPreviousMessage: // Fall through
   644         case EESMRCmdMailNextMessage: // Fall through
   598         case EESMRCmdMailNextMessage: // Fall through
   645         case EESMRCmdMailForwardAsMessage: // Fall through
   599         case EESMRCmdMailForwardAsMessage: // Fall through
   646         case EESMRCmdMailMoveMessage: // Fall through
   600         case EESMRCmdMailMoveMessage: // Fall through
   647         case EESMRCmdMailCopyMessage: // Fall through
   601         case EESMRCmdMailCopyMessage: // Fall through
   648         case EESMRCmdMailMoveMessageToDrafts: // Fall through
   602         case EESMRCmdMailMoveMessageToDrafts: // Fall through
   649         case EESMRCmdMailComposeMessage: // Fall through
   603         case EESMRCmdMailComposeMessage: // Fall through
   650         case EESMRCmdMailMessageDetails:
   604         case EESMRCmdMailMessageDetails:
   651             {
   605         case EESMRCmdForwardAsMeeting: // Fall through
       
   606         case EESMRCmdForwardAsMail:
       
   607             {
       
   608             if( aCommand == EESMRCmdForwardAsMeeting &&
       
   609                     iInfoProvider.EntryL()->Entry().AttachmentCountL() > 0 )
       
   610                 {
       
   611                 // Show confirmation note if current mailbox does not
       
   612                 // support attachments and attachments exist in the entry
       
   613                 if( !SupportsMailBoxCapabilityL(
       
   614                                 MESMRBuilderExtension::
       
   615                                     EMRCFSSupportsAttachmentsInMR ) )
       
   616                     {
       
   617                     if ( !CESMRConfirmationQuery::ExecuteL(
       
   618                                        CESMRConfirmationQuery::
       
   619                                            EESMRAttachmentsNotSupported ) )
       
   620                         {
       
   621                         break;
       
   622                         }
       
   623                     }
       
   624                 }
       
   625             
       
   626             // If entry is recurring, we want to ask from user, if 
       
   627             // single instance or whole series will be forwarded
       
   628             if( aCommand == EESMRCmdForwardAsMail && 
       
   629             		iInfoProvider.EntryL()->IsRecurrentEventL() )
       
   630             	{
       
   631 				SetRecurrenceModRuleL(
       
   632 					*( iInfoProvider.EntryL() ),
       
   633 					CESMRListQuery::EESMRForwardThisOccurenceOrSeriesQuery );
       
   634             	}
       
   635 
   652             TInt res = iCallback.ProcessCommandWithResultL( aCommand );
   636             TInt res = iCallback.ProcessCommandWithResultL( aCommand );
   653             if ( res != KErrCancel )
   637             if ( res != KErrCancel )
   654                 {
   638                 {
   655                 TryExitL( aCommand );
   639                 TryExitL( aCommand );
   656                 }
   640                 }
   657             break;
   641             break;
   658             }
   642             }
   659         case EESMRCmdForward:
   643 
   660             {
   644 // <cmail>
   661             if ( iEntry.Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest )
       
   662                 {
       
   663                 // Because this is MR entry, it is safe to cast it.
       
   664                 MESMRMeetingRequestEntry* mrEntry =
       
   665                     static_cast<MESMRMeetingRequestEntry*>( &iEntry );
       
   666                 __ASSERT_DEBUG( mrEntry, Panic( EESMRViewerDlgInvalidEntry ) );
       
   667                 
       
   668                 TInt command = SupportsForwardingAsMeetingL( mrEntry, ETrue )
       
   669                     ? EESMRCmdForwardAsMeeting : EESMRCmdForwardAsMail;
       
   670                 
       
   671                 CAknToolbar* currentToolbar = static_cast<CEikAppUiFactory*>( 
       
   672                         iEikonEnv->AppUiFactory() )->CurrentFixedToolbar();
       
   673                 if ( currentToolbar )
       
   674                     {
       
   675                     currentToolbar->SetToolbarVisibility( EFalse );
       
   676                     }
       
   677                 TInt res = iCallback.ProcessCommandWithResultL( command );
       
   678                 if ( currentToolbar )
       
   679                     {
       
   680                     currentToolbar->SetToolbarVisibility( ETrue );
       
   681                     }
       
   682                 if ( res != KErrCancel )
       
   683                     {
       
   684                     TryExitL( aCommand );
       
   685                     }
       
   686                 }
       
   687             break;
       
   688             }
       
   689         case EESMRCmdDownloadManager:
   645         case EESMRCmdDownloadManager:
   690             {
   646             {
   691             TInt res = iCallback.ProcessCommandWithResultL( aCommand );
   647             TInt res = iCallback.ProcessCommandWithResultL( aCommand );
   692             if ( res != KErrCancel )
   648             if ( res != KErrCancel )
   693                 {
   649                 {
   694                 TryExitL( EAknSoftkeyClose );
   650                 TryExitL( EAknSoftkeyClose );
   695                 }
   651                 }
   696             break;
   652 // </cmail>
   697             }
   653             break;
       
   654             }
       
   655 
       
   656 // <cmail>
   698         case EESMRCmdOpenAttachment: // Fall through
   657         case EESMRCmdOpenAttachment: // Fall through
   699         case EESMRCmdOpenAttachmentView: // Fall through
   658         case EESMRCmdOpenAttachmentView: // Fall through
   700         case EESMRCmdDownloadAttachment: // Fall through
   659         case EESMRCmdDownloadAttachment: // Fall through
   701         case EESMRCmdDownloadAllAttachments: // Fall through
   660         case EESMRCmdDownloadAllAttachments: // Fall through
   702         case EESMRCmdSaveAttachment: // Fall through
   661         case EESMRCmdSaveAttachment: // Fall through
   703         case EESMRCmdSaveAllAttachments: // Fall through
   662         case EESMRCmdSaveAllAttachments: // Fall through
       
   663 // </cmail>
   704             {
   664             {
   705             TInt res = iCallback.ProcessCommandWithResultL(
   665             TInt res = iCallback.ProcessCommandWithResultL(
   706                     aCommand );
   666                     aCommand );
   707             if ( res != KErrCancel )
   667             if ( res != KErrCancel )
   708                 {
   668                 {
   709                 iExitTriggered = ETrue;
   669                 iExitTriggered = ETrue;
   710                 }
   670                 }
   711             break;
   671             break;
   712             }
   672             }
       
   673 
       
   674         /*
       
   675          * Attachment field viewer context menu commands
       
   676          */
       
   677         case EESMRViewerOpenAttachment:
       
   678         case EESMRViewerSaveAttachment:
       
   679         case EESMRViewerSaveAllAttachments:
       
   680         case EESMRViewerCancelAttachmentDownload:
       
   681             {
       
   682             iView->ProcessEditorCommandL( aCommand );
       
   683             break;
       
   684             }
       
   685 
   713         case EESMRCmdMailFlagMessage: // Fall through
   686         case EESMRCmdMailFlagMessage: // Fall through
   714         case EESMRCmdMailMarkUnread: // Fall through
   687         case EESMRCmdMailMarkUnread: // Fall through
   715         case EESMRCmdMailMarkRead:
   688         case EESMRCmdMailMarkRead:
   716             {
   689             {
   717             TInt res = iCallback.ProcessCommandWithResultL( aCommand );
   690             TInt res = iCallback.ProcessCommandWithResultL( aCommand );
   718             break;
   691             break;
   719             }
   692             }
   720         case EESMRCmdTodoMarkAsDone: // Fall through
   693         case EESMRCmdTodoMarkAsDone: // Fall through
   721         case EESMRCmdTodoMarkAsNotDone:
   694         case EESMRCmdTodoMarkAsNotDone:
   722             {
   695             {
   723             if ( iEntry.Type() == MESMRCalEntry::EESMRCalEntryTodo )
   696             if ( iInfoProvider.EntryL()->Type() == MESMRCalEntry::EESMRCalEntryTodo )
   724                 {
   697                 {
   725                 User::LeaveIfError(
   698                 User::LeaveIfError(
   726                 	iCallback.ProcessCommandWithResultL( aCommand ));
   699                 	iCallback.ProcessCommandWithResultL( aCommand ));
   727                 }
   700                 }
   728 			break;
   701 			break;
   729             } 
   702             }
   730         case EESMRCmdSearchFromMap:
   703         case EESMRCmdSearchFromMap:
   731         case EESMRCmdShowOnMap:                    
   704         case EESMRCmdShowOnMap:
   732             {
   705             {
   733             if ( iFeatures->FeatureSupported(
   706             if ( iFeatures->FeatureSupported(
   734                     CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
   707                     CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
   735                 {
   708                 {
   736                 LocationPluginHandlerL().HandleCommandL( aCommand, iEntry );
   709                 MESMRCalEntry* entry = iInfoProvider.EntryL();
       
   710                 LocationPluginHandlerL().HandleCommandL( aCommand, *entry );
   737                 iView->SetControlFocusedL( EESMRFieldLocation );
   711                 iView->SetControlFocusedL( EESMRFieldLocation );
   738                 }
   712                 }
   739             break;
   713             break;
   740 			}
   714 			}
       
   715         case EMRCmdHideAttachmentIndicator:
       
   716             {
       
   717             iView->ProcessEditorCommandL( EMRCmdHideAttachmentIndicator );
       
   718             }
       
   719             break;            
   741         default:
   720         default:
   742         	{
   721         	{
   743             if ( aCommand >= EESMRCmdActionMenuFirst && 
   722             if ( aCommand >= EESMRCmdActionMenuFirst &&
   744             	 aCommand < EESMRCmdActionMenuLast )
   723             	 aCommand < EESMRCmdActionMenuLast )
   745                 {
   724                 {
   746                 iESMRStatic.ContactMenuHandlerL().ExecuteOptionsMenuL(aCommand);
   725                 iESMRStatic.ContactMenuHandlerL().ExecuteOptionsMenuL(aCommand);
   747                 }
   726                 }
   748             else if ( aCommand == EESMRCmdActionMenuLast )
   727             else if ( aCommand == EESMRCmdActionMenuLast )
   749                 {
   728                 {
   750                 TInt res = iCallback.ProcessCommandWithResultL( 
   729                 TInt res = iCallback.ProcessCommandWithResultL(
   751 										EESMRCmdOpenAttachmentView );
   730 										EESMRCmdOpenAttachmentView );
   752                 if ( res != KErrCancel )
   731                 if ( res != KErrCancel )
   753                     {
   732                     {
   754                     iExitTriggered = ETrue;
   733                     iExitTriggered = ETrue;
   755                     }
   734                     }
   782         case EAknSoftkeyContextOptions:
   761         case EAknSoftkeyContextOptions:
   783             {
   762             {
   784             if ( iFeatures->FeatureSupported(
   763             if ( iFeatures->FeatureSupported(
   785                     CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
   764                     CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
   786                 {
   765                 {
   787                 iMenuBar->TryDisplayContextMenuBarL();
   766                 SetContextMenu();
       
   767                 ShowContextMenuL();
   788                 }
   768                 }
   789             break;
   769             break;
   790             }
   770             }
   791         case EESMRCmdEdit:
   771         case EESMRCmdEdit:
   792         case EESMRCmdEditLocal:
   772         case EESMRCmdEditLocal:
   793         case EESMRCmdCalEntryUIEdit:
   773         case EESMRCmdCalEntryUIEdit:
   794             {
   774             {
   795             res = HandleCommandForRecurrentEventL( aButtonId );
   775             res = HandleCommandForEventL( aButtonId );
   796             break;
   776             break;
   797             }            
   777             }
   798         case EAknSoftkeySelect:
   778         case EAknSoftkeySelect:
   799             {
   779             {
   800             iView->ProcessEditorCommandL( aButtonId );
   780             iView->ProcessEditorCommandL( aButtonId );
   801 
   781 
   802             if ( iExitTriggered )
   782             if ( iExitTriggered )
   803                 {
   783                 {
   804                 res = ETrue;
   784                 res = ETrue;
   805                 }
   785                 }
   806             break;
   786             break;
   807             }
   787             }
   808             
   788 // <cmail>
   809         case EESMRCmdOpenAttachmentView:
   789         case EESMRCmdOpenAttachmentView:
   810         case EESMRCmdMskOpenEmailAttachment:
   790         case EESMRCmdMskOpenEmailAttachment:
   811        	case EESMRCmdOpenAttachment:
   791        	case EESMRCmdOpenAttachment:
   812         case EESMRCmdDownloadAttachment: 
   792         case EESMRCmdDownloadAttachment:
   813             {
   793             {
   814             ProcessCommandL( aButtonId );
   794             ProcessCommandL( aButtonId );
   815             break;
   795             break;
   816             }            
   796             }
   817 
   797 // </cmail>
   818         case EESMRCmdShowAllAttendees:
   798         case EESMRCmdShowAllAttendees:
   819         case EESMRCmdShowOnMap:
   799         case EESMRCmdShowOnMap:
   820             {
   800             {
   821             iView->ProcessEditorCommandL( aButtonId );
   801             iView->ProcessEditorCommandL( aButtonId );
   822             break;
   802             break;
   823             }            
   803             }
   824         case EEikBidCancel:
   804         case EEikBidCancel:
   825             {
   805             {
   826             res = ETrue;
   806             res = ETrue;
   827             break;
   807             break;
   828             }
   808             }
   834         case EESMRCmdMailMoveMessage: // Fall through
   814         case EESMRCmdMailMoveMessage: // Fall through
   835         case EESMRCmdMailCopyMessage: // Fall through
   815         case EESMRCmdMailCopyMessage: // Fall through
   836         case EESMRCmdMailMoveMessageToDrafts: // Fall through
   816         case EESMRCmdMailMoveMessageToDrafts: // Fall through
   837         case EESMRCmdMailComposeMessage: // Fall through
   817         case EESMRCmdMailComposeMessage: // Fall through
   838         case EESMRCmdMailMessageDetails:
   818         case EESMRCmdMailMessageDetails:
   839             {
   819         case EESMRCmdRemoveFromCalendar:
   840             iClearToolbar = ETrue;
   820             {
   841             res = HandleMRExitL( aButtonId );
   821             res = HandleMRExitL( aButtonId );
   842             break;
   822             break;
   843             }            
   823             }
   844         case EESMRCmdRemoveFromCalendar:
   824             
   845         	{
       
   846         	res = iCallback.ProcessCommandWithResultL ( aButtonId );
       
   847         	break;
       
   848         	}
       
   849         default:
   825         default:
   850             {
   826             {
   851             if(iExitTriggered)
   827             if(iExitTriggered)
   852                 {
   828                 {
   853                 res = ETrue;
   829                 res = ETrue;
   854                 }
   830                 }
   855             break;
   831             break;
   856             }            
   832             }
   857         }
   833         }
   858 
   834 
   859     return res;
   835     return res;
   860     }
   836     }
   861 
   837 
   884 // ---------------------------------------------------------------------------
   860 // ---------------------------------------------------------------------------
   885 //
   861 //
   886 TInt CESMRViewerDialog::ExecuteViewLD()
   862 TInt CESMRViewerDialog::ExecuteViewLD()
   887     {
   863     {
   888     FUNC_LOG;
   864     FUNC_LOG;
   889     MakeMrGuiToolbarButtonsL();
       
   890     return ExecuteLD( R_MRVIEWER_DIALOG );
   865     return ExecuteLD( R_MRVIEWER_DIALOG );
   891     }
   866     }
   892 
   867 
   893 // ---------------------------------------------------------------------------
   868 // ---------------------------------------------------------------------------
   894 // CESMRViewerDialog::Response
   869 // CESMRViewerDialog::Response
   895 // ---------------------------------------------------------------------------
   870 // ---------------------------------------------------------------------------
   896 //
   871 //
   897 TBool CESMRViewerDialog::Response( TInt aCommand )
   872 TBool CESMRViewerDialog::Response( TInt aCommand )
   898     {
   873     {
   899     FUNC_LOG;
   874     FUNC_LOG;
       
   875 
       
   876     TBool retValue( EFalse );
   900     iExitTriggered = EFalse;
   877     iExitTriggered = EFalse;
   901     // Documentation says that this function might leave and also might
   878 
   902     // return system might error code.
   879     if ( KErrCancel != aCommand )
   903     TInt res = KErrNone;
   880         {
   904     TRAPD( error, res = iCallback.ProcessCommandWithResultL( aCommand ) );
   881         TBool handleAttachments( EFalse );
   905     if ( res != KErrCancel && error == KErrNone )
   882         TRAPD( error, handleAttachments = UserWantToHandleAttachmentsL() );
   906         {
   883 
   907         iExitTriggered = ETrue;
   884         if ( !handleAttachments )
   908         return ETrue;
   885             {
   909         }
   886             // Documentation says that this function might leave and also might
   910     return EFalse;
   887             // return system wide error code.
       
   888             TInt res = KErrNone;
       
   889             TRAP( error, res = iCallback.ProcessCommandWithResultL( aCommand ) );
       
   890             if ( res != KErrCancel && error == KErrNone )
       
   891                 {
       
   892                 iExitTriggered = ETrue;
       
   893                 retValue = ETrue;
       
   894                 }
       
   895             }
       
   896         }
       
   897     
       
   898     return retValue;
   911     }
   899     }
   912 
   900 
   913 // ---------------------------------------------------------------------------
   901 // ---------------------------------------------------------------------------
   914 // CESMRViewerDialog::ExitDialog
   902 // CESMRViewerDialog::ExitDialog
   915 // ---------------------------------------------------------------------------
   903 // ---------------------------------------------------------------------------
   919     FUNC_LOG;
   907     FUNC_LOG;
   920     // If closing does not work what can we do
   908     // If closing does not work what can we do
   921     TRAPD( error, ProcessCommandL(EAknSoftkeyClose) );
   909     TRAPD( error, ProcessCommandL(EAknSoftkeyClose) );
   922     if ( error != KErrNone )
   910     if ( error != KErrNone )
   923         {
   911         {
   924         CEikonEnv::Static()->HandleError( error );// codescanner::eikonenvstatic
   912         iCoeEnv->HandleError( error );
   925         }
   913         }
   926     }
   914     }
   927 
   915 
   928 // ---------------------------------------------------------------------------
   916 // ---------------------------------------------------------------------------
   929 // CESMRViewerDialog::ChangeReadyResponseL
   917 // CESMRViewerDialog::ChangeReadyResponseL
   932 void CESMRViewerDialog::ChangeReadyResponseL()
   920 void CESMRViewerDialog::ChangeReadyResponseL()
   933     {
   921     {
   934     FUNC_LOG;
   922     FUNC_LOG;
   935     iView->ProcessEditorCommandL( EESMRCmdEdit );
   923     iView->ProcessEditorCommandL( EESMRCmdEdit );
   936     }
   924     }
       
   925 
       
   926 // ---------------------------------------------------------------------------
       
   927 // CESMRViewerDialog::DynInitToolbarL
       
   928 // ---------------------------------------------------------------------------
       
   929 //
       
   930 void CESMRViewerDialog::DynInitToolbarL (
       
   931         TInt /*aResourceId*/,
       
   932         CAknToolbar* /*aToolbar*/ )
       
   933 	{
       
   934 	// TODO: Not implemented yet
       
   935 	}
       
   936 
       
   937 // ---------------------------------------------------------------------------
       
   938 // CESMRViewerDialog::OfferToolbarEventL
       
   939 // ---------------------------------------------------------------------------
       
   940 //
       
   941 void CESMRViewerDialog::OfferToolbarEventL( TInt aCommand )
       
   942 	{
       
   943 	ProcessCommandL( aCommand );
       
   944 	}
   937 
   945 
   938 // ---------------------------------------------------------------------------
   946 // ---------------------------------------------------------------------------
   939 // CESMRViewerDialog::DynInitMenuPaneL
   947 // CESMRViewerDialog::DynInitMenuPaneL
   940 // ---------------------------------------------------------------------------
   948 // ---------------------------------------------------------------------------
   941 //
   949 //
   942 void CESMRViewerDialog::DynInitMenuPaneL(
   950 void CESMRViewerDialog::DynInitMenuPaneL(
   943         TInt aResourceId,
   951         TInt aResourceId,
   944         CEikMenuPane* aMenuPane )
   952         CEikMenuPane* aMenuPane )
   945     {
   953     {
   946     FUNC_LOG;
   954     FUNC_LOG;
   947     if ( iServiceHandler )
   955     MESMRCalEntry* entry = iInfoProvider.EntryL();
   948         {
   956 
   949         if ( iServiceHandler->HandleSubmenuL( *aMenuPane ) )
   957     TMRMenuStyle menuStyle( EMROptionsMenu );
   950             {
       
   951             return;
       
   952             }
       
   953         }
       
   954 
   958 
   955     switch ( aResourceId )
   959     switch ( aResourceId )
   956         {
   960         {
   957         case  R_ACTION_MENU:
   961         case  R_ACTION_MENU:
   958             {
   962             {
   959             iESMRStatic.ContactMenuHandlerL().InitOptionsMenuL( aMenuPane );
   963             CESMRContactMenuHandler& handler = iESMRStatic.ContactMenuHandlerL();
       
   964             if ( handler.OptionsMenuAvailable() )
       
   965                 {
       
   966                 handler.InitOptionsMenuL( aMenuPane );
       
   967                 }
   960             break;
   968             break;
   961             }
   969             }
   962         case R_MR_VIEWER_MENU:
   970         case R_MR_VIEWER_MENU:
   963             {
   971             {
   964     	    if (FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ))
       
   965     		   {
       
   966     		   // remove help support in pf5250
       
   967     		   aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue);      
       
   968     		   }
       
   969     	    
       
   970             HandlePolicyMenuL(
   972             HandlePolicyMenuL(
   971                     aResourceId,
   973                     aResourceId,
   972                     aMenuPane );
   974                     aMenuPane );
   973     
   975 
   974             // Insert send ui menu for all other entry types than meeting request
   976             // Insert send ui menu for all other entry types than meeting request
   975             if ( iEntry.Type() != MESMRCalEntry::EESMRCalEntryMeetingRequest )
   977             if ( entry->Type() != MESMRCalEntry::EESMRCalEntryMeetingRequest )
   976                 {
   978                 {
   977                 TryInsertSendMenuL(aMenuPane);
   979                 TryInsertSendMenuL(aMenuPane);
   978                 }
   980                 }
   979             
   981 
   980             if ( iEntry.Entry().AttendeesL().Count() <= 1 )
   982             if ( entry->Entry().AttendeesL().Count() <= 1 )
   981                 {
   983                 {
   982                 aMenuPane->SetItemDimmed( EESMRCmdReplyAll, ETrue );
   984                 aMenuPane->SetItemDimmed( EESMRCmdReplyAll, ETrue );
   983                 }
   985                 }
   984     
   986 
   985             HandleDynamicMenuItemsL( aResourceId, aMenuPane );
   987             HandleDynamicMenuItemsL( aResourceId, aMenuPane );
   986 
   988 
   987             if ( FeatureManager::FeatureSupported( 
   989             break;
   988                     KFeatureIdPrintingFrameworkCalendarPlugin ) )
   990             }
   989                 {
   991         case R_FORWARD_OPTIONS:
   990                 // Initiliaze menu
   992             {
   991                 iServiceHandler->InitializeMenuPaneL(
   993             HandleForwardMenuL( aResourceId, aMenuPane );
   992                         *aMenuPane,
   994             break;
   993                         aResourceId,
   995             }
   994                         EESMRCmdPrint,
       
   995                         iServiceHandler->InParamListL() );
       
   996                 }
       
   997             else
       
   998                 {
       
   999                 aMenuPane->SetItemDimmed( EESMRCmdPrint, ETrue );            
       
  1000                 }     
       
  1001                 
       
  1002             TBool canCopyToClipboard =  iView->CanProcessEditorCommandL( EESMRCmdClipboardCopy );
       
  1003             if ( !canCopyToClipboard )
       
  1004                 {
       
  1005                 aMenuPane->SetItemDimmed( EESMRCmdClipboardCopy, ETrue );            
       
  1006                 }     
       
  1007                 
       
  1008             break;
       
  1009             }
       
  1010 
       
  1011         case R_MR_VIEWER_LOCATION_MENU:
   996         case R_MR_VIEWER_LOCATION_MENU:
  1012             {
   997             {
  1013             if ( iFeatures->FeatureSupported(
   998             menuStyle = EMRContextMenu;
  1014                     CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
   999             InitLocationMenuL( aMenuPane );
  1015                 {
  1000             break;
  1016                 TBool showOnMap =
  1001             }
  1017                     LocationPluginHandlerL().IsCommandAvailableL( EESMRCmdShowOnMap,
  1002         case R_MR_VIEWER_ATTACHMENT_MENU:
  1018                                                                   iEntry );
  1003             {
  1019                 
  1004             menuStyle = EMRContextMenu;
  1020                 aMenuPane->SetItemDimmed( EESMRCmdShowOnMap, !showOnMap );
       
  1021                 aMenuPane->SetItemDimmed( EESMRCmdSearchFromMap, showOnMap );
       
  1022                 
       
  1023                 aMenuPane->SetItemDimmed( EESMRCmdEdit,
       
  1024                                           !iPolicy->IsDefaultCommand( EESMRCmdEdit ) );
       
  1025                 aMenuPane->SetItemDimmed( EESMRCmdEditLocal,
       
  1026                                           !iPolicy->IsDefaultCommand( EESMRCmdEditLocal ) );
       
  1027                 aMenuPane->SetItemDimmed( EESMRCmdCalEntryUIEdit,
       
  1028                                           !iPolicy->IsDefaultCommand( EESMRCmdCalEntryUIEdit ) );
       
  1029                 }
       
  1030             
       
  1031             break;
  1005             break;
  1032             }
  1006             }
  1033         default:
  1007         default:
  1034             {
  1008             {
  1035             break;
  1009             break;
  1036             }
  1010             }
  1037         }
  1011         }
  1038 
  1012 
  1039     // Handles email submenu
  1013     // Handles email submenu
  1040     HandleEmailSubmenuL( aResourceId, aMenuPane );
  1014     HandleEmailSubmenuL( aResourceId, aMenuPane );
       
  1015 
       
  1016     // Handles field specific context menu
       
  1017     iView->DynInitMenuPaneL( menuStyle, aResourceId, aMenuPane );
  1041     }
  1018     }
  1042 
  1019 
  1043 // ---------------------------------------------------------------------------
  1020 // ---------------------------------------------------------------------------
  1044 // CESMRViewerDialog::HandleDynamicMenuItemsL
  1021 // CESMRViewerDialog::HandleDynamicMenuItemsL
  1045 // ---------------------------------------------------------------------------
  1022 // ---------------------------------------------------------------------------
  1048             TInt aResourceId, CEikMenuPane* aMenuPane )
  1025             TInt aResourceId, CEikMenuPane* aMenuPane )
  1049     {
  1026     {
  1050     FUNC_LOG;
  1027     FUNC_LOG;
  1051     if ( aResourceId == R_MR_VIEWER_MENU )
  1028     if ( aResourceId == R_MR_VIEWER_MENU )
  1052         {
  1029         {
  1053 	    if (FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ))
  1030         // Map and Navigation Fw support
  1054 		   {
       
  1055 		   // remove help support in pf5250
       
  1056 		   aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue);      
       
  1057 		   }
       
  1058         if ( iFeatures->FeatureSupported(
  1031         if ( iFeatures->FeatureSupported(
  1059                 CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
  1032                 CESMRFeatureSettings::EESMRUIMnFwIntegration ) &&
  1060             {
  1033              iView->IsControlVisible( EESMRFieldLocation ))
  1061             if ( !iView->IsComponentVisible( EESMRFieldLocation ))
  1034             {
  1062                 {
  1035             MESMRCalEntry* entry = iInfoProvider.EntryL();
  1063                 aMenuPane->SetItemDimmed( EESMRCmdSearchFromMap, ETrue );
  1036             TBool showOnMap = LocationPluginHandlerL().
  1064                 aMenuPane->SetItemDimmed( EESMRCmdShowOnMap, ETrue );
  1037                 IsCommandAvailableL( EESMRCmdShowOnMap, *entry );
  1065                 }
  1038             aMenuPane->SetItemDimmed( EESMRCmdSearchFromMap, showOnMap );
  1066             else 
  1039             aMenuPane->SetItemDimmed( EESMRCmdShowOnMap, !showOnMap );
  1067                 {
       
  1068                 TBool showOnMap = LocationPluginHandlerL().
       
  1069                     IsCommandAvailableL( EESMRCmdShowOnMap,
       
  1070                                          iEntry );
       
  1071                 aMenuPane->SetItemDimmed( EESMRCmdSearchFromMap, showOnMap );
       
  1072                 aMenuPane->SetItemDimmed( EESMRCmdShowOnMap, !showOnMap );
       
  1073                 }
       
  1074             }
  1040             }
  1075         else
  1041         else
  1076             {
  1042             {
  1077             aMenuPane->SetItemDimmed( EESMRCmdSearchFromMap, ETrue );
  1043             aMenuPane->SetItemDimmed( EESMRCmdSearchFromMap, ETrue );
  1078             aMenuPane->SetItemDimmed( EESMRCmdShowOnMap, ETrue );
  1044             aMenuPane->SetItemDimmed( EESMRCmdShowOnMap, ETrue );
  1079             }
  1045             }
  1080         
  1046 
  1081         // Handle Action Menu item
  1047         // Handle Action Menu item
  1082         TBool dim = !iESMRStatic.ContactMenuHandlerL().OptionsMenuAvailable();
  1048         TBool dim = !iESMRStatic.ContactMenuHandlerL().OptionsMenuAvailable();
  1083         aMenuPane->SetItemDimmed( EESMRCmdActionMenu, dim );
  1049         aMenuPane->SetItemDimmed( EESMRCmdActionMenu, dim );
  1084         aMenuPane->SetItemDimmed( EESMRCmdClipboardCopy, dim );
  1050         aMenuPane->SetItemDimmed( EESMRCmdClipboardCopy, dim );
  1085         }
  1051         }
  1091 //
  1057 //
  1092 void CESMRViewerDialog::TryInsertSendMenuL(CEikMenuPane* aMenuPane)
  1058 void CESMRViewerDialog::TryInsertSendMenuL(CEikMenuPane* aMenuPane)
  1093     {
  1059     {
  1094     FUNC_LOG;
  1060     FUNC_LOG;
  1095     TInt index(KErrNotFound);
  1061     TInt index(KErrNotFound);
  1096    
  1062 
  1097 	// Insert send menu to the next position from "editing options"
  1063 	// Insert send menu to the next position from "editing options"
  1098 	aMenuPane->ItemAndPos(EESMRCmdClipboardCopy, index);
  1064 	aMenuPane->ItemAndPos(EESMRCmdClipboardCopy, index);
  1099 	if (index == KErrNotFound)
  1065 	if (index == KErrNotFound)
  1100 		{
  1066 		{
  1101 		aMenuPane->ItemAndPos(EESMRCmdCalEntryUIDelete, index);
  1067 		aMenuPane->ItemAndPos(EESMRCmdCalEntryUIDelete, index);
  1107 	index++;
  1073 	index++;
  1108 	iESMRSendUI->DisplaySendMenuItemL(*aMenuPane, index);
  1074 	iESMRSendUI->DisplaySendMenuItemL(*aMenuPane, index);
  1109     }
  1075     }
  1110 
  1076 
  1111 // ---------------------------------------------------------------------------
  1077 // ---------------------------------------------------------------------------
       
  1078 // CESMRViewerDialog::SetContextMenu
       
  1079 // ---------------------------------------------------------------------------
       
  1080 //
       
  1081 void CESMRViewerDialog::SetContextMenu()
       
  1082     {
       
  1083     TESMREntryFieldId fieldId = iView->ClickedOrFocusedField();
       
  1084 
       
  1085     switch( fieldId )
       
  1086         {
       
  1087         case EESMRFieldViewerAttachments:
       
  1088             {
       
  1089             iContextMenuResourceId = R_MR_VIEWER_ATTACHMENT_CONTEXT_MENU;
       
  1090             }
       
  1091             break;
       
  1092 
       
  1093         default:
       
  1094             iContextMenuResourceId = R_MR_VIEWER_CONTEXT_MENU;
       
  1095             break;
       
  1096         }
       
  1097 
       
  1098     iMenuBar->SetContextMenuTitleResourceId( iContextMenuResourceId );
       
  1099     }
       
  1100 
       
  1101 // ---------------------------------------------------------------------------
  1112 // CESMRViewerDialog::OpenInDayModeL
  1102 // CESMRViewerDialog::OpenInDayModeL
  1113 // ---------------------------------------------------------------------------
  1103 // ---------------------------------------------------------------------------
  1114 //
  1104 //
  1115 void CESMRViewerDialog::OpenInDayModeL()
  1105 void CESMRViewerDialog::OpenInDayModeL()
  1116     {
  1106     {
  1125 
  1115 
  1126     // copy the 16-bit data into 8-bit buffer
  1116     // copy the 16-bit data into 8-bit buffer
  1127     HBufC8* paramBuf = HBufC8::NewLC( tail->Length() *2 );
  1117     HBufC8* paramBuf = HBufC8::NewLC( tail->Length() *2 );
  1128     TPtr8 tailBuf = paramBuf->Des();
  1118     TPtr8 tailBuf = paramBuf->Des();
  1129 
  1119 
  1130     tailBuf.Copy( 
  1120     tailBuf.Copy(
  1131     	reinterpret_cast<const TUint8*>( tail->Ptr() ), tail->Length() *2 );
  1121     	reinterpret_cast<const TUint8*>( tail->Ptr() ), tail->Length() *2 );
  1132 
  1122 
  1133     if( task.Exists() )  // Calendar already open
  1123     if( task.Exists() )  // Calendar already open
  1134         {
  1124         {
  1135 		const TUid dummyUID = { 0x0 };
  1125 		const TUid dummyUID = { 0x0 };
  1151 			cmdLine->SetTailEndL( tailBuf );
  1141 			cmdLine->SetTailEndL( tailBuf );
  1152 
  1142 
  1153 			lsSession.StartApp( *cmdLine );
  1143 			lsSession.StartApp( *cmdLine );
  1154 			CleanupStack::PopAndDestroy( cmdLine );
  1144 			CleanupStack::PopAndDestroy( cmdLine );
  1155 			}
  1145 			}
  1156 		
  1146 
  1157 		// Close lsSession
  1147 		// Close lsSession
  1158 		CleanupStack::PopAndDestroy();  // codescanner::cleanup
  1148 		CleanupStack::PopAndDestroy();  // codescanner::cleanup
  1159         }
  1149         }
  1160 	CleanupStack::PopAndDestroy( paramBuf );
  1150 	CleanupStack::PopAndDestroy( paramBuf );
  1161 	CleanupStack::PopAndDestroy( tail );
  1151 	CleanupStack::PopAndDestroy( tail );
  1167 //
  1157 //
  1168 void CESMRViewerDialog::CommandTailL(HBufC16*& aTailBuffer)
  1158 void CESMRViewerDialog::CommandTailL(HBufC16*& aTailBuffer)
  1169     {
  1159     {
  1170     FUNC_LOG;
  1160     FUNC_LOG;
  1171     // "DATE YYYY MM DD HH MM SS MMMMMM"
  1161     // "DATE YYYY MM DD HH MM SS MMMMMM"
  1172     aTailBuffer = HBufC::NewLC( KCalDefaultBufferLen ); 
  1162     aTailBuffer = HBufC::NewLC( KCalDefaultBufferLen );
  1173     TPtr tailPtr = aTailBuffer->Des();
  1163     TPtr tailPtr = aTailBuffer->Des();
  1174 
  1164 
  1175     // get the start time of entry
  1165     // get the start time of entry
  1176     CCalEntry& entry = iEntry.Entry();
  1166     CCalEntry& entry = iInfoProvider.EntryL()->Entry();
  1177     TTime startTime = entry.StartTimeL().TimeLocalL();
  1167     TTime startTime = entry.StartTimeL().TimeLocalL();
  1178 
  1168 
  1179     startTime.FormatL(tailPtr, KCalCmdTimeFormat() );
  1169     startTime.FormatL(tailPtr, KCalCmdTimeFormat() );
  1180     tailPtr.Insert( 0, KCalCmdDATE );
  1170     tailPtr.Insert( 0, KCalCmdDATE );
  1181     CleanupStack::Pop( aTailBuffer );
  1171     CleanupStack::Pop( aTailBuffer );
  1182     }
  1172     }
  1183 
  1173 
  1184 // ---------------------------------------------------------------------------
  1174 // ---------------------------------------------------------------------------
  1185 // CESMRViewerDialog::HandleCommandForRecurrentEventL
  1175 // CESMRViewerDialog::HandleCommandForEventL
  1186 // ---------------------------------------------------------------------------
  1176 // ---------------------------------------------------------------------------
  1187 //
  1177 //
  1188 TBool CESMRViewerDialog::HandleCommandForRecurrentEventL( TInt aCommand )
  1178 TBool CESMRViewerDialog::HandleCommandForEventL( TInt aCommand )
  1189     {
  1179     {
  1190     FUNC_LOG;
  1180     FUNC_LOG;
  1191     TBool closeDialog( EFalse );
  1181     TBool closeDialog( EFalse );
  1192 
  1182 
       
  1183     MESMRCalEntry* calEntry( iInfoProvider.EntryL() );
       
  1184 
  1193     switch ( aCommand )
  1185     switch ( aCommand )
  1194         {
  1186         {
  1195         case EESMRCmdEdit: //Fall through
  1187         case EESMRCmdEdit:              //Fall through
  1196         case EESMRCmdEditLocal: //Fall through
  1188         case EESMRCmdEditLocal:         //Fall through
  1197         case EESMRCmdCalEntryUIEdit:
  1189         case EESMRCmdCalEntryUIEdit:
  1198             {
  1190             {
  1199             this->MakeVisible(EFalse); 
  1191             if ( calEntry->IsRecurrentEventL() )
  1200             if ( iEntry.IsRecurrentEventL() )
       
  1201                 {
  1192                 {
  1202                 // Check is the currently viewed entry a modifying entry.
  1193                 // Check is the currently viewed entry a modifying entry.
  1203                 // MESMRCalEntry should provide this method.
  1194                 // MESMRCalEntry should provide this method.
  1204                 // if the entry is an exception to series, no query
  1195                 // if the entry is an exception to series, no query
  1205                 // should be asked in which mode the editor should be launched
  1196                 // should be asked in which mode the editor should be launched
  1206                 // in this occurance or series -mode.
  1197                 // in this occurance or series -mode.
  1207                 if ( iEntry.Entry().RecurrenceIdL().TimeUtcL() !=
  1198                 if ( calEntry->Entry().RecurrenceIdL().TimeUtcL() !=
  1208                             Time::NullTTime()   )
  1199                             Time::NullTTime()   )
  1209                     {
  1200                     {
  1210                     iEntry.SetModifyingRuleL( MESMRCalEntry::EESMRThisOnly );
  1201                     calEntry->SetModifyingRuleL( MESMRCalEntry::EESMRThisOnly );
  1211                     }
  1202                     }
  1212                 else
  1203                 else
  1213                     {
  1204                     {
  1214                     SetRecurrenceModRuleL(
  1205                     SetRecurrenceModRuleL(
  1215                         iEntry,
  1206                         *calEntry,
  1216                         CESMRListQuery::EESMROpenThisOccurenceOrSeriesQuery );
  1207                         CESMRListQuery::EESMROpenThisOccurenceOrSeriesQuery );
  1217                     }
  1208                     }
  1218                 }
  1209                 }
  1219 
  1210 
  1220             MESMRMeetingRequestEntry* entry = NULL;
  1211             MESMRMeetingRequestEntry* entry = NULL;
  1221             if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == iEntry.Type() )
  1212             if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == calEntry->Type() )
  1222                 {
  1213                 {
  1223                 entry = static_cast<MESMRMeetingRequestEntry*>(&iEntry);
  1214                 entry = static_cast<MESMRMeetingRequestEntry*>(calEntry);
  1224 
  1215 
  1225                 TESMRRole role = entry->RoleL();
  1216                 TESMRRole role = entry->RoleL();
  1226                 if ( role == EESMRRoleOrganizer )
  1217                 if ( role == EESMRRoleOrganizer )
  1227                     {
  1218                     {
  1228                     User::LeaveIfError(
  1219                     User::LeaveIfError(
  1236                     closeDialog = ETrue;
  1227                     closeDialog = ETrue;
  1237                     }
  1228                     }
  1238                 }
  1229                 }
  1239             else
  1230             else
  1240                 {
  1231                 {
  1241                 User::LeaveIfError( 
  1232                 User::LeaveIfError(
  1242                   iCallback.ProcessCommandWithResultL( EESMRCmdCalEntryUIEdit));
  1233                   iCallback.ProcessCommandWithResultL( EESMRCmdCalEntryUIEdit));
  1243                 closeDialog = ETrue;
  1234                 closeDialog = ETrue;
  1244                 }
  1235                 }
  1245             this->MakeVisible(ETrue); 
  1236             break;
  1246             break;
  1237             }
  1247             }
  1238         case EESMRCmdDeleteMR:          // Fall through
  1248         case EESMRCmdDeleteMR:
  1239         case EESMRCmdCalEntryUIDelete:
  1249             {
  1240             {
  1250             if ( iEntry.Type () == MESMRCalEntry::EESMRCalEntryMeetingRequest )
  1241             TBool okToDelete = ETrue;
  1251                 {
  1242             MESMRCalEntry* calEntry = iInfoProvider.EntryL();
  1252                 TBool okToDelete = ETrue;
  1243             if ( calEntry->IsRecurrentEventL() )
  1253 
  1244                 {
  1254                 if ( iEntry.IsRecurrentEventL() )
  1245                 SetRecurrenceModRuleL(
       
  1246                  *calEntry,
       
  1247                  CESMRListQuery::EESMRDeleteThisOccurenceOrSeriesQuery );
       
  1248                 }
       
  1249             else
       
  1250                 {
       
  1251                 if( CCalenInterimUtils2::IsMeetingRequestL( calEntry->Entry() ) )
  1255                     {
  1252                     {
  1256                     SetRecurrenceModRuleL(
  1253                     okToDelete = CESMRConfirmationQuery::ExecuteL(
  1257 					 iEntry,
  1254                             CESMRConfirmationQuery::EESMRDeleteMR );
  1258 					 CESMRListQuery::EESMRDeleteThisOccurenceOrSeriesQuery );
       
  1259                     }
  1255                     }
  1260                 else
  1256                 else
  1261                     {
  1257                     {
  1262                     okToDelete = CESMRConfirmationQuery::ExecuteL(
  1258                     okToDelete = CESMRConfirmationQuery::ExecuteL(
  1263 								CESMRConfirmationQuery::EESMRDeleteMR );
  1259                              CESMRConfirmationQuery::EESMRDeleteEntry );
  1264 
       
  1265                     }
  1260                     }
  1266 
  1261                 }
  1267                 if ( okToDelete )
  1262 
       
  1263             if ( okToDelete )
       
  1264                 {
       
  1265                 // When deleting we do not need to externalize entry
       
  1266                 TInt res = iCallback.ProcessCommandWithResultL( aCommand );
       
  1267                 if ( res != KErrCancel )
  1268                     {
  1268                     {
  1269                     // When deleting we do not need to externalize entry
  1269                     closeDialog = ETrue;
  1270                     TInt res = iCallback.ProcessCommandWithResultL( aCommand );
       
  1271                     if ( res != KErrCancel )
       
  1272                         {
       
  1273                         closeDialog = ETrue;
       
  1274                         }
       
  1275                     }
  1270                     }
  1276                 }
  1271                 }
  1277             break;
  1272             break;
  1278             }
  1273             }
  1279         default:
  1274         default:
  1295     FUNC_LOG;
  1290     FUNC_LOG;
  1296     // we don't need MenuPane in CCalSend but we need it for the API
  1291     // we don't need MenuPane in CCalSend but we need it for the API
  1297     CEikMenuPane* pane=NULL;
  1292     CEikMenuPane* pane=NULL;
  1298 
  1293 
  1299     // Show menu to user
  1294     // Show menu to user
  1300     // CCalenSend handles selection internally, so we don't 
  1295     // CCalenSend handles selection internally, so we don't
  1301     // get anything in return
  1296     // get anything in return
  1302     iESMRSendUI->DisplaySendCascadeMenuL(*pane);
  1297     iESMRSendUI->DisplaySendCascadeMenuL(*pane);
  1303 
  1298 
  1304     // Try to send
  1299     // Try to send
  1305     if (iESMRSendUI->CanSendL(aCommandId))
  1300     if (iESMRSendUI->CanSendL(aCommandId))
  1306         {
  1301         {
  1307         iESMRSendUI->SendAsVCalendarL(aCommandId, iEntry.Entry() );
  1302         MESMRCalEntry* calEntry = iInfoProvider.EntryL();
  1308         }
  1303         iESMRSendUI->SendAsVCalendarL(aCommandId, calEntry->Entry() );
  1309     }
  1304         }
  1310 
  1305     }
  1311 // ---------------------------------------------------------------------------
  1306 
  1312 // CESMRViewerDialog::HandlePrintCommandL
       
  1313 // ---------------------------------------------------------------------------
       
  1314 //
       
  1315 void CESMRViewerDialog::HandlePrintCommandL(TInt aCommand)
       
  1316     {
       
  1317     FUNC_LOG;
       
  1318     CAiwGenericParamList& inParams = iServiceHandler->InParamListL();
       
  1319 
       
  1320     // Param date
       
  1321 
       
  1322     TCalTime startTime = iEntry.Entry().StartTimeL();
       
  1323 
       
  1324     TAiwGenericParam dateParam( EGenericParamDateTime );
       
  1325     TTime activeDay = startTime.TimeUtcL();
       
  1326 
       
  1327     TAiwGenericParam calendarParam( EGenericParamCalendarItem );
       
  1328     calendarParam.Value().Set( TUid::Uid(iEntry.Entry().LocalUidL()) );
       
  1329     inParams.AppendL( calendarParam );
       
  1330 
       
  1331     // Append date param
       
  1332     dateParam.Value().Set( activeDay );
       
  1333     inParams.AppendL( dateParam );
       
  1334 
       
  1335     const TUid uid( TUid::Uid( KUidCalendarApplication ) );
       
  1336     TAiwGenericParam uidParam( EGenericParamApplication );
       
  1337     uidParam.Value().Set( uid );
       
  1338     inParams.AppendL( uidParam );
       
  1339 
       
  1340     // Execute service command with given parameters
       
  1341     iServiceHandler->ExecuteMenuCmdL( aCommand,
       
  1342                                       inParams,
       
  1343                                       iServiceHandler->OutParamListL(),
       
  1344                                       0,
       
  1345                                       NULL );
       
  1346     }
       
  1347 
  1307 
  1348 // ---------------------------------------------------------------------------
  1308 // ---------------------------------------------------------------------------
  1349 // CESMRViewerDialog::HandleEmailSubmenuL
  1309 // CESMRViewerDialog::HandleEmailSubmenuL
  1350 // ---------------------------------------------------------------------------
  1310 // ---------------------------------------------------------------------------
  1351 //
  1311 //
  1352 void CESMRViewerDialog::HandleEmailSubmenuL(
  1312 void CESMRViewerDialog::HandleEmailSubmenuL(
  1353         TInt aResourceId,
  1313         TInt aResourceId,
  1354         CEikMenuPane* aMenuPane )
  1314         CEikMenuPane* aMenuPane )
  1355     {
  1315     {
  1356     FUNC_LOG;
  1316     FUNC_LOG;
       
  1317 
       
  1318     MESMRCalEntry* calEntry = iInfoProvider.EntryL();
       
  1319 
  1357     // Insert send ui menu for all other entry types than meeting request
  1320     // Insert send ui menu for all other entry types than meeting request
  1358     if ( iEntry.Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest )
  1321     if ( calEntry->Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest )
  1359         {
  1322         {
  1360         if ( R_MRVIEWER_EMAIL_MENU == aResourceId )
  1323         if ( R_MR_VIEWER_MENU == aResourceId )
  1361             {
  1324             {
  1362             TInt menuItemCount( aMenuPane->NumberOfItemsInPane() );
  1325             const CESMRPolicy& currentPolicy(
  1363             for ( TInt i(0); i < menuItemCount; ++i )
  1326                     iInfoProvider.PolicyProvider().CurrentPolicy() );
  1364                 {
  1327             
  1365                 CEikMenuPaneItem::SData& item(
       
  1366                         aMenuPane->ItemDataByIndexL( i ) );
       
  1367                 aMenuPane->SetItemDimmed(
       
  1368                     item.iCommandId,
       
  1369                     !iCallback.IsCommandAvailable(item.iCommandId) );
       
  1370                 }
       
  1371             }
       
  1372         else if ( R_MR_VIEWER_MENU == aResourceId )
       
  1373             {
       
  1374     	    if (FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ))
       
  1375     		   {
       
  1376     		   // remove help support in pf5250
       
  1377     		   aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue);      
       
  1378     		   }
       
  1379     	                
       
  1380             TBool emailMenuDimmed( ETrue );
       
  1381             // Try insert email specific menu
       
  1382             if ( EESMRAppESEmail == iPolicy->AllowedApp() )
       
  1383                 {
       
  1384                 emailMenuDimmed = EFalse;
       
  1385                 }
       
  1386 
       
  1387             aMenuPane->SetItemDimmed(
  1328             aMenuPane->SetItemDimmed(
  1388                     EESMRCmdMailDelete,
  1329                     EESMRCmdMailDelete,
  1389                     !iCallback.IsCommandAvailable(
  1330                     !iCallback.IsCommandAvailable(
  1390                             EESMRCmdMailDelete) );
  1331                             EESMRCmdMailDelete) );
  1391             aMenuPane->SetItemDimmed(
  1332             aMenuPane->SetItemDimmed(
  1400 
  1341 
  1401             aMenuPane->SetItemDimmed(
  1342             aMenuPane->SetItemDimmed(
  1402                     EESMRCmdMailNextMessage,
  1343                     EESMRCmdMailNextMessage,
  1403                     !iCallback.IsCommandAvailable(
  1344                     !iCallback.IsCommandAvailable(
  1404                             EESMRCmdMailNextMessage ) );
  1345                             EESMRCmdMailNextMessage ) );
  1405 
       
  1406             aMenuPane->SetItemDimmed(
       
  1407                     EESMRCmdMailEmailMoreMenu,
       
  1408                     emailMenuDimmed );
       
  1409             }
  1346             }
  1410         }
  1347         }
  1411     }
  1348     }
  1412 
  1349 
  1413 // ---------------------------------------------------------------------------
  1350 // ---------------------------------------------------------------------------
  1417 void CESMRViewerDialog::HandlePolicyMenuL(
  1354 void CESMRViewerDialog::HandlePolicyMenuL(
  1418         TInt aResourceId,
  1355         TInt aResourceId,
  1419         CEikMenuPane* aMenuPane )
  1356         CEikMenuPane* aMenuPane )
  1420     {
  1357     {
  1421     FUNC_LOG;
  1358     FUNC_LOG;
       
  1359     MESMRCalEntry* calEntry = iInfoProvider.EntryL();
       
  1360     const CESMRPolicy& currentPolicy(
       
  1361             iInfoProvider.PolicyProvider().CurrentPolicy() );
       
  1362 
  1422     if ( aResourceId == R_MR_VIEWER_MENU )
  1363     if ( aResourceId == R_MR_VIEWER_MENU )
  1423         {
  1364         {
  1424 	    if (FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ))
  1365         if ( calEntry->Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest )
  1425 		   {
       
  1426 		   // remove help support in pf5250
       
  1427 		   aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue);      
       
  1428 		   }
       
  1429 	            
       
  1430         if ( iEntry.Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest )
       
  1431             {
  1366             {
  1432             MESMRMeetingRequestEntry* mrEntry =
  1367             MESMRMeetingRequestEntry* mrEntry =
  1433                     (MESMRMeetingRequestEntry*)( &iEntry );
  1368                     (MESMRMeetingRequestEntry*)( calEntry );
  1434             CCalEntry::TMethod method(
  1369             CCalEntry::TMethod method(
  1435                     mrEntry->Entry().MethodL() );
  1370                     mrEntry->Entry().MethodL() );
  1436 
  1371 
  1437             TInt itemsInMenu( aMenuPane->NumberOfItemsInPane() );
  1372             TInt itemsInMenu( aMenuPane->NumberOfItemsInPane() );
  1438             for ( TInt i(0); i < itemsInMenu; ++i )
  1373             for ( TInt i(0); i < itemsInMenu; ++i )
  1455                                     ETrue );
  1390                                     ETrue );
  1456                             break;
  1391                             break;
  1457                             }
  1392                             }
  1458                         case EESMRCmdRemoveFromCalendar:
  1393                         case EESMRCmdRemoveFromCalendar:
  1459                             {
  1394                             {
  1460                             TPtrC addr = DigMailboxAndRemovePrefixL();
  1395                             if( SupportsMailBoxCapabilityL(
  1461                             
  1396                                     MESMRBuilderExtension::
  1462                             if( iESMRStatic.MailBoxL( addr ).HasCapability( 
  1397                                         EMRCFSRemoveFromCalendar ) )
  1463                                     EFSMBoxCapaRemoveFromCalendar ) &&
       
  1464                                 iEntry.IsStoredL() )
       
  1465                                 {
  1398                                 {
  1466                                 aMenuPane->SetItemDimmed(
  1399                                 aMenuPane->SetItemDimmed(
  1467                                         item.iCommandId,
  1400                                         item.iCommandId,
  1468                                         EFalse );
  1401                                         EFalse );
  1469                                 }
  1402                                 }
  1477                             }
  1410                             }
  1478                         default:
  1411                         default:
  1479                             {
  1412                             {
  1480                             aMenuPane->SetItemDimmed(
  1413                             aMenuPane->SetItemDimmed(
  1481                                     item.iCommandId,
  1414                                     item.iCommandId,
  1482                                     !iPolicy->IsDefaultCommand( 
  1415                                     !currentPolicy.IsDefaultCommand(
  1483                                     		item.iCommandId) );
  1416                                     		item.iCommandId) );
  1484                             break;
  1417                             break;
  1485                             }
  1418                             }
  1486                         }
  1419                         }
  1487                     }
  1420                     }
  1488                 else
  1421                 else
  1489                     {
  1422                     {
  1490                     if ( EESMRCmdRemoveFromCalendar == item.iCommandId )
  1423                     if( mrEntry->OccursInPastL() ||
  1491                         {
  1424             			mrEntry->IsEntryOutOfDateL() ||
  1492                         aMenuPane->SetItemDimmed(
  1425             			mrEntry->IsMeetingCancelledL() )
  1493                                 EESMRCmdRemoveFromCalendar,
  1426                     	{
  1494                                 ETrue );
  1427                     	if( item.iCommandId == EESMRCmdAcceptMR ||
  1495                         }
  1428                     			item.iCommandId == EESMRCmdTentativeMR ||
  1496                     else
  1429                     			item.iCommandId == EESMRCmdDeclineMR )
  1497                         {
  1430                     		{
  1498                         aMenuPane->SetItemDimmed(
  1431                     		aMenuPane->SetItemDimmed(
  1499                                 item.iCommandId,
  1432                     				item.iCommandId,
  1500                                 !iPolicy->IsDefaultCommand( item.iCommandId) );
  1433                     				ETrue );
       
  1434                     		}
       
  1435                         else if ( EESMRCmdRemoveFromCalendar == item.iCommandId &&
       
  1436                         		  mrEntry->IsOpenedFromMail() )
       
  1437                             {
       
  1438                             aMenuPane->SetItemDimmed(
       
  1439                                     EESMRCmdRemoveFromCalendar,
       
  1440                                     EFalse );
       
  1441                             }
       
  1442                 		else
       
  1443                 			{
       
  1444                             aMenuPane->SetItemDimmed(
       
  1445                                     item.iCommandId,
       
  1446                                     !currentPolicy.IsDefaultCommand( item.iCommandId) );
       
  1447                 			}
       
  1448                     	}
       
  1449             		else
       
  1450             			{
       
  1451             			if ( EESMRCmdRemoveFromCalendar == item.iCommandId )
       
  1452             				{
       
  1453             				aMenuPane->SetItemDimmed(
       
  1454             						EESMRCmdRemoveFromCalendar,
       
  1455             						ETrue );
       
  1456             				}
       
  1457             			else
       
  1458             				{
       
  1459             				aMenuPane->SetItemDimmed(
       
  1460             						item.iCommandId,
       
  1461             						!currentPolicy.IsDefaultCommand( item.iCommandId) );
       
  1462             				}
  1501                         }
  1463                         }
  1502                     }
  1464                     }
  1503                 if ( EESMRRoleOrganizer == mrEntry->RoleL())
  1465                 if ( EESMRRoleOrganizer == mrEntry->RoleL())
  1504                     {
  1466                     {
  1505                     //dim tracking view menuitem if no attendees
  1467                     //dim tracking view menuitem if no attendees
  1506                     //or if current cfsmailbox doesn't support attendee status
  1468                     //or if current cfsmailbox doesn't support attendee status
  1507                     if( EESMRCmdViewTrack == item.iCommandId )
  1469                     if( EESMRCmdViewTrack == item.iCommandId )
  1508                         {
  1470                         {
  1509                         TInt count(0);
  1471                         TInt count(0);
  1510 
  1472 
  1511                         if ( SupportsAttendeeStatusL() )
  1473                         if ( SupportsMailBoxCapabilityL(
       
  1474                                 MESMRBuilderExtension::
       
  1475                                 EMRCFSAttendeeStatus ) )
  1512                             {
  1476                             {
  1513                             count = mrEntry->AttendeeCountL(EESMRRoleRequiredAttendee)+
  1477                             count = mrEntry->AttendeeCountL(EESMRRoleRequiredAttendee)+
  1514                                     mrEntry->AttendeeCountL(EESMRRoleOptionalAttendee);
  1478                                     mrEntry->AttendeeCountL(EESMRRoleOptionalAttendee);
  1515                             }
  1479                             }
  1516 
  1480 
  1529                 {
  1493                 {
  1530                 CEikMenuPaneItem::SData& item = aMenuPane->ItemDataByIndexL(i);
  1494                 CEikMenuPaneItem::SData& item = aMenuPane->ItemDataByIndexL(i);
  1531 
  1495 
  1532                 aMenuPane->SetItemDimmed(
  1496                 aMenuPane->SetItemDimmed(
  1533                     item.iCommandId,
  1497                     item.iCommandId,
  1534                     !iPolicy->IsDefaultCommand( item.iCommandId) );
  1498                     !currentPolicy.IsDefaultCommand( item.iCommandId) );
  1535                 }
  1499                 }
  1536 
  1500 
  1537             if ( iEntry.Type() == MESMRCalEntry::EESMRCalEntryTodo )
  1501             if ( calEntry->Type() == MESMRCalEntry::EESMRCalEntryTodo )
  1538                 {
  1502                 {
  1539                 if (iPolicy->IsDefaultCommand(EESMRCmdTodoMarkAsDone))
  1503                 if (currentPolicy.IsDefaultCommand( EESMRCmdTodoMarkAsDone ) )
  1540                     {
  1504                     {
  1541                     TBool dim(EFalse);
  1505                     TBool dim(EFalse);
  1542                     if( iEntry.Entry().StatusL() == CCalEntry::ETodoCompleted )
  1506                     if( calEntry->Entry().StatusL() == CCalEntry::ETodoCompleted )
  1543                         {
  1507                         {
  1544                         dim = ETrue;
  1508                         dim = ETrue;
  1545                         }
  1509                         }
  1546                     aMenuPane->SetItemDimmed( EESMRCmdTodoMarkAsDone, dim );
  1510                     aMenuPane->SetItemDimmed( EESMRCmdTodoMarkAsDone, dim );
  1547                     aMenuPane->SetItemDimmed( EESMRCmdTodoMarkAsNotDone, !dim );
  1511                     aMenuPane->SetItemDimmed( EESMRCmdTodoMarkAsNotDone, !dim );
  1553 
  1517 
  1554 // ---------------------------------------------------------------------------
  1518 // ---------------------------------------------------------------------------
  1555 // CESMRViewerDialog::SupportsAttendeeStatusL
  1519 // CESMRViewerDialog::SupportsAttendeeStatusL
  1556 // ---------------------------------------------------------------------------
  1520 // ---------------------------------------------------------------------------
  1557 //
  1521 //
  1558 TBool CESMRViewerDialog::SupportsAttendeeStatusL( )
  1522 TBool CESMRViewerDialog::SupportsMailBoxCapabilityL(
  1559     {
  1523         MESMRBuilderExtension::TMRCFSMailBoxCapability aCapa )
  1560     FUNC_LOG;
  1524     {
  1561     TBool supportsAttendeeStatus(EFalse);
  1525     FUNC_LOG;
       
  1526     TBool supportsCapability( EFalse );
  1562     CESMRFieldBuilderInterface* plugin = NULL;
  1527     CESMRFieldBuilderInterface* plugin = NULL;
  1563     TRAPD( error, 
  1528     TRAPD( error,
  1564             plugin = CESMRFieldBuilderInterface::CreatePluginL( 
  1529             plugin = CESMRFieldBuilderInterface::CreatePluginL(
  1565                         TUid::Uid(KESMRUIFieldBuilderPluginImplUId) ) );
  1530                         TUid::Uid(KESMRUIFieldBuilderPluginImplUId) ) );
  1566     CleanupStack::PushL( plugin );
  1531     CleanupStack::PushL( plugin );
  1567     
  1532 
  1568     if (error == KErrNone && plugin)
  1533     if (error == KErrNone && plugin)
  1569         {
  1534         {
  1570         TUid uid = {0};
  1535         TUid uid = {0};
  1571         MESMRBuilderExtension* extension = 
  1536         MESMRBuilderExtension* extension =
  1572             static_cast<MESMRBuilderExtension*>( plugin->ExtensionL(uid) );
  1537                 static_cast<MESMRBuilderExtension*>( plugin->ExtensionL(uid) );
  1573 
  1538 
  1574         if (extension)
  1539         MESMRCalEntry* calEntry = iInfoProvider.EntryL();
  1575             {
  1540         
  1576             supportsAttendeeStatus = 
  1541         if ( extension && MESMRCalEntry::EESMRCalEntryMeetingRequest == calEntry->Type())
  1577                 extension->CFSMailBoxCapabilityL(
  1542             {
  1578                         MESMRBuilderExtension::EMRCFSAttendeeStatus);
  1543             // Static cast is safe here. We know for sure that entry is MR
       
  1544             MESMRMeetingRequestEntry* mrEntry =
       
  1545                     static_cast<MESMRMeetingRequestEntry*>( calEntry );
       
  1546 
       
  1547             supportsCapability = extension->CFSMailBoxCapabilityL(
       
  1548                     mrEntry->Entry().PhoneOwnerL()->Address(),
       
  1549                     aCapa );
  1579             }
  1550             }
  1580         }
  1551         }
  1581 
  1552 
  1582     CleanupStack::PopAndDestroy( plugin );
  1553     CleanupStack::PopAndDestroy( plugin );
  1583 
  1554 
  1584     return supportsAttendeeStatus;
  1555     return supportsCapability;
  1585     }
  1556     }
  1586 
  1557 
  1587 // ---------------------------------------------------------------------------
  1558 // ---------------------------------------------------------------------------
  1588 // CESMRViewerDialog::HandleMRExitL
  1559 // CESMRViewerDialog::HandleMRExitL
  1589 // ---------------------------------------------------------------------------
  1560 // ---------------------------------------------------------------------------
  1590 //
  1561 //
  1591 TBool CESMRViewerDialog::HandleMRExitL( TInt aCommand )
  1562 TBool CESMRViewerDialog::HandleMRExitL( TInt aCommand )
  1592     {
  1563     {
  1593     FUNC_LOG;
  1564     FUNC_LOG;
  1594     TBool deleteEntry( EFalse );
  1565     TBool deleteEntry( EFalse );
  1595     
  1566 
  1596     TBool queryAvailable( ETrue );
  1567     TBool queryAvailable( ETrue );
  1597     
  1568 
  1598     // disable EESMRRemoveAppointment query if exiting dialog 
  1569     // disable EESMRRemoveAppointment query if exiting dialog
  1599     // through email-based option menu command,
  1570     // through email-based option menu command,
  1600     switch ( aCommand )
  1571     switch ( aCommand )
  1601         {
  1572         {
  1602         case EESMRCmdMailPreviousMessage: // Fall through
  1573         case EESMRCmdMailPreviousMessage: // Fall through
  1603         case EESMRCmdMailNextMessage: // Fall through
  1574         case EESMRCmdMailNextMessage: // Fall through
  1604         case EESMRCmdMailForwardAsMessage: // Fall through
  1575         case EESMRCmdMailForwardAsMessage: // Fall through
  1605         case EESMRCmdMailMoveMessage: // Fall through
  1576         case EESMRCmdMailMoveMessage: // Fall through
  1606         case EESMRCmdMailCopyMessage: // Fall through
  1577         case EESMRCmdMailCopyMessage: // Fall through
  1607         case EESMRCmdMailMoveMessageToDrafts: // Fall through
  1578         case EESMRCmdMailMoveMessageToDrafts: // Fall through
  1608         case EESMRCmdMailComposeMessage: // Fall through
  1579         case EESMRCmdMailComposeMessage: // Fall through
  1609         case EESMRCmdMailMessageDetails: // Fall through
  1580         case EESMRCmdMailMessageDetails:
  1610         case EESMRCmdForward:
  1581         case EESMRCmdForwardAsMeeting: // Fall through
       
  1582         case EESMRCmdForwardAsMail:
  1611             {
  1583             {
  1612             queryAvailable = EFalse;
  1584             queryAvailable = EFalse;
  1613             break;
  1585             break;
  1614             }
  1586             }
       
  1587         case EAknSoftkeyClose:
       
  1588         	{
       
  1589         	queryAvailable = EFalse;
       
  1590         	break;
       
  1591         	}
  1615         default:
  1592         default:
  1616             break;
  1593             break;
  1617         }
  1594         }
  1618              
  1595 
  1619     if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == iEntry.Type() )
  1596     MESMRCalEntry* calEntry = iInfoProvider.EntryL();
  1620         {
  1597 
  1621         MESMRMeetingRequestEntry* mrEntry =  static_cast<MESMRMeetingRequestEntry*>( &iEntry );
  1598     if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == calEntry->Type() )
  1622 
  1599         {
  1623         if ( mrEntry->IsOpenedFromMail() &&
  1600         // Static cast is safe here. We know for sure that entry is MR
  1624              queryAvailable &&
  1601         MESMRMeetingRequestEntry* mrEntry =
  1625              EESMRRoleOrganizer != mrEntry->RoleL() &&
  1602                 static_cast<MESMRMeetingRequestEntry*>( calEntry );
  1626              mrEntry->IsMeetingCancelledL() &&
  1603 
  1627              EESMRAttendeeStatusDecline != mrEntry->AttendeeStatusL() &&
  1604         // Restore the status pane layout
  1628              CESMRConfirmationQuery::ExecuteL( CESMRConfirmationQuery::EESMRRemoveAppointment) )
  1605         CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
  1629             {
  1606         sp->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL);
  1630             deleteEntry = ETrue;
  1607 
       
  1608         if ( mrEntry->IsOpenedFromMail() )
       
  1609             {
       
  1610 
       
  1611 
       
  1612             if( queryAvailable &&
       
  1613                 EESMRRoleOrganizer != mrEntry->RoleL() &&
       
  1614                 ( mrEntry->IsMeetingCancelledL() ||
       
  1615                 		mrEntry->IsEntryOutOfDateL() ||
       
  1616                 		mrEntry->OccursInPastL() ) &&
       
  1617                 EESMRAttendeeStatusDecline != mrEntry->AttendeeStatusL() &&
       
  1618                 CESMRConfirmationQuery::ExecuteL( CESMRConfirmationQuery::EESMRRemoveAppointment)  )
       
  1619                 {
       
  1620                 deleteEntry = ETrue;
       
  1621                 }
  1631             }
  1622             }
  1632         }
  1623         }
  1633 
  1624 
  1634     if ( deleteEntry )
  1625     if ( deleteEntry )
  1635         {
  1626         {
  1641             }
  1632             }
  1642         }
  1633         }
  1643 
  1634 
  1644     if ( EESMRCmdRemoveFromCalendar == aCommand )
  1635     if ( EESMRCmdRemoveFromCalendar == aCommand )
  1645         {
  1636         {
  1646         return deleteEntry;        
  1637         return deleteEntry;
  1647         }
  1638         }
  1648     
  1639 
  1649     return ETrue;
  1640     return ETrue;
  1650     }
  1641     }
  1651 
  1642 
  1652 // ---------------------------------------------------------------------------
  1643 // ---------------------------------------------------------------------------
  1653 // CESMRViewerDialog::SupportsForwardingAsMeetingL
  1644 // CESMRViewerDialog::HandleForwardMenuL
  1654 // ---------------------------------------------------------------------------
  1645 // ---------------------------------------------------------------------------
  1655 //
  1646 //
  1656 TBool CESMRViewerDialog::SupportsForwardingAsMeetingL( 
  1647 void CESMRViewerDialog::HandleForwardMenuL(
  1657         MESMRMeetingRequestEntry* aEntry,
  1648         TInt /*aResourceId*/,
  1658         TBool aForceResetDefaultMRMailbox )
  1649         CEikMenuPane* aMenuPane )
  1659     {
  1650     {
  1660     FUNC_LOG;
  1651     FUNC_LOG;
  1661     TBool sendingAsMRSupported( EFalse );
  1652     MESMRCalEntry* calEntry = iInfoProvider.EntryL();
  1662     TESMRMailPlugin currentPlugin = aEntry->CurrentPluginL();
  1653     if ( calEntry->Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest )
  1663 
  1654         {
  1664     if ( EESMRIntelliSync != currentPlugin )
  1655         // Because this is MR entry, it is safe to cast it.
  1665         {
  1656         MESMRMeetingRequestEntry* mrEntry =
  1666         if ( aEntry->IsOpenedFromMail() )
  1657                 (MESMRMeetingRequestEntry*)( calEntry );
  1667             {
  1658 
  1668             // Set default MR mail box to the one used for this MR
  1659         __ASSERT_DEBUG( mrEntry, Panic( EESMRViewerDlgInvalidEntry) );
  1669             // unless if it already is set
  1660 
  1670             CMRMailboxUtils* mbUtils = CMRMailboxUtils::NewL();
  1661         TBool mrOriginatingEnabled( EFalse  );
  1671             CleanupStack::PushL( mbUtils );
  1662         TESMRMailPlugin currentPlugin = mrEntry->CurrentPluginL();
  1672             TInt currentEntryId = AccountIdL( aEntry->CurrentMailBoxIdL() );
  1663 
  1673             CMRMailboxUtils::TMailboxInfo mrMailboxInfo;
  1664         if ( EESMRIntelliSync == currentPlugin )
  1674             mbUtils->GetDefaultMRMailBoxL( mrMailboxInfo );
  1665             {
  1675             if ( mrMailboxInfo.iEntryId != currentEntryId )
  1666             mrOriginatingEnabled = EFalse;
  1676                 {
  1667             }
  1677                 mbUtils->SetDefaultMRMailBoxL( currentEntryId );
  1668         else if ( mrEntry->IsOpenedFromMail() )
  1678                 }
  1669             {
  1679             CleanupStack::PopAndDestroy( mbUtils );
       
  1680             
       
  1681             // When opened from email, we need to make sure that
  1670             // When opened from email, we need to make sure that
  1682             // meeting request sending is possible
  1671             // meeting request sending is possible
  1683             CESMRFieldBuilderInterface* plugin = 
  1672             CESMRFieldBuilderInterface* plugin = NULL;
       
  1673             TRAPD( error, plugin =
  1684                 CESMRFieldBuilderInterface::CreatePluginL(
  1674                 CESMRFieldBuilderInterface::CreatePluginL(
  1685                         TUid::Uid( KESMRUIFieldBuilderPluginImplUId ) );
  1675                         TUid::Uid(KESMRUIFieldBuilderPluginImplUId)) );
       
  1676 
  1686             CleanupDeletePushL( plugin );
  1677             CleanupDeletePushL( plugin );
  1687 
  1678 
  1688             if ( plugin )
  1679             if (error == KErrNone && plugin)
  1689                 {
  1680                 {
  1690                 TUid uid = {0};
  1681                 TUid uid = {0};
  1691                 MESMRBuilderExtension* extension =
  1682                 MESMRBuilderExtension* extension =
  1692                         static_cast<MESMRBuilderExtension*>(
  1683                         static_cast<MESMRBuilderExtension*>(
  1693                                 plugin->ExtensionL( uid ) );
  1684                                 plugin->ExtensionL(uid) );
  1694 
  1685 
  1695                 if ( extension )
  1686                 if (extension)
  1696                     {
  1687                     {
  1697                     sendingAsMRSupported =
  1688                     mrOriginatingEnabled =
  1698                             extension->MRCanBeOriginateedL(
  1689                             extension->MRCanBeOriginateedL();
  1699                                     aForceResetDefaultMRMailbox );
       
  1700                     }
  1690                     }
  1701                 }
  1691                 }
  1702             CleanupStack::PopAndDestroy( plugin );
  1692             CleanupStack::PopAndDestroy( plugin );
  1703             plugin = NULL;
  1693             plugin = NULL;
  1704             }
  1694             }
  1705         else
  1695         else
  1706             {
  1696             {
  1707             sendingAsMRSupported = ETrue;
  1697             mrOriginatingEnabled = ETrue;
  1708             }
  1698             }
  1709         }
  1699 
  1710 
  1700         aMenuPane->SetItemDimmed(
  1711     return sendingAsMRSupported;
  1701                 EESMRCmdForwardAsMeeting,
  1712     }
  1702                 !mrOriginatingEnabled );
  1713 
  1703         }
       
  1704     }
  1714 
  1705 
  1715 // ---------------------------------------------------------------------------
  1706 // ---------------------------------------------------------------------------
  1716 // CESMRViewerDialog::LocationPluginHandlerL
  1707 // CESMRViewerDialog::LocationPluginHandlerL
  1717 // ---------------------------------------------------------------------------
  1708 // ---------------------------------------------------------------------------
  1718 //
  1709 //
  1721     FUNC_LOG;
  1712     FUNC_LOG;
  1722     if ( !iLocationPluginHandler )
  1713     if ( !iLocationPluginHandler )
  1723         {
  1714         {
  1724         iLocationPluginHandler = CESMRLocationPluginHandler::NewL( *this );
  1715         iLocationPluginHandler = CESMRLocationPluginHandler::NewL( *this );
  1725         }
  1716         }
       
  1717 
       
  1718     return *iLocationPluginHandler;
       
  1719     }
       
  1720 
       
  1721 // ---------------------------------------------------------------------------
       
  1722 // CESMRViewerDialog::HandleFieldEventL
       
  1723 // ---------------------------------------------------------------------------
       
  1724 //
       
  1725 void CESMRViewerDialog::HandleFieldEventL( const MESMRFieldEvent& aEvent )
       
  1726     {
       
  1727     FUNC_LOG;
  1726     
  1728     
  1727     return *iLocationPluginHandler;
  1729     MESMRFieldEvent::TEventType type( aEvent.Type() );
  1728     }
  1730     
  1729 
  1731     if ( MESMRFieldEvent::EESMRFieldCommandEvent == type )
  1730 // ---------------------------------------------------------------------------
  1732         {
  1731 // CESMRViewerDialog::LocationPluginHandlerL
  1733         ProcessCommandEventL( aEvent );
  1732 // ---------------------------------------------------------------------------
  1734         }
  1733 //
  1735     else if ( MESMRFieldEvent::EESMRFieldChangeEvent == type ) 
  1734 void CESMRViewerDialog::HandleFieldEventL( const MESMRFieldEvent& aEvent )
  1736         {
  1735     {
  1737         ProcessFieldEventL( aEvent );
  1736     FUNC_LOG;
       
  1737     if ( aEvent.Type() == MESMRFieldEvent::EESMRFieldCommandEvent )
       
  1738         {
       
  1739         TInt* command = static_cast< TInt* >( aEvent.Param( 0 ) );
       
  1740         
       
  1741         switch ( *command )
       
  1742             {
       
  1743             case EESMRCmdRestoreMiddleSoftKey:
       
  1744                 {
       
  1745                 SetDefaultMiddleSoftKeyL();
       
  1746                 ButtonGroupContainer().DrawDeferred();
       
  1747                 break;
       
  1748                 }
       
  1749            	case EESMRCmdOpenAttachment:// Fall through
       
  1750             case EESMRCmdOpenAttachmentView:// Fall through
       
  1751             case EESMRCmdDownloadAttachment: // Fall through
       
  1752             case EESMRCmdDownloadAllAttachments: // Fall through
       
  1753             case EESMRCmdSaveAttachment: // Fall through
       
  1754             case EESMRCmdSaveAllAttachments: // Fall through
       
  1755             case EESMRCmdMskOpenEmailAttachment:
       
  1756                 {
       
  1757                 ProcessCommandL( *command );
       
  1758                 
       
  1759                 break;
       
  1760                 }
       
  1761             default:
       
  1762                 {
       
  1763                 break;
       
  1764                 }
       
  1765             }
       
  1766         }
  1738         }
  1767     }
  1739     }
  1768 
  1740 
  1769 // ---------------------------------------------------------------------------
  1741 // ---------------------------------------------------------------------------
  1770 // CESMRViewerDialog::SetDefaultMiddleSoftKeyL
  1742 // CESMRViewerDialog::SetDefaultMiddleSoftKeyL
  1772 //
  1744 //
  1773 void CESMRViewerDialog::SetDefaultMiddleSoftKeyL()
  1745 void CESMRViewerDialog::SetDefaultMiddleSoftKeyL()
  1774     {
  1746     {
  1775     FUNC_LOG;
  1747     FUNC_LOG;
  1776     TInt resourceId = KErrNotFound;
  1748     TInt resourceId = KErrNotFound;
  1777     if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == iEntry.Type() )
  1749     MESMRCalEntry* calEntry = iInfoProvider.EntryL();
       
  1750     const CESMRPolicy& currentPolicy(
       
  1751             iInfoProvider.PolicyProvider().CurrentPolicy() );
       
  1752 
       
  1753     if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == calEntry->Type() )
  1778         {
  1754         {
  1779         // If 'Edit' command is not allowed then we change the MSK to 'Select'
  1755         // If 'Edit' command is not allowed then we change the MSK to 'Select'
  1780         if ( !iPolicy->IsDefaultCommand( EESMRCmdEdit ) )
  1756         if ( !currentPolicy.IsDefaultCommand( EESMRCmdEdit ) )
  1781             {
  1757             {
  1782             resourceId = R_MR_SELECT_SOFTKEY;
  1758             resourceId = R_MR_SELECT_SOFTKEY;
  1783             // Disable middle softkey by default
  1759             // Disable middle softkey by default
  1784             // Focused field enables it if MSK has select functionality
  1760             // Focused field enables it if MSK has select functionality
  1785             ButtonGroupContainer().MakeCommandVisibleByPosition(
  1761             ButtonGroupContainer().MakeCommandVisibleByPosition(
  1788             }
  1764             }
  1789         else
  1765         else
  1790             {
  1766             {
  1791             resourceId = R_MR_EDIT_SOFTKEY;
  1767             resourceId = R_MR_EDIT_SOFTKEY;
  1792             }
  1768             }
  1793             
  1769 
  1794         }
  1770         }
  1795     else if ( iPolicy->IsDefaultCommand( EESMRCmdCalEntryUIEdit ) )
  1771     else if ( currentPolicy.IsDefaultCommand( EESMRCmdCalEntryUIEdit ) )
  1796         {
  1772         {
  1797         // Set correct edit command in MSK. Dialog resource has EESMRCmdEdit
  1773         // Set correct edit command in MSK. Dialog resource has EESMRCmdEdit
  1798         resourceId = R_MR_CAL_EDIT_SOFTKEY;
  1774         resourceId = R_MR_CAL_EDIT_SOFTKEY;
  1799         }
  1775         }
       
  1776 
       
  1777     if ( resourceId != KErrNotFound )
       
  1778         {
       
  1779         ButtonGroupContainer().SetCommandL(
       
  1780                 CEikButtonGroupContainer::EMiddleSoftkeyPosition,
       
  1781                 resourceId );
       
  1782         }
       
  1783     }
       
  1784 
       
  1785 // -----------------------------------------------------------------------------
       
  1786 // CESMRViewerDialog::ShowContextMenuL
       
  1787 // -----------------------------------------------------------------------------
       
  1788 //
       
  1789 void CESMRViewerDialog::ShowContextMenuL()
       
  1790     {
       
  1791     FUNC_LOG;
       
  1792 
       
  1793     if ( iMenuBar )
       
  1794         {
       
  1795         iMenuBar->TryDisplayContextMenuBarL();
       
  1796         }
       
  1797     }
       
  1798 
       
  1799  // ---------------------------------------------------------------------------
       
  1800  // CESMRViewerDialog::HandleNaviArrowEventL
       
  1801  // ---------------------------------------------------------------------------
       
  1802  //
       
  1803  void CESMRViewerDialog::HandleNaviArrowEventL( const TInt aCommand )
       
  1804      {
       
  1805      FUNC_LOG;
       
  1806      ProcessCommandL( aCommand );
       
  1807      }
       
  1808 
       
  1809  // ---------------------------------------------------------------------------
       
  1810  // CESMRViewerDialog::UserWantToHandleAttachmentsL
       
  1811  // ---------------------------------------------------------------------------
       
  1812  //
       
  1813  TBool CESMRViewerDialog::UserWantToHandleAttachmentsL()
       
  1814      {
       
  1815      TBool retValue( EFalse );
       
  1816 
       
  1817      MESMRCalEntry* calEntry = iInfoProvider.EntryL();
       
  1818      MESMRMeetingRequestEntry* mrEntry = NULL;
       
  1819      if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == calEntry->Type() )
       
  1820          {
       
  1821          // This is meeting request
       
  1822          mrEntry = static_cast<MESMRMeetingRequestEntry*>( calEntry );
       
  1823 
       
  1824          TBool openedFromEmail( mrEntry->IsOpenedFromMail() );
       
  1825          
       
  1826          // If entry is opened from mail, contains remote attachments and
       
  1827          // mailbox is MfE, we show the query.
       
  1828          if ( openedFromEmail && mrEntry->ContainsRemoteAttachmentsL() &&
       
  1829         		 mrEntry->CurrentPluginL() == EESMRActiveSync )
       
  1830              {
       
  1831              retValue =
       
  1832                      CESMRConfirmationQuery::ExecuteL(
       
  1833                                  CESMRConfirmationQuery::EESMRAttachments );
       
  1834              }
       
  1835          }
       
  1836 
       
  1837      return retValue;
       
  1838      }
       
  1839 
       
  1840 // ---------------------------------------------------------------------------
       
  1841 // CESMRViewerDialog::InitLocationMenuL
       
  1842 // ---------------------------------------------------------------------------
       
  1843 //
       
  1844 void CESMRViewerDialog::InitLocationMenuL( CEikMenuPane* aMenuPane )
       
  1845     {
       
  1846     FUNC_LOG;
       
  1847 
       
  1848     aMenuPane->SetItemDimmed( EESMRCmdSearchFromMap,ETrue );
       
  1849     aMenuPane->SetItemDimmed( EESMRCmdShowOnMap, ETrue );
       
  1850     }
       
  1851 
       
  1852 // ---------------------------------------------------------------------------
       
  1853 // CESMRViewerDialog::ConstructToolbarL
       
  1854 // ---------------------------------------------------------------------------
       
  1855 //
       
  1856 void CESMRViewerDialog::ConstructToolbarL()
       
  1857     {
       
  1858     FUNC_LOG;
       
  1859     if( iInfoProvider.EntryL()->Type() == 
       
  1860             MESMRCalEntry::EESMRCalEntryMeetingRequest )
       
  1861         {
       
  1862         MESMRMeetingRequestEntry* entry =
       
  1863             static_cast<MESMRMeetingRequestEntry*>( 
       
  1864                     iInfoProvider.EntryL() );
       
  1865         
       
  1866         if( !entry->OccursInPastL() && 
       
  1867                 !entry->IsEntryOutOfDateL() && 
       
  1868                     !entry->IsMeetingCancelledL() )
       
  1869             {
       
  1870             if ( entry->RoleL()== EESMRRoleRequiredAttendee ||
       
  1871                         entry->RoleL()== EESMRRoleOptionalAttendee )
       
  1872                 {
       
  1873                 TSize screenSize = 
       
  1874                         iEikonEnv->ScreenDevice()->SizeInPixels();
       
  1875             
       
  1876                 TBool isVGA( EFalse );
       
  1877                 if( ( screenSize.iHeight == KVGAOneSide || 
       
  1878                         screenSize.iWidth == KVGAOneSide ) && 
       
  1879                             ( screenSize.iHeight == KVGAOtherSide || 
       
  1880                               screenSize.iWidth == KVGAOtherSide ) && 
       
  1881                               screenSize.iHeight != screenSize.iWidth )
       
  1882                     {
       
  1883                     isVGA = ETrue;
       
  1884                     }
       
  1885 
       
  1886                 // Toolbar is disabled in VGA mode
       
  1887                 if( !isVGA )
       
  1888                     {
       
  1889                     // Toolbar is always shown in MR viewer when user
       
  1890                     // is attendee
       
  1891                     iToolbar->SetObserver( this );
       
  1892                     iToolbar->InitializeToolbarL(
       
  1893                             CMRToolbar::EMRViewerAttendee );
       
  1894                     iToolbar->ShowToolbar( ETrue );
       
  1895                     
       
  1896                     // Toolbar created, relayouting needed
       
  1897                     iView->ReLayout();
       
  1898                     }
       
  1899                 }
       
  1900             }        
       
  1901         }
       
  1902     }
       
  1903 
       
  1904 // ---------------------------------------------------------------------------
       
  1905 // CESMRViewerDialog::ProcessCommandEventL
       
  1906 // ---------------------------------------------------------------------------
       
  1907 //
       
  1908 void CESMRViewerDialog::ProcessCommandEventL( const MESMRFieldEvent& aEvent )
       
  1909     {
       
  1910     FUNC_LOG;
  1800     
  1911     
  1801     if ( resourceId != KErrNotFound )
  1912     TInt* command = static_cast< TInt* >( aEvent.Param( 0 ) );
  1802         {
  1913 
  1803         ButtonGroupContainer().SetCommandL(
  1914     switch ( *command )
  1804                 CEikButtonGroupContainer::EMiddleSoftkeyPosition, 
  1915         {
  1805                 resourceId );
  1916         case EESMRCmdRestoreMiddleSoftKey:
  1806         }
  1917             {
  1807     }
  1918             SetDefaultMiddleSoftKeyL();
  1808 
  1919             ButtonGroupContainer().DrawDeferred();
  1809 // ---------------------------------------------------------------------------
  1920             break;
  1810 // CESMRViewerDialog::DigMailboxAndRemovePrefixL
  1921             }
  1811 // ---------------------------------------------------------------------------
  1922         case EESMRCmdEdit: // Fall through
  1812 //
  1923         case EESMRCmdViewTrack: // Fall through
  1813 TPtrC CESMRViewerDialog::DigMailboxAndRemovePrefixL()
  1924         case EESMRCmdOpenAttachment:// Fall through
  1814     {
  1925         case EESMRCmdOpenAttachmentView:// Fall through
  1815     CCalUser* calUser = iEntry.Entry().PhoneOwnerL();
  1926         case EESMRCmdDownloadAttachment: // Fall through
  1816     TPtrC addrWithoutPrefix = calUser->Address();
  1927         case EESMRCmdDownloadAllAttachments: // Fall through
  1817     TInt pos = KErrNotFound;
  1928         case EESMRCmdSaveAttachment: // Fall through
  1818         
  1929         case EESMRCmdSaveAllAttachments: // Fall through
  1819     do
  1930         case EESMRCmdMskOpenEmailAttachment: // Fall through
  1820         {
  1931         case EESMRCmdSearchFromMap: // Fall through
  1821         pos = addrWithoutPrefix.MatchF( KMailtoMatchPattern );
  1932         case EESMRCmdShowOnMap:
  1822         if ( pos != KErrNotFound )
  1933         case EMRCmdHideAttachmentIndicator:
  1823         {
  1934             {
  1824             addrWithoutPrefix.Set( addrWithoutPrefix.Mid( KMailtoLength ) );
  1935             ProcessCommandL( *command );
  1825             }
  1936             break;
  1826         }
  1937             }
  1827     while ( pos != KErrNotFound );
  1938        case EMRLaunchAttachmentContextMenu:
       
  1939        case EAknSoftkeyContextOptions:
       
  1940             {
       
  1941             SetContextMenu();
       
  1942             ShowContextMenuL();
       
  1943             break;
       
  1944             }
       
  1945        case EESMRCmdAcceptMR:
       
  1946        case EESMRCmdTentativeMR:
       
  1947        case EESMRCmdDeclineMR:
       
  1948        case EESMRCmdRemoveFromCalendar:
       
  1949            {
       
  1950            ProcessCommandL( *command );
       
  1951            }
       
  1952            break;
       
  1953         default:
       
  1954             {
       
  1955             break;
       
  1956             }
       
  1957         }    
       
  1958     }
       
  1959 
       
  1960 // ---------------------------------------------------------------------------
       
  1961 // CESMRViewerDialog::ProcessFieldEventL
       
  1962 // ---------------------------------------------------------------------------
       
  1963 //
       
  1964 void CESMRViewerDialog::ProcessFieldEventL( const MESMRFieldEvent& aEvent )
       
  1965     {
       
  1966     FUNC_LOG;    
       
  1967     iView->ProcessEventL( aEvent );
       
  1968     }
  1828     
  1969     
  1829     return addrWithoutPrefix;
  1970 // EOF
  1830     }
       
  1831 
       
  1832 // ---------------------------------------------------------------------------
       
  1833 // CESMRViewerDialog::OfferToolbarEventL
       
  1834 // ---------------------------------------------------------------------------
       
  1835 //
       
  1836 void CESMRViewerDialog::OfferToolbarEventL( TInt aCommand ) 
       
  1837     {
       
  1838     ProcessCommandL( aCommand );
       
  1839     }
       
  1840 
       
  1841 // ---------------------------------------------------------------------------
       
  1842 // CESMRViewerDialog::HandleNaviDecoratorEventL
       
  1843 // ---------------------------------------------------------------------------
       
  1844 //
       
  1845 void CESMRViewerDialog::HandleNaviDecoratorEventL( TInt aEventID )
       
  1846     {
       
  1847     FUNC_LOG;
       
  1848     if ( iESMRNaviDecorator )
       
  1849         {
       
  1850         iESMRNaviDecorator->SetNaviDecoratorObserver( NULL );
       
  1851         }
       
  1852     if ( iIdleNaviEventRunner && !iIdleNaviEventRunner->IsActive() )
       
  1853         {
       
  1854         if( aEventID == 
       
  1855         MAknNaviDecoratorObserver::EAknNaviDecoratorEventRightTabArrow )
       
  1856             {
       
  1857             iIdleNaviEventRunner->Start( 
       
  1858                     TCallBack( RunCmdMailNextMessageIdle, this ) );
       
  1859             }
       
  1860         else
       
  1861             {
       
  1862             iIdleNaviEventRunner->Start( 
       
  1863                     TCallBack( RunCmdMailPreviousMessageIdle, this ) );
       
  1864             }
       
  1865         }
       
  1866     }
       
  1867 
       
  1868 
       
  1869 // ---------------------------------------------------------------------------
       
  1870 // CESMRViewerDialog::HandleSessionEventL
       
  1871 // ---------------------------------------------------------------------------
       
  1872 // 
       
  1873 void CESMRViewerDialog::HandleSessionEventL( 
       
  1874     TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/,
       
  1875     TAny* /*aArg2*/, TAny* /*aArg3*/ )
       
  1876     {
       
  1877     FUNC_LOG;
       
  1878     }
       
  1879 
       
  1880 
       
  1881 // ---------------------------------------------------------------------------
       
  1882 // CESMRViewerDialog::RunCmdMailNextMessageIdle [static]
       
  1883 // ---------------------------------------------------------------------------
       
  1884 // 
       
  1885 TInt CESMRViewerDialog::RunCmdMailNextMessageIdle( TAny* aObjPtr )
       
  1886     {
       
  1887     CESMRViewerDialog* self = 
       
  1888         reinterpret_cast<CESMRViewerDialog*>( aObjPtr );
       
  1889     if ( self )
       
  1890         {
       
  1891         TRAP_IGNORE( self->ProcessCommandL( EESMRCmdMailNextMessage ) );
       
  1892         }
       
  1893     return KErrNone;
       
  1894     }
       
  1895 
       
  1896 // ---------------------------------------------------------------------------
       
  1897 // CESMRViewerDialog::RunCmdMailPreviousMessageIdle [static]
       
  1898 // ---------------------------------------------------------------------------
       
  1899 // 
       
  1900 TInt CESMRViewerDialog::RunCmdMailPreviousMessageIdle( TAny* aObjPtr )
       
  1901     {
       
  1902     CESMRViewerDialog* self = 
       
  1903             reinterpret_cast<CESMRViewerDialog*>( aObjPtr );
       
  1904     if ( self )
       
  1905         {
       
  1906         TRAP_IGNORE( self->ProcessCommandL( EESMRCmdMailPreviousMessage ) );
       
  1907         }
       
  1908     return KErrNone;
       
  1909     }
       
  1910 
       
  1911 // ---------------------------------------------------------------------------
       
  1912 // CESMRViewerDialog::MakeMrGuiToolbarButtonsL
       
  1913 // ---------------------------------------------------------------------------
       
  1914 //
       
  1915 void CESMRViewerDialog::MakeMrGuiToolbarButtonsL()
       
  1916     {
       
  1917     CAknToolbar* currentToolbar = static_cast<CEikAppUiFactory*>( 
       
  1918         iEikonEnv->AppUiFactory() )->CurrentFixedToolbar();
       
  1919     if ( currentToolbar )
       
  1920         {
       
  1921         iOldObserver = currentToolbar->ToolbarObserver();
       
  1922         currentToolbar->SetToolbarObserver( this );
       
  1923 
       
  1924         TBool setResponseButtons = EFalse;
       
  1925         if ( iEntry.Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest )
       
  1926             {
       
  1927             CCalEntry::TMethod method = iEntry.Entry().MethodL();
       
  1928             if ( method != CCalEntry::EMethodCancel )
       
  1929                 {
       
  1930                 setResponseButtons = ETrue;
       
  1931                 }
       
  1932             }
       
  1933 
       
  1934         if ( setResponseButtons )
       
  1935             {
       
  1936             SetResponseButtonsL( currentToolbar );
       
  1937             }
       
  1938         else
       
  1939             {
       
  1940             SetEmptyButtonsL( currentToolbar );
       
  1941             }
       
  1942         }
       
  1943     }
       
  1944 
       
  1945 // ---------------------------------------------------------------------------
       
  1946 // CESMRViewerDialog::ClearToolbarL
       
  1947 // ---------------------------------------------------------------------------
       
  1948 //
       
  1949 void CESMRViewerDialog::ClearToolbarL()
       
  1950     {
       
  1951     if ( iClearToolbar )
       
  1952         {
       
  1953         // creating empty toolbar buttons
       
  1954         CAknToolbar* currentToolbar = static_cast<CEikAppUiFactory*>(
       
  1955             iEikonEnv->AppUiFactory() )->CurrentFixedToolbar();
       
  1956         if ( currentToolbar )
       
  1957             {
       
  1958             SetEmptyButtonsL( currentToolbar );
       
  1959             }
       
  1960         }
       
  1961     }
       
  1962 
       
  1963 // ---------------------------------------------------------------------------
       
  1964 // CESMRViewerDialog::AccountIdL
       
  1965 // ---------------------------------------------------------------------------
       
  1966 //
       
  1967 TInt CESMRViewerDialog::AccountIdL( const TFSMailMsgId& aMailboxId )
       
  1968     {
       
  1969     FUNC_LOG;
       
  1970 
       
  1971     CMsvSession* msvSession = CMsvSession::OpenSyncL( *this );
       
  1972     CleanupStack::PushL( msvSession );
       
  1973     CMsvEntry* rootEntry = msvSession->GetEntryL( KMsvRootIndexEntryIdValue );
       
  1974     CleanupStack::PushL( rootEntry );
       
  1975 
       
  1976     rootEntry->SetSortTypeL(
       
  1977         TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
       
  1978 
       
  1979     TInt accountId = 0;
       
  1980     TBool found = EFalse;
       
  1981     const TInt count = rootEntry->Count();
       
  1982     for ( TInt ii = 0; ii < count && !found; ++ii )
       
  1983         {
       
  1984         const TMsvEntry& entry = (*rootEntry)[ii];
       
  1985         if ( entry.iType == KUidMsvServiceEntry )
       
  1986             {
       
  1987             if ( entry.iMtmData1 == aMailboxId.PluginId().iUid &&
       
  1988                 entry.iMtmData2 == aMailboxId.Id() )
       
  1989                 {
       
  1990                 accountId = entry.Id();
       
  1991                 found = ETrue;
       
  1992                 }
       
  1993             }
       
  1994         }
       
  1995 
       
  1996     if ( !found )
       
  1997         {
       
  1998         User::Leave( KErrNotFound );
       
  1999         }
       
  2000 
       
  2001     CleanupStack::PopAndDestroy( rootEntry );
       
  2002     CleanupStack::PopAndDestroy( msvSession );
       
  2003     return accountId;
       
  2004     }