meetingrequest/mrgui/src/cesmreditordialog.cpp
changeset 0 8466d47a6819
child 1 12c456ceeff2
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  ESMR editor dialog
       
    15 *
       
    16 */
       
    17 
       
    18 #include "emailtrace.h"
       
    19 #include "cesmreditordialog.h"
       
    20 
       
    21 //<cmail>
       
    22 #include "esmrdef.h"
       
    23 #include <esmrgui.rsg>
       
    24 #include "cesmrpolicy.h"
       
    25 //</cmail>
       
    26 #include <eikenv.h>
       
    27 #include <eikappui.h>
       
    28 #include <avkon.hrh>
       
    29 #include <eikmenup.h>
       
    30 #include <MAgnEntryUi.h>
       
    31 #include <layoutmetadata.cdl.h>
       
    32 #include <AknDef.h>
       
    33 #include <AknUtils.h>
       
    34 
       
    35 #include <AknIndicatorContainer.h>
       
    36 #include <aknenv.h>
       
    37 #include <aknEditStateIndicator.h>
       
    38 #include <calentry.h>
       
    39 #include <CalenInterimUtils2.h>
       
    40 
       
    41 #include <akntitle.h>
       
    42 #include <StringLoader.h>
       
    43 //<cmail>
       
    44 #include <featmgr.h>
       
    45 //</cmail>
       
    46 #include "esmrcommands.h"
       
    47 //</cmail>
       
    48 
       
    49 #include <AiwServiceHandler.h>
       
    50 #include <featmgr.h>
       
    51 #include <bldvariant.hrh>
       
    52 
       
    53 #include "esmrgui.hrh"
       
    54 #include "cesmrview.h"
       
    55 #include "mesmrmeetingrequestentry.h"
       
    56 #include "cesmrconfirmationquery.h"
       
    57 #include "cesmrlistquery.h"
       
    58 #include "cesmreditorfieldstorage.h"
       
    59 #include "cesmrmixedfieldstorage.h"
       
    60 #include "cesmrsendui.h"
       
    61 #include "cesmrfield.h"
       
    62 #include "cesmrfieldbuilderinterface.h"
       
    63 #include "mesmrresponseobserver.h"
       
    64 #include "cesmrglobalnote.h"
       
    65 #include "cesmrtitlepanehandler.h"
       
    66 #include "esmrinternaluid.h"
       
    67 #include "cesmrlocationpluginhandler.h"
       
    68 #include "cesmraddressinfohandler.h"
       
    69 #include "cesmrfeaturesettings.h"
       
    70 #include "mesmrfieldevent.h"
       
    71 
       
    72 #include "esmrconfig.hrh"
       
    73 
       
    74 // <cmail> Removed profiling. </cmail>
       
    75 
       
    76 // Unnamed namespace for local definitions
       
    77 namespace { // codescanner::namespace
       
    78 
       
    79 #ifdef _DEBUG
       
    80     _LIT( KESMREditDlgPanicTxt, "ESMREDITORDIALOG" );
       
    81     /** Enumeration for panic codes */
       
    82     enum TESMREditDlgPanicCode
       
    83         {
       
    84         // Recurrence series query result error
       
    85         EESMREditDlgInvalidSeriesResult = 0,
       
    86         EESMREditDlgDialogLeave
       
    87         };
       
    88 
       
    89     void Panic( TESMREditDlgPanicCode aPanic )
       
    90         {
       
    91         User::Panic ( KESMREditDlgPanicTxt, aPanic );
       
    92         }
       
    93 #endif
       
    94 
       
    95 /**
       
    96  * Sets recurrence modification rule to entry. Rule is queried
       
    97  * from the user. Invalid result will cause panic.
       
    98  * @param aEntry Reference to meeting request.
       
    99  */
       
   100 void SetRecurrenceModRuleL(
       
   101         MESMRCalEntry& aEntry,
       
   102         CESMRListQuery::TESMRListQueryType aQueryType )
       
   103     {
       
   104     if ( aEntry.IsRecurrentEventL() &&
       
   105          aEntry.IsStoredL() )
       
   106         {
       
   107         TInt result =
       
   108             CESMRListQuery::ExecuteL( aQueryType );
       
   109 
       
   110         if( KErrCancel == result )
       
   111             {
       
   112             // User has cancelled selecting opening the instance
       
   113             User::Leave( KErrCancel );
       
   114             }
       
   115 
       
   116         TESMRThisOccurenceOrSeriesQuery recurrenceModRule =
       
   117             static_cast<TESMRThisOccurenceOrSeriesQuery>( result );
       
   118 
       
   119         switch( recurrenceModRule )
       
   120             {
       
   121             case EESMRThisOccurence:
       
   122                 {
       
   123                 aEntry.SetModifyingRuleL(
       
   124                         MESMRMeetingRequestEntry::EESMRThisOnly );
       
   125                 }
       
   126                 break;
       
   127             case EESMRSeries:
       
   128                 {
       
   129                 aEntry.SetModifyingRuleL(
       
   130                         MESMRMeetingRequestEntry::EESMRAllInSeries );
       
   131                 }
       
   132                 break;
       
   133             default:
       
   134                 __ASSERT_DEBUG( EFalse, Panic(EESMREditDlgInvalidSeriesResult));
       
   135                 break;
       
   136             }
       
   137         }
       
   138     else
       
   139         {
       
   140         aEntry.SetModifyingRuleL(
       
   141                 MESMRMeetingRequestEntry::EESMRThisOnly );
       
   142         }
       
   143     }
       
   144 
       
   145 /**
       
   146  * Creates correct type of storage for editing calendar entry.
       
   147  * @param aCommandObserver Reference to command observer
       
   148  * @param aEntry Reference to ES calendar entry
       
   149  * @param aPolicy. Pointer to used policy.
       
   150  * @param aResponseObserver Pointer to response observer.
       
   151  */
       
   152 CESMRFieldStorage* CreateCorrectStorageLC(
       
   153         MESMRFieldEventObserver& aEventObserver,
       
   154         MESMRCalEntry& aEntry,
       
   155         CESMRPolicy* aPolicy,
       
   156         MESMRResponseObserver* aResponseObserver )
       
   157     {
       
   158     CESMRFieldStorage* storage = NULL;
       
   159 
       
   160     MESMRCalEntry::TESMRRecurrenceModifyingRule rule(
       
   161             aEntry.RecurrenceModRule() );
       
   162 
       
   163     TESMRViewMode mode(
       
   164             aPolicy->ViewMode() );
       
   165 
       
   166     if ( ( aEntry.IsRecurrentEventL() &&
       
   167            rule == MESMRCalEntry::EESMRThisOnly ) ||
       
   168            mode == EESMRForwardMR )
       
   169         {
       
   170         // instance editing or forwarding entry
       
   171         storage = CESMRMixedFieldStorage::NewL(
       
   172                 aEventObserver,
       
   173                 aPolicy,
       
   174                 aResponseObserver,
       
   175                 aEntry );
       
   176         CleanupStack::PushL ( storage );
       
   177         }
       
   178     else if ( aEntry.IsRecurrentEventL() &&
       
   179               rule == MESMRCalEntry::EESMRAllInSeries  )
       
   180         {
       
   181         // Editing all in series
       
   182         storage = CESMRMixedFieldStorage::NewL(
       
   183                 aEventObserver,
       
   184                 aPolicy,
       
   185                 aResponseObserver,
       
   186                 aEntry );
       
   187         CleanupStack::PushL ( storage );
       
   188         }
       
   189     else
       
   190         {
       
   191         storage = CESMREditorFieldStorage::NewL ( aPolicy, aEventObserver );
       
   192         CleanupStack::PushL ( storage );
       
   193         }
       
   194 
       
   195     return storage;
       
   196     }
       
   197 
       
   198 /**
       
   199  * Tests if two datetime objects has same day or not.
       
   200  * @param aLhs Reference to left hand side datetime object.
       
   201  * @param aRhs Reference to right hand side datetime object.
       
   202  */
       
   203 TBool IsSameDay(
       
   204         TDateTime& aLhs,
       
   205         TDateTime& aRhs )
       
   206     {
       
   207     TBool retValue( ETrue );
       
   208 
       
   209     if ( aLhs.Day()     != aRhs.Day() ||
       
   210          aLhs.Month() != aRhs.Month() ||
       
   211          aLhs.Year()  != aRhs.Year() )
       
   212         {
       
   213         retValue = EFalse;
       
   214         }
       
   215 
       
   216     return retValue;
       
   217     }
       
   218 
       
   219 } // namespace
       
   220 
       
   221 // ======== MEMBER FUNCTIONS ========
       
   222 
       
   223 // ---------------------------------------------------------------------------
       
   224 // CESMREditorDialog::CESMREditorDialog
       
   225 // ---------------------------------------------------------------------------
       
   226 //
       
   227 CESMREditorDialog::CESMREditorDialog(
       
   228         MESMRCalEntry& aEntry,
       
   229         MAgnEntryUiCallback& aCallback ) :
       
   230     iEntry( aEntry), iCallback( aCallback)
       
   231     {
       
   232     FUNC_LOG;
       
   233     // Do nothing
       
   234     }
       
   235 
       
   236 // ---------------------------------------------------------------------------
       
   237 // CESMREditorDialog::~CESMREditorDialog
       
   238 // ---------------------------------------------------------------------------
       
   239 //
       
   240 CESMREditorDialog::~CESMREditorDialog( )
       
   241     {
       
   242     FUNC_LOG;
       
   243     if ( iFeatureManagerInitialized )
       
   244         {
       
   245         FeatureManager::UnInitializeLib();
       
   246         }
       
   247 
       
   248     if ( iServiceHandler )
       
   249         {
       
   250         iServiceHandler->DetachMenu ( 
       
   251         		R_MR_EDITOR_ORGANIZER_MENU, 
       
   252         		R_PS_AIW_INTEREST );
       
   253         delete iServiceHandler;
       
   254         }
       
   255 
       
   256     delete iESMRSendUI;
       
   257     if ( iTitlePane )
       
   258         {
       
   259         // Returns the previous title back to titlepane
       
   260         iTitlePane->Rollback();
       
   261         delete iTitlePane;
       
   262         }
       
   263 
       
   264     delete iInterimUtils;
       
   265 
       
   266     delete iLocationPluginHandler;
       
   267     
       
   268     delete iAddressInfoHandler;
       
   269     
       
   270     delete iFeatures;
       
   271     // iView is deleted by framework because it uses the
       
   272     // custom control mechanism.
       
   273     }
       
   274 
       
   275 // ---------------------------------------------------------------------------
       
   276 // CESMREditorDialog::NewL
       
   277 // ---------------------------------------------------------------------------
       
   278 //
       
   279 EXPORT_C CESMREditorDialog* CESMREditorDialog::NewL(
       
   280         CESMRPolicy* aPolicy,
       
   281         MESMRCalEntry& aEntry,
       
   282         MAgnEntryUiCallback& aCallback )
       
   283     {
       
   284     FUNC_LOG;
       
   285     CESMREditorDialog* self =
       
   286     new (ELeave) CESMREditorDialog( aEntry, aCallback );
       
   287     CleanupStack::PushL( self );
       
   288     self->ConstructL( aPolicy );
       
   289     CleanupStack::Pop( self );
       
   290     return self;
       
   291     }
       
   292 
       
   293 // ---------------------------------------------------------------------------
       
   294 // CESMREditorDialog::ConstructL
       
   295 // ---------------------------------------------------------------------------
       
   296 //
       
   297 void CESMREditorDialog::ConstructL(
       
   298         CESMRPolicy* aPolicy )
       
   299     {
       
   300     FUNC_LOG;
       
   301     CAknDialog::ConstructL ( R_MREDITOR_MENUBAR );
       
   302     iPolicy = aPolicy;
       
   303 
       
   304     iESMRSendUI = CESMRSendUI::NewL (EESMRCmdSendAs );
       
   305 
       
   306     FeatureManager::InitializeLibL();
       
   307     iFeatureManagerInitialized = ETrue;
       
   308 
       
   309     // <cmail> remove custom feature KFeatureIdPrintingFrameworkCalendarPlugin 
       
   310     // </cmail>	
       
   311 
       
   312     CESMRFieldStorage* storage =
       
   313             CreateCorrectStorageLC( *this, iEntry, aPolicy, this );
       
   314 
       
   315     TRect clientRect;
       
   316     AknLayoutUtils::LayoutMetricsRect(
       
   317             AknLayoutUtils::EMainPane,
       
   318             clientRect );
       
   319 
       
   320     // storage ownership is transferred to CESMRView
       
   321     iView = CESMRView::NewL( storage, iEntry, clientRect );
       
   322     CleanupStack::Pop( storage );
       
   323 
       
   324     // try to find subject field and set title pane observer
       
   325     CESMRField* field = NULL;
       
   326     TInt fieldCount( storage->Count() );
       
   327     for ( TInt i(0); i < fieldCount; ++i )
       
   328         {
       
   329         field = storage->Field( i );
       
   330         TESMREntryFieldId fieldId( field->FieldId() );
       
   331 
       
   332         switch (fieldId)
       
   333             {
       
   334             case EESMRFieldSubject: //Fall through
       
   335             case EESMRFieldOccasion://Fall through
       
   336             case EESMRFieldPriority://Fall through
       
   337             case EESMRFieldDetailedSubject:
       
   338                 {
       
   339                 field->SetTitlePaneObserver( iView );
       
   340                 break;
       
   341                 }            
       
   342             default:
       
   343             	break;
       
   344             }
       
   345         }
       
   346 
       
   347     TInt titleStringId = -1;
       
   348     switch ( iEntry.Type() )
       
   349         {
       
   350         case MESMRCalEntry::EESMRCalEntryMeetingRequest:
       
   351             titleStringId = R_QTN_MEET_REQ_TITLE_MEETING;
       
   352             break;
       
   353         case MESMRCalEntry::EESMRCalEntryMeeting:
       
   354             titleStringId = R_QTN_CALENDAR_TITLE_MEETING;
       
   355             break;
       
   356         case MESMRCalEntry::EESMRCalEntryTodo:
       
   357             titleStringId = R_QTN_CALENDAR_TITLE_TODO;
       
   358             break;
       
   359         case MESMRCalEntry::EESMRCalEntryMemo:
       
   360             titleStringId = R_QTN_CALENDAR_TITLE_MEMO;
       
   361             break;
       
   362         case MESMRCalEntry::EESMRCalEntryReminder:
       
   363             break;
       
   364         case MESMRCalEntry::EESMRCalEntryAnniversary:
       
   365             titleStringId = R_QTN_CALENDAR_TITLE_ANNIVERSARY;
       
   366             break;
       
   367         default:
       
   368             break;
       
   369         }
       
   370     if ( titleStringId != -1 )
       
   371         {
       
   372         iTitlePane = CESMRTitlePaneHandler::NewL( *iEikonEnv );
       
   373         HBufC* titleText = StringLoader::LoadLC( titleStringId, iCoeEnv );
       
   374         iTitlePane->SetNewTitle( titleText );
       
   375         CleanupStack::PopAndDestroy( titleText );
       
   376         }
       
   377     
       
   378     if(!iInterimUtils)
       
   379         {
       
   380         iInterimUtils = CCalenInterimUtils2::NewL();
       
   381         }
       
   382     
       
   383     iFeatures = CESMRFeatureSettings::NewL();
       
   384     
       
   385     if ( iFeatures->FeatureSupported(
       
   386             CESMRFeatureSettings::EESMRUILocationFeatures ) )
       
   387         {
       
   388         if ( iPolicy->FieldL( EESMRFieldLocation ).iFieldMode == EESMRFieldModeEdit )
       
   389             {
       
   390             iMenuBar->SetContextMenuTitleResourceId( R_MR_EDITOR_CONTEXT_MENU );
       
   391             }
       
   392         else
       
   393             {
       
   394             iMenuBar->SetContextMenuTitleResourceId( R_MR_VIEWER_CONTEXT_MENU );
       
   395             }        
       
   396         }
       
   397     }
       
   398 
       
   399 // ---------------------------------------------------------------------------
       
   400 // CESMREditorDialog::CreateCustomControlL
       
   401 // ---------------------------------------------------------------------------
       
   402 //
       
   403 SEikControlInfo CESMREditorDialog::CreateCustomControlL(
       
   404         TInt aType )
       
   405     {
       
   406     FUNC_LOG;
       
   407     SEikControlInfo controlInfo;
       
   408     controlInfo.iControl = NULL;
       
   409     controlInfo.iFlags = 0;
       
   410     controlInfo.iTrailerTextId = 0;
       
   411 
       
   412     if ( aType == EEsMrEditorType )
       
   413         {
       
   414         controlInfo.iControl = iView;
       
   415         }
       
   416 
       
   417     return controlInfo;
       
   418     }
       
   419 
       
   420 // ---------------------------------------------------------------------------
       
   421 // CESMREditorDialog::OfferKeyEventL
       
   422 // ---------------------------------------------------------------------------
       
   423 //
       
   424 TKeyResponse CESMREditorDialog::OfferKeyEventL(
       
   425         const TKeyEvent& aEvent,
       
   426         TEventCode aType )
       
   427     {
       
   428     FUNC_LOG;
       
   429 
       
   430     TKeyResponse response( EKeyWasNotConsumed);
       
   431     if ( aEvent.iCode != EKeyEscape && !MenuShowing() && aType == EEventKey)
       
   432         {
       
   433         response = iView->OfferKeyEventL ( aEvent, aType );
       
   434         }
       
   435 
       
   436     if ( response == EKeyWasNotConsumed  )
       
   437         {
       
   438         response = CAknDialog::OfferKeyEventL ( aEvent, aType );
       
   439         }
       
   440 
       
   441     return response;
       
   442     }
       
   443 
       
   444 // ---------------------------------------------------------------------------
       
   445 // CESMREditorDialog::OkToExitL
       
   446 // ---------------------------------------------------------------------------
       
   447 //
       
   448 TBool CESMREditorDialog::OkToExitL( TInt aButtonId )
       
   449     {
       
   450     FUNC_LOG;
       
   451     TBool res( EFalse );
       
   452     
       
   453     switch ( aButtonId )
       
   454         {
       
   455         case EAknSoftkeyOptions:
       
   456             {
       
   457             // Show options menu
       
   458             CAknDialog::DisplayMenuL();
       
   459             break;
       
   460             }
       
   461         case EESMRCmdSaveMR:
       
   462             {
       
   463             ProcessCommandL( EESMRCmdSaveMR );
       
   464             break;
       
   465             }
       
   466         case EAknSoftkeyContextOptions:
       
   467             {
       
   468             // Show context menu
       
   469             if ( iFeatures->FeatureSupported(
       
   470                     CESMRFeatureSettings::EESMRUILocationFeatures ) )
       
   471                 {
       
   472                 iMenuBar->TryDisplayContextMenuBarL();
       
   473                 }
       
   474             break;            
       
   475             }
       
   476         case EESMRCmdAlarmOn:
       
   477         case EESMRCmdAlarmOff:
       
   478         case EESMRCmdOpenPriorityQuery:
       
   479         case EESMRCmdOpenSyncQuery:
       
   480         case EESMRCmdOpenRecurrenceQuery:
       
   481         case EESMRCmdOpenAlarmQuery:
       
   482         case EESMRCmdCheckEvent:
       
   483         case EESMRCmdAttendeeSoftkeySelect:
       
   484         case EESMRCmdAttendeeSoftkeyCancel:
       
   485         case EESMRCmdAttendeeInsertContact:
       
   486             {
       
   487             // Forward to editor
       
   488             TRAPD( err, iView->ProcessEditorCommandL( aButtonId ) )
       
   489             if ( err != KErrNone &&
       
   490                  err != KErrCancel &&
       
   491                  err != KErrArgument )
       
   492                 {
       
   493                 User::Leave(err);
       
   494                 }
       
   495             break;
       
   496             }
       
   497         case EESMRCmdForceExit:
       
   498         case EESMRCmdCalEntryUIDelete:
       
   499         case EESMRCmdDeleteMR:
       
   500             {
       
   501             res = ETrue;
       
   502             break;
       
   503             }
       
   504         case EAknSoftkeyDone:
       
   505             {
       
   506             // Exit dialog
       
   507             TRAPD( err, HandleExitL() )
       
   508             
       
   509             switch ( err )
       
   510                 {
       
   511                 case KErrNone:
       
   512                     {
       
   513                     res = ETrue;
       
   514                     break;
       
   515                     }
       
   516                 case KErrArgument:
       
   517                     {
       
   518                     res = EFalse;
       
   519                     break;
       
   520                     }
       
   521                 default:
       
   522                     {
       
   523                     User::Leave( err );
       
   524                     break;
       
   525                     }
       
   526                 }
       
   527             break;
       
   528             }
       
   529         case EAknCmdExit:
       
   530         case EEikBidCancel:
       
   531             {
       
   532             // Force exit. Don't care about exceptions
       
   533             // just close the dialog
       
   534             TRAP_IGNORE( HandleForcedExitL( aButtonId == EAknCmdExit ) )
       
   535             res = ETrue;
       
   536             break;
       
   537             }
       
   538         default:
       
   539             {
       
   540             break;
       
   541             }
       
   542         }
       
   543 
       
   544     return res;
       
   545     }
       
   546 
       
   547 // ---------------------------------------------------------------------------
       
   548 // CESMREditorDialog::ActivateL
       
   549 // ---------------------------------------------------------------------------
       
   550 //
       
   551 void CESMREditorDialog::ActivateL( )
       
   552     {
       
   553     FUNC_LOG;
       
   554     CAknDialog::ActivateL();
       
   555     iView->InternalizeL();
       
   556     
       
   557     // Notification that MR editor is ready to be shown on screen.
       
   558     if ( iEntry.Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest )
       
   559         {
       
   560         TTime start = iEntry.Entry().StartTimeL().TimeUtcL();
       
   561         TTime now;
       
   562         now.UniversalTime();
       
   563         if ( start < now )
       
   564             {
       
   565             iOccursInPast = ETrue;
       
   566             }
       
   567         iCallback.ProcessCommandL( EESMRCmdEditorInitializationComplete );
       
   568         }
       
   569     }
       
   570 
       
   571 // ---------------------------------------------------------------------------
       
   572 // CESMREditorDialog::IsAllowedToSaveL
       
   573 // ---------------------------------------------------------------------------
       
   574 //
       
   575 TBool CESMREditorDialog::IsAllowedToSaveL()
       
   576     {
       
   577     FUNC_LOG;
       
   578     TBool ret(ETrue);
       
   579 
       
   580 
       
   581     if ( ( iEntry.Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest ||
       
   582             iEntry.Type() == MESMRCalEntry::EESMRCalEntryMeeting ) &&
       
   583          iEntry.IsStoredL() && iEntry.IsRecurrentEventL() &&
       
   584          MESMRCalEntry::EESMRAllInSeries == iEntry.RecurrenceModRule() )
       
   585         {
       
   586         TDateTime originalDate =
       
   587                 iEntry.OriginalEntry().StartTimeL().TimeLocalL().DateTime();
       
   588         TDateTime modifiedDate =
       
   589                 iEntry.Entry().StartTimeL().TimeLocalL().DateTime();
       
   590 
       
   591         if ( !IsSameDay( originalDate, modifiedDate ) )
       
   592         {
       
   593             if ( !CESMRConfirmationQuery::ExecuteL(
       
   594                    CESMRConfirmationQuery::EESMRSaveMeetingChangedStartDay ) )
       
   595                 {
       
   596                 ret = EFalse;
       
   597                 }
       
   598             }
       
   599         }
       
   600 
       
   601     return ret;
       
   602     }
       
   603 
       
   604 // ---------------------------------------------------------------------------
       
   605 // CESMREditorDialog::ProcessCommandL
       
   606 // ---------------------------------------------------------------------------
       
   607 //
       
   608 void CESMREditorDialog::ProcessCommandL(
       
   609         TInt aCommand )
       
   610     {
       
   611     FUNC_LOG;
       
   612     TRAPD( err, DoProcessCommandL( aCommand ) );
       
   613     if ( err != KErrNone &&
       
   614          err != KErrCancel &&
       
   615          err != KErrArgument )
       
   616         {
       
   617         User::Leave(err);
       
   618         }           
       
   619     }
       
   620 
       
   621 // ---------------------------------------------------------------------------
       
   622 // CESMREditorDialog::DoProcessCommandL
       
   623 // ---------------------------------------------------------------------------
       
   624 //
       
   625 void CESMREditorDialog::DoProcessCommandL(
       
   626         TInt aCommand )
       
   627     {
       
   628     FUNC_LOG;
       
   629     CAknDialog::ProcessCommandL ( aCommand );
       
   630 
       
   631     switch ( aCommand )
       
   632         {
       
   633         case EESMRCmdPrint: //Fall through
       
   634         case EESMRCmdPrint_Reserved1: //Fall through
       
   635         case EESMRCmdPrint_Reserved2: //Fall through
       
   636         case EESMRCmdPrint_Reserved3: //Fall through
       
   637         case EESMRCmdPrint_Reserved4:
       
   638             {
       
   639             iView->ExternalizeL(); // no force validation
       
   640             TInt res(KErrGeneral);
       
   641             res = iCallback.ProcessCommandWithResultL ( EESMRCmdSaveMR );
       
   642 
       
   643             if (res == KErrNone )
       
   644                 {
       
   645                 this->MakeVisible(EFalse); 
       
   646                 HandlePrintCommandL (aCommand );
       
   647                 this->MakeVisible(ETrue); 
       
   648                 }
       
   649             break;
       
   650             }
       
   651 
       
   652         case EESMRCmdSendAs:
       
   653             {
       
   654             SendCalendarEntryL (aCommand );
       
   655             break;
       
   656             }
       
   657             // pass-through all calentryui related command to call back
       
   658         case EESMRCmdCalEntryUISend:
       
   659             {
       
   660             User::LeaveIfError(
       
   661             		iCallback.ProcessCommandWithResultL ( aCommand ));
       
   662             break;
       
   663             }
       
   664         case EESMRCmdCalEntryUIDelete:
       
   665             {
       
   666             iView->ExternalizeL(); // no force validation
       
   667             if (!(iCallback.ProcessCommandWithResultL(aCommand) == KErrCancel))
       
   668             	{
       
   669                 TryExitL( EESMRCmdCalEntryUIDelete );
       
   670             	}
       
   671             break;
       
   672             }
       
   673         case EESMRCmdCalEntryUIAddParticipants:
       
   674             {
       
   675             iView->ExternalizeL (); // no force validation
       
   676             User::LeaveIfError( 
       
   677             		iCallback.ProcessCommandWithResultL ( aCommand ));
       
   678             TryExitL ( EESMRCmdForceExit );
       
   679             break;
       
   680             }
       
   681         case EEikBidCancel: //Fall through
       
   682         case EAknCmdExit:
       
   683         	{
       
   684             TryExitL ( aCommand );
       
   685             break;
       
   686         	}
       
   687         case EAknCmdHelp:
       
   688             {
       
   689             iView->LaunchEditorHelpL ( );
       
   690             break;
       
   691             }
       
   692         case EESMRCmdViewTrack:
       
   693             {
       
   694             TInt res = iCallback.ProcessCommandWithResultL( aCommand );
       
   695             break;
       
   696             }
       
   697         case EESMRCmdAddOptAttendee: //Fall through
       
   698         case EESMRCmdPriorityHigh: //Fall through
       
   699         case EESMRCmdPriorityNormal: //Fall through
       
   700         case EESMRCmdPriorityLow:
       
   701             {
       
   702             iView->ProcessEditorCommandL ( aCommand );
       
   703             }
       
   704             break;
       
   705         case EESMRCmdSaveMR:
       
   706             {
       
   707             TInt ret( KErrGeneral );
       
   708             iView->ExternalizeL (); // no force validation
       
   709             if ( IsAllowedToSaveL() )
       
   710                 {
       
   711                 ret = iCallback.ProcessCommandWithResultL ( aCommand );
       
   712                 }
       
   713             if ( ret == KErrNone )
       
   714                 {
       
   715                 if ( iFeatures->FeatureSupported(
       
   716                         CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
       
   717                     {
       
   718                     LocationPluginHandlerL().StoreLocationToHistoryL( iEntry );
       
   719                     }
       
   720                 
       
   721                 if ( iEntry.Type() == MESMRCalEntry::EESMRCalEntryTodo )
       
   722                     {
       
   723                     CESMRGlobalNote* note =
       
   724                         CESMRGlobalNote::NewL( 
       
   725                         		CESMRGlobalNote::EESMRTodoEntrySaved );
       
   726                     note->ExecuteLD();
       
   727                     }
       
   728                 else
       
   729                     {
       
   730                     CESMRGlobalNote* note =
       
   731                         CESMRGlobalNote::NewL( 
       
   732                         		CESMRGlobalNote::EESMREntrySaved );
       
   733                     note->ExecuteLD();
       
   734                     }
       
   735                 }
       
   736             }
       
   737             break;
       
   738 
       
   739         case EESMRCmdSendMR: //Fall through
       
   740         case EESMRCmdSendMRUpdate:
       
   741             {
       
   742             TInt ret( KErrGeneral );
       
   743             iView->ExternalizeL();
       
   744             if ( IsAllowedToSaveL() )
       
   745                 {
       
   746                 ret = iCallback.ProcessCommandWithResultL ( aCommand );
       
   747                 }
       
   748 
       
   749             if ( ret == KErrNone )
       
   750                 {
       
   751                 if ( iFeatures->FeatureSupported(
       
   752                              CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
       
   753                     {
       
   754                     LocationPluginHandlerL().StoreLocationToHistoryL( iEntry );
       
   755                     }
       
   756                 
       
   757                 TInt exitCode = aCommand ==
       
   758                         EESMRCmdDeleteMR ? EESMRCmdDeleteMR : EAknSoftkeyDone;
       
   759                 TryExitL ( exitCode );
       
   760                 }
       
   761             }
       
   762             break;
       
   763 
       
   764         case EESMRCmdDeleteMR:
       
   765             {
       
   766             if ( iEntry.Type () == MESMRCalEntry::EESMRCalEntryMeetingRequest )
       
   767                 {
       
   768                 TBool okToDelete = ETrue;
       
   769 
       
   770                 if ( iEntry.IsRecurrentEventL() )
       
   771                     {
       
   772                     SetRecurrenceModRuleL(
       
   773                        iEntry,
       
   774                        CESMRListQuery::EESMRDeleteThisOccurenceOrSeriesQuery );
       
   775                     }
       
   776                 else
       
   777                     {
       
   778                     okToDelete = CESMRConfirmationQuery::ExecuteL(
       
   779                             CESMRConfirmationQuery::EESMRDeleteMR );
       
   780 
       
   781                     }
       
   782 
       
   783                 if ( okToDelete )
       
   784                     {
       
   785                     // When deleting we do not need to externalize entry
       
   786                     TInt res = iCallback.ProcessCommandWithResultL( aCommand );
       
   787                     if ( res != KErrCancel )
       
   788                         {
       
   789                         TInt exitCode = aCommand == EESMRCmdDeleteMR ?
       
   790                                             EESMRCmdDeleteMR : EAknSoftkeyDone;
       
   791                         TryExitL ( exitCode );
       
   792                         }
       
   793                     }
       
   794                 }
       
   795             }
       
   796             break;
       
   797         
       
   798         case EESMRCmdAssignFromMap:
       
   799         case EESMRCmdLandmarks:
       
   800         case EESMRCmdPreviousLocations:
       
   801         	{
       
   802             if ( iFeatures->FeatureSupported(
       
   803                     CESMRFeatureSettings::EESMRUIMnFwIntegration
       
   804                     | CESMRFeatureSettings::EESMRUILandmarksIntegration
       
   805                     | CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
       
   806                 {
       
   807                 TBool ignoreQuery = EFalse;
       
   808                 
       
   809                 if ( aCommand == EESMRCmdAssignFromMap )
       
   810                     {
       
   811                     HBufC* oldLocation = iEntry.Entry().LocationL().AllocLC();
       
   812                     iView->ExternalizeL();
       
   813                     
       
   814                     // if old and new locations are different and old location
       
   815                     // exists, the user is updating existing location. Let's discard
       
   816                     // the existing coordinates by using command EESMRCmdUpdateFromMap
       
   817                     if ( ( iEntry.Entry().LocationL().Compare( *oldLocation ) != 0
       
   818                            && oldLocation->Length() != 0 )
       
   819                          || iLocationModified )
       
   820                         {
       
   821                         aCommand = EESMRCmdUpdateFromMap;
       
   822                         }
       
   823                     else if ( oldLocation->Length() == 0 )
       
   824                         {
       
   825                         // Assigning location from Maps for first time.
       
   826                         ignoreQuery = EFalse;                                            
       
   827                         }
       
   828                     CleanupStack::PopAndDestroy( oldLocation );
       
   829                     oldLocation = NULL;
       
   830                     }
       
   831                 else
       
   832                     {
       
   833                     iView->ExternalizeL();
       
   834                     }
       
   835                 
       
   836                 iLocationModified |=
       
   837                     LocationPluginHandlerL().HandleCommandL( aCommand,
       
   838                                                          iEntry,
       
   839                                                          ignoreQuery ); 
       
   840                 iView->InternalizeL();
       
   841                 iView->SetControlFocusedL( EESMRFieldLocation );
       
   842                 }
       
   843 			break;
       
   844         	}
       
   845         case EESMRCmdSearchFromContacts:
       
   846         	{
       
   847             if ( iFeatures->FeatureSupported(
       
   848                     CESMRFeatureSettings::EESMRUIContactsIntegration ) )
       
   849                  {
       
   850                  iView->ExternalizeL();
       
   851                  iLocationModified |=
       
   852                      AddressInfoHandlerL().SearchAddressFromContactsL( iEntry );
       
   853                  iView->InternalizeL();
       
   854                  iView->SetControlFocusedL( EESMRFieldLocation );
       
   855                  }
       
   856         	break;
       
   857         	}
       
   858         // Scenarios with viewer location field in editor dialog.
       
   859         case EESMRCmdShowOnMap:
       
   860         case EESMRCmdSearchFromMap:
       
   861             {
       
   862             LocationPluginHandlerL().HandleCommandL(aCommand, iEntry );
       
   863             break;
       
   864             }        	
       
   865         case EAknCmdOpen:
       
   866         	{
       
   867         	HandleOpenCmdL();
       
   868         	break;
       
   869         	}
       
   870         default:
       
   871             break;
       
   872         }
       
   873     }
       
   874 
       
   875 // ---------------------------------------------------------------------------
       
   876 // CESMREditorDialog::DynInitMenuPaneL()
       
   877 // ---------------------------------------------------------------------------
       
   878 //
       
   879 void CESMREditorDialog::DynInitMenuPaneL(
       
   880         TInt aResourceId,
       
   881         CEikMenuPane* aMenu )
       
   882     {
       
   883     FUNC_LOG;
       
   884 
       
   885     if ( iServiceHandler && iServiceHandler->HandleSubmenuL ( *aMenu ) )
       
   886         {
       
   887         return;
       
   888         }
       
   889 
       
   890     if ( aResourceId == R_MR_EDITOR_ORGANIZER_MENU )
       
   891         {
       
   892         
       
   893 	    if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
       
   894 		   {
       
   895 		   // remove help support in pf5250
       
   896 		   aMenu->SetItemDimmed( EAknCmdHelp, ETrue);      
       
   897 		   }        
       
   898         
       
   899         const TInt count(aMenu->NumberOfItemsInPane());
       
   900 		for (TInt i(0); i < count; i++ )
       
   901 			{
       
   902 			CEikMenuPaneItem::SData& item = aMenu->ItemDataByIndexL ( i );
       
   903 			aMenu->SetItemDimmed (
       
   904 						item.iCommandId, 
       
   905 						!iPolicy->IsDefaultCommand(item.iCommandId) );
       
   906 			}
       
   907         
       
   908 		//Open command		
       
   909 		if ( iView->IsComponentFocused( EESMRFieldSync ) ||
       
   910 			 iView->IsComponentFocused( EESMRFieldRecurrence ) ||
       
   911 			 iView->IsComponentFocused( EESMRFieldAlarm ) ||
       
   912 			 iView->IsComponentFocused( EESMRFieldPriority ))			
       
   913 			{
       
   914 			aMenu->SetItemDimmed( EAknCmdOpen, EFalse );
       
   915 			}		
       
   916 		
       
   917 		if( iInterimUtils && !(iInterimUtils->MRViewersEnabledL()))
       
   918 			{ 
       
   919 			aMenu->SetItemDimmed( EESMRCmdCalEntryUIAddParticipants, ETrue );
       
   920 			}
       
   921         
       
   922         // if the entry is saved (stored) and sent to recipients,
       
   923         // show 'Send update', otherwise just 'Send'
       
   924         TBool sentAndStored = iEntry.IsSentL() && iEntry.IsStoredL();
       
   925 
       
   926         // enable send only if attendee editors contain attendees and
       
   927         // entry does not occur in past (unless if this is forwarded
       
   928         // MR in which case the "in past" sending is also allowed).
       
   929         TBool occurredInPastCheckPassed( !iOccursInPast );
       
   930         if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == iEntry.Type() )
       
   931             {
       
   932             // This is meeting request
       
   933             MESMRMeetingRequestEntry* mrEntry = 
       
   934                 static_cast<MESMRMeetingRequestEntry*>( &iEntry );
       
   935             occurredInPastCheckPassed = mrEntry->IsForwardedL();
       
   936             }
       
   937 
       
   938         TBool sendEnabled = 
       
   939 				( iRequiredAttendeesEnabled | iOptionalAttendeesEnabled ) &&
       
   940 				occurredInPastCheckPassed;
       
   941 
       
   942         if ( iPolicy->IsDefaultCommand( EESMRCmdSendMR ) )
       
   943            {
       
   944            aMenu->SetItemDimmed ( EESMRCmdSendMR, !sendEnabled );
       
   945            }
       
   946 
       
   947         if ( iPolicy->IsDefaultCommand(EESMRCmdSendMRUpdate ) )
       
   948            {
       
   949            if ( sendEnabled )
       
   950                {
       
   951                //EESMRCmdSendMRUpdate and EESMRCmdSendMR shouldn't 
       
   952                //be visible at the same time
       
   953                aMenu->SetItemDimmed( EESMRCmdSendMRUpdate, !sentAndStored );
       
   954                if(iPolicy->IsDefaultCommand( EESMRCmdSendMR ) )
       
   955                    {
       
   956                    aMenu->SetItemDimmed( EESMRCmdSendMR, sentAndStored );
       
   957                    }
       
   958                }
       
   959            else
       
   960                {
       
   961                aMenu->SetItemDimmed( EESMRCmdSendMRUpdate, ETrue );
       
   962                }
       
   963            }
       
   964 
       
   965         if(iPolicy->IsDefaultCommand( EESMRCmdViewTrack ) )
       
   966             {
       
   967             //only show tracking view option when item is sent, stored
       
   968             //and when cfsmailbox actually supports attendee status
       
   969 
       
   970             if (SupportsAttendeeStatusL())
       
   971                 {
       
   972                 aMenu->SetItemDimmed( EESMRCmdViewTrack, !sentAndStored );
       
   973                 }
       
   974             else
       
   975                 {
       
   976                 aMenu->SetItemDimmed( EESMRCmdViewTrack, ETrue );
       
   977                 }
       
   978 
       
   979             }
       
   980 
       
   981         if ( iPolicy->IsDefaultCommand( EESMRCmdAddOptAttendee ) )
       
   982             {
       
   983             // if optional attendee (recipient) is already visible, don't show
       
   984             // the menu item.
       
   985             TBool isVisible =
       
   986                     iView->IsComponentVisible( EESMRFieldOptAttendee );
       
   987             aMenu->SetItemDimmed( EESMRCmdAddOptAttendee, isVisible );
       
   988             }
       
   989 
       
   990         // Insert send ui menu for all other entry types than meeting request
       
   991         if ( iEntry.Type ( )!= MESMRCalEntry::EESMRCalEntryMeetingRequest )
       
   992             {
       
   993             TryInsertSendMenuL( aMenu );
       
   994             }
       
   995 
       
   996         if ( FeatureManager::FeatureSupported( 
       
   997         		KFeatureIdPrintingFrameworkCalendarPlugin ) )
       
   998             {
       
   999             // Initiliaze menu
       
  1000             iServiceHandler->InitializeMenuPaneL(
       
  1001                     *aMenu,
       
  1002                     aResourceId,
       
  1003                     EESMRCmdPrint,
       
  1004                     iServiceHandler->InParamListL() );
       
  1005             }
       
  1006         else
       
  1007             {
       
  1008             aMenu->SetItemDimmed( EESMRCmdPrint, ETrue );            
       
  1009             }
       
  1010         
       
  1011         HandleLocationOptionsL( aResourceId, aMenu );
       
  1012         }
       
  1013     
       
  1014     if ( aResourceId == R_LOCATION_OPTIONS
       
  1015          || aResourceId == R_MR_EDITOR_LOCATION_MENU
       
  1016          || aResourceId == R_MR_VIEWER_LOCATION_MENU )
       
  1017         {
       
  1018         HandleLocationOptionsL( aResourceId, aMenu );
       
  1019         }
       
  1020     }
       
  1021 
       
  1022 // ---------------------------------------------------------------------------
       
  1023 // CESMREditorDialog::SupportsAttendeeStatusL
       
  1024 // ---------------------------------------------------------------------------
       
  1025 //
       
  1026 TBool CESMREditorDialog::SupportsAttendeeStatusL( )
       
  1027     {
       
  1028     FUNC_LOG;
       
  1029     TBool supportsAttendeeStatus(EFalse);
       
  1030     CESMRFieldBuilderInterface* plugin = NULL;
       
  1031     TRAPD( error, 
       
  1032     		plugin = CESMRFieldBuilderInterface::CreatePluginL( 
       
  1033 						TUid::Uid(KESMRUIFieldBuilderPluginImplUId) ) );
       
  1034     CleanupStack::PushL( plugin );
       
  1035     
       
  1036     if (error == KErrNone && plugin)
       
  1037         {
       
  1038         TUid uid = {0};
       
  1039         MESMRBuilderExtension* extension = 
       
  1040 			static_cast<MESMRBuilderExtension*>( plugin->ExtensionL(uid) );
       
  1041 
       
  1042         if (extension)
       
  1043             {
       
  1044             supportsAttendeeStatus = 
       
  1045 				extension->CFSMailBoxCapabilityL(
       
  1046 						MESMRBuilderExtension::EMRCFSAttendeeStatus);
       
  1047             }
       
  1048         }
       
  1049 
       
  1050     CleanupStack::PopAndDestroy( plugin );
       
  1051 
       
  1052     return supportsAttendeeStatus;
       
  1053     }
       
  1054 
       
  1055 
       
  1056 // ---------------------------------------------------------------------------
       
  1057 // CESMREditorDialog::ExecuteViewLD
       
  1058 // ---------------------------------------------------------------------------
       
  1059 //
       
  1060 TInt CESMREditorDialog::ExecuteViewLD( )
       
  1061     {
       
  1062     return ExecuteLD( R_MREDITOR_DIALOG );
       
  1063     }
       
  1064 
       
  1065 // ---------------------------------------------------------------------------
       
  1066 // CESMRViewerDialog::Response
       
  1067 // ---------------------------------------------------------------------------
       
  1068 //
       
  1069 TBool CESMREditorDialog::Response(
       
  1070         TInt /*aCommand*/)
       
  1071     {
       
  1072     return EFalse;
       
  1073     }
       
  1074 
       
  1075 // ---------------------------------------------------------------------------
       
  1076 // CESMRViewerDialog::ExitDialog
       
  1077 // ---------------------------------------------------------------------------
       
  1078 //
       
  1079 void CESMREditorDialog::ExitDialog()
       
  1080     {
       
  1081     // This is for mixed field storage's viewer fields.
       
  1082     // Not actual used in editor dialog
       
  1083     }
       
  1084 
       
  1085 // ---------------------------------------------------------------------------
       
  1086 // CESMRViewerDialog::ChangeReadyResponseL
       
  1087 // ---------------------------------------------------------------------------
       
  1088 //
       
  1089 void CESMREditorDialog::ChangeReadyResponseL() // codescanner::LFunctionCantLeave
       
  1090     {
       
  1091     // This is for mixed field storage's viewer fields.
       
  1092     // Not actual used in editor dialog
       
  1093     }
       
  1094 
       
  1095 // ---------------------------------------------------------------------------
       
  1096 // CESMREditorDialog::HandleExitL
       
  1097 // ---------------------------------------------------------------------------
       
  1098 //
       
  1099 TInt CESMREditorDialog::HandleExitL() // codescanner::intleaves
       
  1100     {
       
  1101     FUNC_LOG;
       
  1102     TInt res( KErrNone);
       
  1103 
       
  1104     iView->ExternalizeL(); // no force validation
       
  1105     TBool isStored = iEntry.IsStoredL();
       
  1106 
       
  1107     if ( iEntry.IsEntryEditedL() )
       
  1108         {
       
  1109         if ( IsAllowedToSaveL() )
       
  1110             {
       
  1111             res = iCallback.ProcessCommandWithResultL( EESMRCmdSaveMR );
       
  1112             
       
  1113             if ( res == KErrNone
       
  1114                  && iFeatures->FeatureSupported(
       
  1115                          CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
       
  1116                 {
       
  1117                 LocationPluginHandlerL().StoreLocationToHistoryL( iEntry );
       
  1118                 }
       
  1119             }
       
  1120         else
       
  1121             {
       
  1122             res = KErrCancel;
       
  1123             }
       
  1124         }
       
  1125     return res;
       
  1126     }
       
  1127 
       
  1128 // ---------------------------------------------------------------------------
       
  1129 // CESMREditorDialog::HandleForcedExitL
       
  1130 // ---------------------------------------------------------------------------
       
  1131 //
       
  1132 TInt CESMREditorDialog::HandleForcedExitL( TBool aShowConfirmationQuery ) // codescanner::intleaves
       
  1133     {
       
  1134     FUNC_LOG;
       
  1135     TInt res( KErrNone);
       
  1136 
       
  1137     iView->ExternalizeL ( ETrue ); // force validation should be used
       
  1138 
       
  1139     if ( iEntry.IsEntryEditedL() && 
       
  1140     	 iEntry.Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest)
       
  1141         {
       
  1142         if ( !aShowConfirmationQuery ||
       
  1143              CESMRConfirmationQuery::ExecuteL(
       
  1144         		CESMRConfirmationQuery::EESMRSaveChanges ))
       
  1145             {
       
  1146             res = iCallback.ProcessCommandWithResultL( EESMRCmdSaveMR );
       
  1147             
       
  1148             if ( res == KErrNone
       
  1149                  && iFeatures->FeatureSupported(
       
  1150                          CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
       
  1151                 {
       
  1152                 LocationPluginHandlerL().StoreLocationToHistoryL( iEntry );
       
  1153                 }
       
  1154             }
       
  1155         }
       
  1156     return res;
       
  1157     }
       
  1158 
       
  1159 // ---------------------------------------------------------------------------
       
  1160 // CESMREditorDialog::SendCalendarEntryL
       
  1161 // ---------------------------------------------------------------------------
       
  1162 //
       
  1163 void CESMREditorDialog::SendCalendarEntryL(
       
  1164         TInt aCommandId )
       
  1165     {
       
  1166     FUNC_LOG;
       
  1167     iView->ExternalizeL(); // no force validation
       
  1168     TInt res(KErrGeneral);
       
  1169     res = iCallback.ProcessCommandWithResultL( EESMRCmdSaveMR );
       
  1170 
       
  1171     if ( res == KErrNone )
       
  1172         {
       
  1173         if ( iFeatures->FeatureSupported(
       
  1174                 CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
       
  1175             {
       
  1176             LocationPluginHandlerL().StoreLocationToHistoryL( iEntry );
       
  1177             }
       
  1178         
       
  1179         // we don't need MenuPane in CCalSend but we need it for the API
       
  1180         CEikMenuPane* pane = NULL;
       
  1181 
       
  1182         // Show menu to user
       
  1183         // CCalenSend handles selection internally, 
       
  1184         // so we don't get anything in return
       
  1185         iESMRSendUI->DisplaySendCascadeMenuL( *pane );
       
  1186 
       
  1187         // Try to send
       
  1188         if (iESMRSendUI->CanSendL( aCommandId ) )
       
  1189             {
       
  1190             iESMRSendUI->SendAsVCalendarL( aCommandId, iEntry.Entry ( ) );
       
  1191             }
       
  1192         }
       
  1193     }
       
  1194 
       
  1195 // ---------------------------------------------------------------------------
       
  1196 // CESMREditorDialog::TryInsertSendMenuL
       
  1197 // ---------------------------------------------------------------------------
       
  1198 //
       
  1199 void CESMREditorDialog::TryInsertSendMenuL(
       
  1200         CEikMenuPane* aMenuPane )
       
  1201     {
       
  1202     FUNC_LOG;
       
  1203     // Insert send menu to the next position from "delete"
       
  1204     TInt index(KErrNotFound);
       
  1205     aMenuPane->ItemAndPos(EESMRCmdCalEntryUIDelete, index);
       
  1206     if (index == KErrNotFound)
       
  1207         {
       
  1208         aMenuPane->ItemAndPos(EESMRCmdDeleteMR, index);
       
  1209         }
       
  1210     index++;
       
  1211     iESMRSendUI->DisplaySendMenuItemL(*aMenuPane, index);
       
  1212     }
       
  1213 
       
  1214 // ---------------------------------------------------------------------------
       
  1215 // CESMREditorDialog::HandlePrintCommandL
       
  1216 // ---------------------------------------------------------------------------
       
  1217 //
       
  1218 void CESMREditorDialog::HandlePrintCommandL(
       
  1219         TInt aCommand )
       
  1220     {
       
  1221     FUNC_LOG;
       
  1222     CAiwGenericParamList& inParams = iServiceHandler->InParamListL ( );
       
  1223 
       
  1224     // Param date
       
  1225 
       
  1226     TCalTime startTime = iEntry.Entry().StartTimeL ( );
       
  1227 
       
  1228     TAiwGenericParam dateParam( EGenericParamDateTime);
       
  1229     TTime activeDay = startTime.TimeUtcL ( );
       
  1230 
       
  1231     TAiwGenericParam calendarParam( EGenericParamCalendarItem);
       
  1232     calendarParam.Value().Set ( TUid::Uid (iEntry.Entry().LocalUidL ( ) ) );
       
  1233     inParams.AppendL ( calendarParam );
       
  1234 
       
  1235     // Append date param
       
  1236     dateParam.Value().Set ( activeDay );
       
  1237     inParams.AppendL ( dateParam );
       
  1238 
       
  1239     const TUid uid( TUid::Uid( KUidCalendarApplication ) );
       
  1240     TAiwGenericParam uidParam( EGenericParamApplication);
       
  1241     uidParam.Value().Set ( uid );
       
  1242     inParams.AppendL ( uidParam );
       
  1243 
       
  1244     // Execute service command with given parameters
       
  1245     iServiceHandler->ExecuteMenuCmdL ( aCommand,
       
  1246             inParams, iServiceHandler->OutParamListL ( ), 0,
       
  1247             NULL );
       
  1248     }
       
  1249 
       
  1250 // ---------------------------------------------------------------------------
       
  1251 // CESMREditorDialog::HandleOpenCmdL
       
  1252 // ---------------------------------------------------------------------------
       
  1253 //
       
  1254 void CESMREditorDialog::HandleOpenCmdL()
       
  1255 	{
       
  1256     FUNC_LOG;
       
  1257 	iView->ProcessEditorCommandL( EAknCmdOpen );
       
  1258 	}
       
  1259 
       
  1260 // ---------------------------------------------------------------------------
       
  1261 // CESMREditorDialog::HandleLocationOptionsL
       
  1262 // ---------------------------------------------------------------------------
       
  1263 //
       
  1264 void CESMREditorDialog::HandleLocationOptionsL( TInt aResourceId,
       
  1265                                                 CEikMenuPane* aMenuPane )
       
  1266     {
       
  1267     FUNC_LOG;
       
  1268     TInt menuPos = KErrNotFound;
       
  1269     
       
  1270     if ( aResourceId == R_MR_EDITOR_ORGANIZER_MENU )
       
  1271         {
       
  1272         
       
  1273 	    if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
       
  1274 		   {
       
  1275 		   // remove help support in pf5250
       
  1276 		   aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue);      
       
  1277 		   }        
       
  1278                 
       
  1279         if ( iPolicy->FieldL( EESMRFieldLocation ).iFieldMode == EESMRFieldModeView )
       
  1280             {
       
  1281             // Dim Location cascade menu with viewer field
       
  1282             aMenuPane->SetItemDimmed( EESMRCmdAddLocation, ETrue );
       
  1283             
       
  1284             if ( iFeatures->FeatureSupported(
       
  1285                     CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
       
  1286                 {
       
  1287                 TBool showOnMap =
       
  1288                     LocationPluginHandlerL().IsCommandAvailableL( EESMRCmdShowOnMap,
       
  1289                                                                   iEntry );
       
  1290                 aMenuPane->SetItemDimmed( EESMRCmdShowOnMap, !showOnMap );
       
  1291                 aMenuPane->SetItemDimmed( EESMRCmdSearchFromMap, showOnMap );
       
  1292                 }
       
  1293             }
       
  1294         else if ( aMenuPane->MenuItemExists( EESMRCmdAddLocation, menuPos ) )
       
  1295             {
       
  1296             TInt numOptions = 0; // number of sub menu items
       
  1297             TInt commandId = 0; // command id if only one sub menu item
       
  1298             
       
  1299             if ( iFeatures->FeatureSupported(
       
  1300                     CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
       
  1301                 {
       
  1302                 ++numOptions;
       
  1303                 commandId = EESMRCmdAssignFromMap;
       
  1304                 }
       
  1305             
       
  1306             if ( iFeatures->FeatureSupported(
       
  1307                     CESMRFeatureSettings::EESMRUIContactsIntegration ) )
       
  1308                 {
       
  1309                 ++numOptions;
       
  1310                 commandId = EESMRCmdSearchFromContacts;
       
  1311                 }
       
  1312             
       
  1313             if ( iFeatures->FeatureSupported(
       
  1314                     CESMRFeatureSettings::EESMRUILandmarksIntegration) )
       
  1315                 {
       
  1316                 ++numOptions;
       
  1317                 commandId = EESMRCmdLandmarks;
       
  1318                 }
       
  1319             
       
  1320             if ( iFeatures->FeatureSupported(
       
  1321                     CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
       
  1322                 {
       
  1323                 ++numOptions;
       
  1324                 commandId = EESMRCmdPreviousLocations;
       
  1325                 }
       
  1326                         
       
  1327                         
       
  1328             
       
  1329             if ( numOptions == 0 )
       
  1330                 {
       
  1331                 // Delete whole sub menu
       
  1332                 aMenuPane->DeleteMenuItem( EESMRCmdAddLocation );
       
  1333                 }
       
  1334             else if ( numOptions == 1 )
       
  1335                 {
       
  1336                 // Replace submenu with available command
       
  1337                 aMenuPane->DeleteMenuItem( EESMRCmdAddLocation );
       
  1338                 
       
  1339                 // Insert new menu item
       
  1340                 HBufC* text = LoadOptionsMenuTextLC( commandId );
       
  1341                 CEikMenuPaneItem::SData menuItem;
       
  1342                 menuItem.iCommandId = commandId;
       
  1343                 menuItem.iCascadeId = 0;
       
  1344                 menuItem.iFlags = 0;
       
  1345                 menuItem.iText = *text;
       
  1346                 CleanupStack::PopAndDestroy( text );
       
  1347                 aMenuPane->InsertMenuItemL( menuItem, menuPos );
       
  1348                 }
       
  1349             }
       
  1350         else if ( aMenuPane->MenuItemExists( EESMRCmdPreviousLocations, menuPos )
       
  1351                   && !LocationPluginHandlerL().IsCommandAvailableL(
       
  1352                           EESMRCmdPreviousLocations, iEntry ) )
       
  1353             {
       
  1354             // No items in location history. Dim item.
       
  1355             aMenuPane->SetItemDimmed( EESMRCmdPreviousLocations, ETrue );
       
  1356             }
       
  1357         }
       
  1358     
       
  1359     if ( aResourceId == R_LOCATION_OPTIONS
       
  1360          || aResourceId == R_MR_EDITOR_LOCATION_MENU )
       
  1361         {
       
  1362         TBool assignFromMap = iFeatures->FeatureSupported(
       
  1363                 CESMRFeatureSettings::EESMRUIMnFwIntegration );
       
  1364         aMenuPane->SetItemDimmed( EESMRCmdAssignFromMap, !assignFromMap );
       
  1365         
       
  1366         TBool searchFromContacts = iFeatures->FeatureSupported(
       
  1367                 CESMRFeatureSettings::EESMRUIContactsIntegration );        
       
  1368         aMenuPane->SetItemDimmed( EESMRCmdSearchFromContacts,
       
  1369                                   !searchFromContacts );
       
  1370         
       
  1371         TBool landmarks = iFeatures->FeatureSupported(
       
  1372                 CESMRFeatureSettings::EESMRUILandmarksIntegration );        
       
  1373         aMenuPane->SetItemDimmed( EESMRCmdLandmarks,
       
  1374                                   !landmarks );
       
  1375         
       
  1376         TBool previousLocations = iFeatures->FeatureSupported(
       
  1377                         CESMRFeatureSettings::EESMRUIPreviousLocationsList );
       
  1378         if ( previousLocations
       
  1379              && !LocationPluginHandlerL().IsCommandAvailableL(
       
  1380                      EESMRCmdPreviousLocations, iEntry ) )
       
  1381             {
       
  1382             // No items in history. Dim option.
       
  1383             previousLocations = EFalse;
       
  1384             }
       
  1385         aMenuPane->SetItemDimmed( EESMRCmdPreviousLocations,
       
  1386                                   !previousLocations );
       
  1387         }
       
  1388     
       
  1389     if ( aResourceId == R_MR_VIEWER_LOCATION_MENU )
       
  1390         {
       
  1391         TBool showOnMap =
       
  1392             LocationPluginHandlerL().IsCommandAvailableL( EESMRCmdShowOnMap,
       
  1393                                                           iEntry );
       
  1394         
       
  1395         aMenuPane->SetItemDimmed( EESMRCmdShowOnMap, !showOnMap );
       
  1396         aMenuPane->SetItemDimmed( EESMRCmdSearchFromMap, showOnMap );
       
  1397         
       
  1398         aMenuPane->SetItemDimmed( EESMRCmdEdit,
       
  1399                                   !iPolicy->IsDefaultCommand( EESMRCmdEdit ) );
       
  1400         aMenuPane->SetItemDimmed( EESMRCmdEditLocal,
       
  1401                                   !iPolicy->IsDefaultCommand( EESMRCmdEditLocal ) );
       
  1402         aMenuPane->SetItemDimmed( EESMRCmdCalEntryUIEdit,
       
  1403                                   !iPolicy->IsDefaultCommand( EESMRCmdCalEntryUIEdit ) );
       
  1404         }
       
  1405     }
       
  1406 
       
  1407 // ---------------------------------------------------------------------------
       
  1408 // CESMREditorDialog::LoadOptionsMenuTextLC
       
  1409 // ---------------------------------------------------------------------------
       
  1410 //
       
  1411 HBufC* CESMREditorDialog::LoadOptionsMenuTextLC( TInt aCommandId )
       
  1412     {
       
  1413     FUNC_LOG;
       
  1414     TInt resourceId = 0;
       
  1415     
       
  1416     switch ( aCommandId )
       
  1417         {
       
  1418         case EESMRCmdAssignFromMap:
       
  1419             {
       
  1420             resourceId = R_MEET_REQ_OPTIONS_ASSIGN_FROM_MAP;
       
  1421             break;
       
  1422             }
       
  1423         case EESMRCmdSearchFromContacts:
       
  1424             {
       
  1425             resourceId = R_MEET_REQ_OPTIONS_SEARCH_FROM_CONTACTS;
       
  1426             break;
       
  1427             }
       
  1428         case EESMRCmdPreviousLocations:
       
  1429             {
       
  1430             resourceId = R_MEET_REQ_OPTIONS_PREVIOUS_LOCATIONS;
       
  1431             break;
       
  1432             }
       
  1433         case EESMRCmdLandmarks:
       
  1434             {
       
  1435             resourceId = R_MEET_REQ_OPTIONS_LANDMARKS;
       
  1436             break;
       
  1437             }
       
  1438         default:
       
  1439             {
       
  1440             User::Leave( KErrArgument );
       
  1441             }
       
  1442         }
       
  1443     
       
  1444     HBufC* text = StringLoader::LoadLC( resourceId, iCoeEnv );
       
  1445     return text;
       
  1446     }
       
  1447 
       
  1448 // ---------------------------------------------------------------------------
       
  1449 // CESMREditorDialog::LocationPluginHandlerL
       
  1450 // ---------------------------------------------------------------------------
       
  1451 //
       
  1452 CESMRLocationPluginHandler& CESMREditorDialog::LocationPluginHandlerL()
       
  1453     {
       
  1454     FUNC_LOG;
       
  1455     if ( !iLocationPluginHandler )
       
  1456         {
       
  1457         iLocationPluginHandler = CESMRLocationPluginHandler::NewL( *this );
       
  1458         }
       
  1459     
       
  1460     return *iLocationPluginHandler;
       
  1461     }
       
  1462     
       
  1463 // ---------------------------------------------------------------------------
       
  1464 // CESMREditorDialog::AddressInfoHandlerL
       
  1465 // ---------------------------------------------------------------------------
       
  1466 //
       
  1467 CESMRAddressInfoHandler& CESMREditorDialog::AddressInfoHandlerL()
       
  1468     {
       
  1469     FUNC_LOG;
       
  1470     if ( !iAddressInfoHandler )
       
  1471         {
       
  1472         iAddressInfoHandler = CESMRAddressInfoHandler::NewL();
       
  1473         }
       
  1474     
       
  1475     return *iAddressInfoHandler;
       
  1476     }
       
  1477 
       
  1478 // ---------------------------------------------------------------------------
       
  1479 // CESMREditorDialog::HandleFieldEventL
       
  1480 // ---------------------------------------------------------------------------
       
  1481 //
       
  1482 void CESMREditorDialog::HandleFieldEventL( // codescanner::LFunctionCantLeave
       
  1483         const MESMRFieldEvent& aEvent )
       
  1484     {
       
  1485     FUNC_LOG;
       
  1486     switch ( aEvent.Type() )
       
  1487         {
       
  1488         case MESMRFieldEvent::EESMRFieldCommandEvent:
       
  1489             {
       
  1490             HandleFieldCommandEventL( aEvent );
       
  1491             break;
       
  1492             }
       
  1493         case MESMRFieldEvent::EESMRFieldChangeEvent:
       
  1494             {
       
  1495             HandleFieldChangeEventL( aEvent );
       
  1496             break;    
       
  1497             }
       
  1498         default:
       
  1499             {
       
  1500             break;
       
  1501             }
       
  1502         }
       
  1503     }
       
  1504 
       
  1505 // ---------------------------------------------------------------------------
       
  1506 // CESMREditorDialog::HandleFieldCommandEventL
       
  1507 // ---------------------------------------------------------------------------
       
  1508 //
       
  1509 void CESMREditorDialog::HandleFieldCommandEventL(
       
  1510         const MESMRFieldEvent& aEvent )
       
  1511     {
       
  1512     FUNC_LOG;
       
  1513     TInt* command = static_cast< TInt* >( aEvent.Param( 0 ) );
       
  1514     switch ( *command )
       
  1515         {
       
  1516         case EESMRCmdAttendeeRequiredEnabled:
       
  1517             {
       
  1518             iRequiredAttendeesEnabled = ETrue;
       
  1519             break;
       
  1520             }            
       
  1521         case EESMRCmdAttendeeRequiredDisabled:
       
  1522             {
       
  1523             iRequiredAttendeesEnabled = EFalse;
       
  1524             break;
       
  1525             }            
       
  1526         case EESMRCmdAttendeeOptionalEnabled:
       
  1527             {
       
  1528             iOptionalAttendeesEnabled = ETrue;
       
  1529             break;
       
  1530             }
       
  1531         case EESMRCmdAttendeeOptionalDisabled:
       
  1532             {
       
  1533             iOptionalAttendeesEnabled = EFalse;
       
  1534             break;
       
  1535             }
       
  1536         case EESMRCmdRestoreMiddleSoftKey:
       
  1537             {
       
  1538             CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
  1539             
       
  1540             if ( iPolicy->FieldL( iView->FocusedField() ).iFieldMode
       
  1541                  == EESMRFieldModeView )
       
  1542                 {
       
  1543                 // Dim default MSK if editor contains viewer fields
       
  1544                 cba.MakeCommandVisibleByPosition(
       
  1545                         CEikButtonGroupContainer::EMiddleSoftkeyPosition,
       
  1546                         EFalse );
       
  1547                 }
       
  1548             else
       
  1549                 {
       
  1550                 cba.SetCommandL(
       
  1551                     CEikButtonGroupContainer::EMiddleSoftkeyPosition, 
       
  1552                     R_MR_SELECT_SOFTKEY );
       
  1553                             
       
  1554                 cba.MakeCommandVisibleByPosition(
       
  1555                         CEikButtonGroupContainer::EMiddleSoftkeyPosition,
       
  1556                         ETrue );
       
  1557                 cba.DrawDeferred();
       
  1558                 }
       
  1559             }
       
  1560             break;
       
  1561         case EESMRCmdSizeExceeded:
       
  1562         	iView->ProcessEditorCommandL( *command );
       
  1563         	break;
       
  1564         default:
       
  1565             {
       
  1566             break;
       
  1567             }
       
  1568         }
       
  1569     }
       
  1570     
       
  1571 // ---------------------------------------------------------------------------
       
  1572 // CESMREditorDialog::HandleFieldChangeEventL
       
  1573 // ---------------------------------------------------------------------------
       
  1574 //
       
  1575 void CESMREditorDialog::HandleFieldChangeEventL(
       
  1576         const MESMRFieldEvent& aEvent )
       
  1577     {
       
  1578     FUNC_LOG;
       
  1579     TInt* fieldId = static_cast< TInt* >( aEvent.Param( 0 ) );
       
  1580     switch ( *fieldId )
       
  1581         {
       
  1582         case EESMRFieldLocation:
       
  1583             {
       
  1584             MESMRFieldEventValue* value =
       
  1585                 static_cast< MESMRFieldEventValue* >( aEvent.Param( 1 ) );
       
  1586             if ( iEntry.Entry().LocationL() != value->StringValue() )
       
  1587                 {
       
  1588                 // Show query dialog only if entry has geocoordinates.
       
  1589                 // It can be verified by checking if "Show on map" is available
       
  1590                 // for iEntry as geocoordinates are required for that.
       
  1591                 TBool enableQuery =
       
  1592                     LocationPluginHandlerL().IsCommandAvailableL(
       
  1593                             EESMRCmdShowOnMap, iEntry );
       
  1594                 
       
  1595                 if ( enableQuery
       
  1596                      && CESMRConfirmationQuery::ExecuteL(
       
  1597                         CESMRConfirmationQuery::EESMRAssignUpdatedLocation ) )
       
  1598                     {
       
  1599                     HBufC* oldLocation = iEntry.Entry().LocationL().AllocLC();
       
  1600                     iView->ExternalizeL();
       
  1601                                        
       
  1602                     // if old and new locations are different and old location
       
  1603                     // exists, the user is updating existing location. Let's discard
       
  1604                     // the existing coordinates by using command EESMRCmdUpdateFromMap
       
  1605                     if ( iEntry.Entry().LocationL().Compare( *oldLocation ) != 0 && 
       
  1606                             oldLocation->Length() != 0 )
       
  1607                         {
       
  1608                         LocationPluginHandlerL().HandleCommandL( 
       
  1609                                 EESMRCmdUpdateFromMap, 
       
  1610                                 iEntry );
       
  1611                         }
       
  1612                     else
       
  1613                         {
       
  1614                         LocationPluginHandlerL().HandleCommandL(
       
  1615                             EESMRCmdAssignFromMap,
       
  1616                             iEntry,
       
  1617 							   EFalse );
       
  1618                         }
       
  1619 
       
  1620                     iView->InternalizeL();
       
  1621                     iView->SetControlFocusedL( EESMRFieldLocation );
       
  1622                     
       
  1623                     CleanupStack::PopAndDestroy( oldLocation );
       
  1624                     oldLocation = NULL;
       
  1625                     }
       
  1626                 else if ( enableQuery )
       
  1627                     {
       
  1628                     // Externalize entry, so query won't be displayed
       
  1629                     // again for the same text. 
       
  1630                     iView->ExternalizeL();
       
  1631                     }
       
  1632                 }
       
  1633             break;
       
  1634             }
       
  1635         case EESMRFieldStartDate:
       
  1636             {
       
  1637             if ( iEntry.Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest )
       
  1638                 {
       
  1639                 MESMRFieldEventValue* value =
       
  1640                     static_cast< MESMRFieldEventValue* >( aEvent.Param( 1 ) );
       
  1641                 TTime now;
       
  1642                 now.UniversalTime();
       
  1643                 if ( value->TimeValue() < now )
       
  1644                     {
       
  1645                     // disable send option
       
  1646                     iOccursInPast = ETrue;
       
  1647                     }
       
  1648                 else
       
  1649                     {
       
  1650                     iOccursInPast = EFalse;
       
  1651                     }
       
  1652                 }
       
  1653             break;
       
  1654             }
       
  1655         default:
       
  1656             {
       
  1657             break;
       
  1658             }
       
  1659         }
       
  1660     }
       
  1661 
       
  1662 // EOF
       
  1663