meetingrequest/mrgui/src/cesmreditordialog.cpp
branchRCL_3
changeset 12 4ce476e64c59
parent 1 12c456ceeff2
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 editor dialog
    14 * Description:  ESMR editor dialog
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "emailtrace.h"
       
    19 #include "cesmreditordialog.h"
    18 #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"
    19 #include "esmrgui.hrh"
    54 #include "cesmrview.h"
    20 #include "cesmrview.h"
    55 #include "mesmrmeetingrequestentry.h"
    21 #include "mesmrmeetingrequestentry.h"
    56 #include "cesmrconfirmationquery.h"
    22 #include "cesmrconfirmationquery.h"
    57 #include "cesmrlistquery.h"
    23 #include "cesmrlistquery.h"
    66 #include "esmrinternaluid.h"
    32 #include "esmrinternaluid.h"
    67 #include "cesmrlocationpluginhandler.h"
    33 #include "cesmrlocationpluginhandler.h"
    68 #include "cesmraddressinfohandler.h"
    34 #include "cesmraddressinfohandler.h"
    69 #include "cesmrfeaturesettings.h"
    35 #include "cesmrfeaturesettings.h"
    70 #include "mesmrfieldevent.h"
    36 #include "mesmrfieldevent.h"
    71 
       
    72 #include "esmrconfig.hrh"
    37 #include "esmrconfig.hrh"
       
    38 #include "esmrdef.h"
       
    39 #include "esmrcommands.h"
       
    40 #include "cesmrpolicy.h"
       
    41 #include "cmrtoolbar.h"
       
    42 #include "mmrpolicyprovider.h"
       
    43 #include "mmrinfoprovider.h"
       
    44 #include "cesmrcaldbmgr.h"
       
    45 #include "cmrfocusstrategyeditor.h"
       
    46 #include "cesmrfieldbuilderinterface.h"
       
    47 
       
    48 #include <esmrgui.rsg>
       
    49 #include <apgcli.h>
       
    50 #include <eikenv.h>
       
    51 #include <eikappui.h>
       
    52 #include <avkon.hrh>
       
    53 #include <eikmenup.h>
       
    54 #include <magnentryui.h>
       
    55 #include <layoutmetadata.cdl.h>
       
    56 #include <akndef.h>
       
    57 #include <aknutils.h>
       
    58 #include <aknindicatorcontainer.h>
       
    59 #include <aknenv.h>
       
    60 #include <akneditstateindicator.h>
       
    61 #include <aknnotewrappers.h>
       
    62 #include <documenthandler.h>
       
    63 #include <npdapi.h>
       
    64 #include <calentry.h>
       
    65 #include <calattachment.h>
       
    66 #include <caleninterimutils2.h>
       
    67 #include <akntitle.h>
       
    68 #include <stringloader.h>
       
    69 
       
    70 // DEBUG
       
    71 #include "emailtrace.h"
    73 
    72 
    74 // <cmail> Removed profiling. </cmail>
    73 // <cmail> Removed profiling. </cmail>
    75 
    74 
    76 // Unnamed namespace for local definitions
    75 // Unnamed namespace for local definitions
    77 namespace { // codescanner::namespace
    76 namespace { // codescanner::namespace
    78 
    77 
    79 #ifdef _DEBUG
    78 #ifdef _DEBUG
    80     _LIT( KESMREditDlgPanicTxt, "ESMREDITORDIALOG" );
       
    81     /** Enumeration for panic codes */
    79     /** Enumeration for panic codes */
    82     enum TESMREditDlgPanicCode
    80     enum TESMREditDlgPanicCode
    83         {
    81         {
    84         // Recurrence series query result error
    82         // Recurrence series query result error
    85         EESMREditDlgInvalidSeriesResult = 0,
    83         EESMREditDlgInvalidSeriesResult = 0,
    86         EESMREditDlgDialogLeave
    84         EESMREditDlgDialogLeave
    87         };
    85         };
    88 
    86 
    89     void Panic( TESMREditDlgPanicCode aPanic )
    87     void Panic( TESMREditDlgPanicCode aPanic )
    90         {
    88         {
       
    89         _LIT( KESMREditDlgPanicTxt, "ESMREDITORDIALOG" );
    91         User::Panic ( KESMREditDlgPanicTxt, aPanic );
    90         User::Panic ( KESMREditDlgPanicTxt, aPanic );
    92         }
    91         }
    93 #endif
    92 #endif
    94 
    93 
    95 /**
    94 /**
   135                 break;
   134                 break;
   136             }
   135             }
   137         }
   136         }
   138     else
   137     else
   139         {
   138         {
   140         TInt result =
   139         aEntry.SetModifyingRuleL(
   141                     CESMRListQuery::ExecuteL( aQueryType );
   140                 MESMRMeetingRequestEntry::EESMRThisOnly );
   142 
       
   143                 if( KErrCancel == result )
       
   144                     {
       
   145                     // User has cancelled selecting opening the instance
       
   146                     User::Leave( KErrCancel );
       
   147                     }
       
   148 
       
   149                 TESMRThisOccurenceOrSeriesQuery recurrenceModRule =
       
   150                     static_cast<TESMRThisOccurenceOrSeriesQuery>( result );
       
   151 
       
   152                 switch( recurrenceModRule )
       
   153                     {
       
   154                     case EESMRThisOccurence:
       
   155                         {
       
   156                         aEntry.SetModifyingRuleL(
       
   157                                 MESMRMeetingRequestEntry::EESMRThisOnly );
       
   158                         }
       
   159                         break;
       
   160                     case EESMRSeries:
       
   161                         {
       
   162                         aEntry.SetModifyingRuleL(
       
   163                                 MESMRMeetingRequestEntry::EESMRAllInSeries );
       
   164                         }
       
   165                         break;
       
   166                     default:
       
   167                         __ASSERT_DEBUG( EFalse, Panic(EESMREditDlgInvalidSeriesResult));
       
   168                         break;
       
   169                     }
       
   170         }
   141         }
   171     }
   142     }
   172 
   143 
   173 /**
   144 /**
   174  * Creates correct type of storage for editing calendar entry.
   145  * Creates correct type of storage for editing calendar entry.
   175  * @param aCommandObserver Reference to command observer
   146  * @param aCommandObserver Reference to command observer
   176  * @param aEntry Reference to ES calendar entry
   147  * @param aEntry Reference to ES calendar entry
   177  * @param aPolicy. Pointer to used policy.
   148  * @param aPolicyProvider. Pointer to used policy.
   178  * @param aResponseObserver Pointer to response observer.
   149  * @param aResponseObserver Pointer to response observer.
   179  */
   150  */
   180 CESMRFieldStorage* CreateCorrectStorageLC(
   151 CESMRFieldStorage* CreateCorrectStorageLC(
   181         MESMRFieldEventObserver& aEventObserver,
   152         MESMRFieldEventObserver& aEventObserver,
   182         MESMRCalEntry& aEntry,
   153         MESMRCalEntry& aEntry,
   183         CESMRPolicy* aPolicy,
   154         const CESMRPolicy& aPolicy,
   184         MESMRResponseObserver* aResponseObserver )
   155         MESMRResponseObserver* aResponseObserver )
   185     {
   156     {
   186     CESMRFieldStorage* storage = NULL;
   157     CESMRFieldStorage* storage = NULL;
   187 
   158 
   188     MESMRCalEntry::TESMRRecurrenceModifyingRule rule(
   159     MESMRCalEntry::TESMRRecurrenceModifyingRule rule(
   189             aEntry.RecurrenceModRule() );
   160             aEntry.RecurrenceModRule() );
   190 
   161 
   191     TESMRViewMode mode(
   162     TESMRViewMode mode( aPolicy.ViewMode() );
   192             aPolicy->ViewMode() );
       
   193 
   163 
   194     if ( ( aEntry.IsRecurrentEventL() &&
   164     if ( ( aEntry.IsRecurrentEventL() &&
   195            rule == MESMRCalEntry::EESMRThisOnly ) ||
   165            rule == MESMRCalEntry::EESMRThisOnly ) ||
   196            mode == EESMRForwardMR )
   166            mode == EESMRForwardMR )
   197         {
   167         {
   251 // ---------------------------------------------------------------------------
   221 // ---------------------------------------------------------------------------
   252 // CESMREditorDialog::CESMREditorDialog
   222 // CESMREditorDialog::CESMREditorDialog
   253 // ---------------------------------------------------------------------------
   223 // ---------------------------------------------------------------------------
   254 //
   224 //
   255 CESMREditorDialog::CESMREditorDialog(
   225 CESMREditorDialog::CESMREditorDialog(
   256         MESMRCalEntry& aEntry,
   226         MMRInfoProvider& aInfoProvider,
   257         MAgnEntryUiCallback& aCallback ) :
   227         MAgnEntryUiCallback& aCallback ) :
   258     iEntry( aEntry), iCallback( aCallback)
   228     iInfoProvider( aInfoProvider ),
       
   229     iCallback( aCallback)
   259     {
   230     {
   260     FUNC_LOG;
   231     FUNC_LOG;
   261     // Do nothing
   232     // Do nothing
   262     }
   233     }
   263 
   234 
   266 // ---------------------------------------------------------------------------
   237 // ---------------------------------------------------------------------------
   267 //
   238 //
   268 CESMREditorDialog::~CESMREditorDialog( )
   239 CESMREditorDialog::~CESMREditorDialog( )
   269     {
   240     {
   270     FUNC_LOG;
   241     FUNC_LOG;
   271     if ( iFeatureManagerInitialized )
       
   272         {
       
   273         FeatureManager::UnInitializeLib();
       
   274         }
       
   275 
       
   276     if ( iServiceHandler )
       
   277         {
       
   278         iServiceHandler->DetachMenu ( 
       
   279         		R_MR_EDITOR_ORGANIZER_MENU, 
       
   280         		R_PS_AIW_INTEREST );
       
   281         delete iServiceHandler;
       
   282         }
       
   283 
   242 
   284     delete iESMRSendUI;
   243     delete iESMRSendUI;
   285     if ( iTitlePane )
   244     if ( iTitlePane )
   286         {
   245         {
   287         // Returns the previous title back to titlepane
   246         // Returns the previous title back to titlepane
   288         iTitlePane->Rollback();
   247         iTitlePane->Rollback();
   289         delete iTitlePane;
   248         delete iTitlePane;
   290         }
   249         }
   291 
       
   292     delete iInterimUtils;
   250     delete iInterimUtils;
   293 
       
   294     delete iLocationPluginHandler;
   251     delete iLocationPluginHandler;
   295     
       
   296     delete iAddressInfoHandler;
   252     delete iAddressInfoHandler;
   297     
       
   298     delete iFeatures;
   253     delete iFeatures;
       
   254     delete iToolbar;
       
   255     delete iFocusStrategy;
       
   256 
   299     // iView is deleted by framework because it uses the
   257     // iView is deleted by framework because it uses the
   300     // custom control mechanism.
   258     // custom control mechanism.
   301     }
   259     }
   302 
   260 
   303 // ---------------------------------------------------------------------------
   261 // ---------------------------------------------------------------------------
   304 // CESMREditorDialog::NewL
   262 // CESMREditorDialog::NewL
   305 // ---------------------------------------------------------------------------
   263 // ---------------------------------------------------------------------------
   306 //
   264 //
   307 EXPORT_C CESMREditorDialog* CESMREditorDialog::NewL(
   265 EXPORT_C CESMREditorDialog* CESMREditorDialog::NewL(
   308         CESMRPolicy* aPolicy,
   266         MMRInfoProvider& aInfoProvider,
   309         MESMRCalEntry& aEntry,
       
   310         MAgnEntryUiCallback& aCallback )
   267         MAgnEntryUiCallback& aCallback )
   311     {
   268     {
   312     FUNC_LOG;
   269     FUNC_LOG;
   313     CESMREditorDialog* self =
   270     CESMREditorDialog* self =
   314     new (ELeave) CESMREditorDialog( aEntry, aCallback );
   271     new (ELeave) CESMREditorDialog( aInfoProvider, aCallback );
   315     CleanupStack::PushL( self );
   272     CleanupStack::PushL( self );
   316     self->ConstructL( aPolicy );
   273     self->ConstructL();
   317     CleanupStack::Pop( self );
   274     CleanupStack::Pop( self );
   318     return self;
   275     return self;
   319     }
   276     }
   320 
   277 
   321 // ---------------------------------------------------------------------------
   278 // ---------------------------------------------------------------------------
   322 // CESMREditorDialog::ConstructL
   279 // CESMREditorDialog::ConstructL
   323 // ---------------------------------------------------------------------------
   280 // ---------------------------------------------------------------------------
   324 //
   281 //
   325 void CESMREditorDialog::ConstructL(
   282 void CESMREditorDialog::ConstructL()
   326         CESMRPolicy* aPolicy )
       
   327     {
   283     {
   328     FUNC_LOG;
   284     FUNC_LOG;
   329     CAknDialog::ConstructL ( R_MREDITOR_MENUBAR );
   285     CAknDialog::ConstructL ( R_MREDITOR_MENUBAR );
   330     iPolicy = aPolicy;
       
   331 
   286 
   332     iESMRSendUI = CESMRSendUI::NewL (EESMRCmdSendAs );
   287     iESMRSendUI = CESMRSendUI::NewL (EESMRCmdSendAs );
   333 
   288 
   334     FeatureManager::InitializeLibL();
   289     MESMRCalEntry* entry = iInfoProvider.EntryL();
   335     iFeatureManagerInitialized = ETrue;
   290     CESMRFieldStorage* storage = CreateCorrectStorageLC(
   336 
   291             *this,
   337     // <cmail> remove custom feature KFeatureIdPrintingFrameworkCalendarPlugin 
   292             *entry,
   338     // </cmail>	
   293             iInfoProvider.PolicyProvider().CurrentPolicy(),
   339 
   294             this );
   340     CESMRFieldStorage* storage =
   295 
   341             CreateCorrectStorageLC( *this, iEntry, aPolicy, this );
   296     iStartTimeUtc = entry->Entry().StartTimeL().TimeUtcL();
       
   297 
       
   298     //clean previous toolbar if there is, and be sure restore toolbar area to EMainPane
       
   299     iToolbar = CMRToolbar::NewL();
   342 
   300 
   343     TRect clientRect;
   301     TRect clientRect;
   344     AknLayoutUtils::LayoutMetricsRect(
   302     AknLayoutUtils::LayoutMetricsRect(
   345             AknLayoutUtils::EMainPane,
   303             AknLayoutUtils::EMainPane,
   346             clientRect );
   304             clientRect );
   347 
   305 
       
   306     // Create focus strategy
       
   307     iFocusStrategy = CMRFocusStrategyEditor::NewL( *storage );
       
   308 
   348     // storage ownership is transferred to CESMRView
   309     // storage ownership is transferred to CESMRView
   349     iView = CESMRView::NewL( storage, iEntry, clientRect );
   310     iView = CESMRView::NewL( 
       
   311             storage, 
       
   312             *entry, 
       
   313             clientRect, 
       
   314             *iFocusStrategy,
       
   315             *iToolbar );
       
   316     
       
   317     iView->SetViewMode( EESMREditMR );
   350     CleanupStack::Pop( storage );
   318     CleanupStack::Pop( storage );
   351 
   319 
   352     // try to find subject field and set title pane observer
   320     // try to find subject field and set title pane observer
   353     CESMRField* field = NULL;
   321     CESMRField* field = NULL;
   354     TInt fieldCount( storage->Count() );
   322     TInt fieldCount( storage->Count() );
   364             case EESMRFieldPriority://Fall through
   332             case EESMRFieldPriority://Fall through
   365             case EESMRFieldDetailedSubject:
   333             case EESMRFieldDetailedSubject:
   366                 {
   334                 {
   367                 field->SetTitlePaneObserver( iView );
   335                 field->SetTitlePaneObserver( iView );
   368                 break;
   336                 break;
   369                 }            
   337                 }
   370             default:
   338             default:
   371             	break;
   339                 break;
   372             }
   340             }
   373         }
   341         }
   374 
   342 
   375     TInt titleStringId = -1;
   343     SetTitleL();
   376     switch ( iEntry.Type() )
   344 
   377         {
       
   378         case MESMRCalEntry::EESMRCalEntryMeetingRequest:
       
   379             titleStringId = R_QTN_MEET_REQ_TITLE_MEETING;
       
   380             break;
       
   381         case MESMRCalEntry::EESMRCalEntryMeeting:
       
   382             titleStringId = R_QTN_CALENDAR_TITLE_MEETING;
       
   383             break;
       
   384         case MESMRCalEntry::EESMRCalEntryTodo:
       
   385             titleStringId = R_QTN_CALENDAR_TITLE_TODO;
       
   386             break;
       
   387         case MESMRCalEntry::EESMRCalEntryMemo:
       
   388             titleStringId = R_QTN_CALENDAR_TITLE_MEMO;
       
   389             break;
       
   390         case MESMRCalEntry::EESMRCalEntryReminder:
       
   391             break;
       
   392         case MESMRCalEntry::EESMRCalEntryAnniversary:
       
   393             titleStringId = R_QTN_CALENDAR_TITLE_ANNIVERSARY;
       
   394             break;
       
   395         default:
       
   396             break;
       
   397         }
       
   398     if ( titleStringId != -1 )
       
   399         {
       
   400         iTitlePane = CESMRTitlePaneHandler::NewL( *iEikonEnv );
       
   401         HBufC* titleText = StringLoader::LoadLC( titleStringId, iCoeEnv );
       
   402         iTitlePane->SetNewTitle( titleText );
       
   403         CleanupStack::PopAndDestroy( titleText );
       
   404         }
       
   405     
       
   406     if(!iInterimUtils)
   345     if(!iInterimUtils)
   407         {
   346         {
   408         iInterimUtils = CCalenInterimUtils2::NewL();
   347         iInterimUtils = CCalenInterimUtils2::NewL();
   409         }
   348         }
   410     
   349 
   411     iFeatures = CESMRFeatureSettings::NewL();
   350     iFeatures = CESMRFeatureSettings::NewL();
   412     
   351 
   413     if ( iFeatures->FeatureSupported(
       
   414             CESMRFeatureSettings::EESMRUILocationFeatures ) )
       
   415         {
       
   416         if ( iPolicy->FieldL( EESMRFieldLocation ).iFieldMode == EESMRFieldModeEdit )
       
   417             {
       
   418             iMenuBar->SetContextMenuTitleResourceId( R_MR_EDITOR_CONTEXT_MENU );
       
   419             }
       
   420         else
       
   421             {
       
   422             iMenuBar->SetContextMenuTitleResourceId( R_MR_VIEWER_CONTEXT_MENU );
       
   423             }        
       
   424         }
       
   425     }
   352     }
   426 
   353 
   427 // ---------------------------------------------------------------------------
   354 // ---------------------------------------------------------------------------
   428 // CESMREditorDialog::CreateCustomControlL
   355 // CESMREditorDialog::CreateCustomControlL
   429 // ---------------------------------------------------------------------------
   356 // ---------------------------------------------------------------------------
   475 //
   402 //
   476 TBool CESMREditorDialog::OkToExitL( TInt aButtonId )
   403 TBool CESMREditorDialog::OkToExitL( TInt aButtonId )
   477     {
   404     {
   478     FUNC_LOG;
   405     FUNC_LOG;
   479     TBool res( EFalse );
   406     TBool res( EFalse );
   480     
   407     MESMRCalEntry* entry = iInfoProvider.EntryL();
   481     switch ( aButtonId )
   408     switch ( aButtonId )
   482         {
   409         {
   483         case EAknSoftkeyOptions:
   410         case EAknSoftkeyOptions:
   484             {
   411             {
   485             // Show options menu
   412             // Show options menu
   486             CAknDialog::DisplayMenuL();
   413             CAknDialog::DisplayMenuL();
   487             break;
   414             break;
   488             }
   415             }
       
   416         case EAknSoftkeySend:
       
   417         	{
       
   418             if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == entry->Type() )
       
   419                 {
       
   420                 MESMRMeetingRequestEntry* mrEntry =
       
   421                         static_cast<MESMRMeetingRequestEntry*>( 
       
   422                                 iInfoProvider.EntryL() );
       
   423                         	
       
   424                 const CESMRPolicy& policy = Policy();
       
   425                 if ( policy.IsDefaultCommand(EESMRCmdSendMRUpdate ) &&
       
   426                         ( mrEntry->IsSentL() && mrEntry->IsStoredL() ) )
       
   427                     {
       
   428                     ProcessCommandL( EESMRCmdSendMRUpdate );
       
   429                     }
       
   430                 else
       
   431                     {
       
   432                     ProcessCommandL( EESMRCmdSendMR );
       
   433                     }
       
   434                 }
       
   435         	break;
       
   436             }
   489         case EESMRCmdSaveMR:
   437         case EESMRCmdSaveMR:
   490             {
   438             {
   491             ProcessCommandL( EESMRCmdSaveMR );
   439             ProcessCommandL( EESMRCmdSaveMR );
   492             break;
   440             break;
   493             }
   441             }
       
   442         case EESMREditorAddAttachment:
       
   443             {
       
   444             ProcessCommandL( EESMREditorAddAttachment );
       
   445             break;
       
   446             }
       
   447 
       
   448         case EESMRCmdLongtapDetected:
   494         case EAknSoftkeyContextOptions:
   449         case EAknSoftkeyContextOptions:
   495             {
   450             {
   496             // Show context menu
   451             if( SetContextMenuL() )
   497             if ( iFeatures->FeatureSupported(
   452                 {
   498                     CESMRFeatureSettings::EESMRUILocationFeatures ) )
   453                 ShowContextMenuL();;
   499                 {
   454                 }
   500                 iMenuBar->TryDisplayContextMenuBarL();
   455             break;
   501                 }
       
   502             break;            
       
   503             }
   456             }
   504         case EESMRCmdAlarmOn:
   457         case EESMRCmdAlarmOn:
   505         case EESMRCmdAlarmOff:
   458         case EESMRCmdAlarmOff:
   506         case EESMRCmdOpenPriorityQuery:
   459         case EESMRCmdOpenPriorityQuery:
   507         case EESMRCmdOpenSyncQuery:
   460         case EESMRCmdOpenSyncQuery:
       
   461         case EESMRCmdOpenUnifiedEditorQuery:
       
   462         case EESMRCmdOpenMultiCalenSelectQuery:
   508         case EESMRCmdOpenRecurrenceQuery:
   463         case EESMRCmdOpenRecurrenceQuery:
   509         case EESMRCmdOpenAlarmQuery:
   464         case EESMRCmdOpenAlarmQuery:
   510         case EESMRCmdCheckEvent:
   465         case EESMRCmdCheckEvent:
   511         case EESMRCmdAttendeeSoftkeySelect:
   466         case EESMRCmdAttendeeSoftkeySelect:
   512         case EESMRCmdAttendeeSoftkeyCancel:
   467         case EESMRCmdAttendeeSoftkeyCancel:
   531             }
   486             }
   532         case EAknSoftkeyDone:
   487         case EAknSoftkeyDone:
   533             {
   488             {
   534             // Exit dialog
   489             // Exit dialog
   535             TRAPD( err, HandleExitL() )
   490             TRAPD( err, HandleExitL() )
   536             
   491 
   537             switch ( err )
   492             switch ( err )
   538                 {
   493                 {
   539                 case KErrNone:
   494                 case KErrNone:
   540                     {
   495                     {
   541                     res = ETrue;
   496                     res = ETrue;
   579 void CESMREditorDialog::ActivateL( )
   534 void CESMREditorDialog::ActivateL( )
   580     {
   535     {
   581     FUNC_LOG;
   536     FUNC_LOG;
   582     CAknDialog::ActivateL();
   537     CAknDialog::ActivateL();
   583     iView->InternalizeL();
   538     iView->InternalizeL();
   584     
   539 
   585     // Notification that MR editor is ready to be shown on screen.
   540     // Notification that MR editor is ready to be shown on screen.
   586     if ( iEntry.Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest )
   541     MESMRCalEntry* entry = iInfoProvider.EntryL();
   587         {
   542     if ( entry->Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest )
   588         TTime start = iEntry.Entry().StartTimeL().TimeUtcL();
   543         {
   589         TTime now;
       
   590         now.UniversalTime();
       
   591         if ( start < now )
       
   592             {
       
   593             iOccursInPast = ETrue;
       
   594             }
       
   595         iCallback.ProcessCommandL( EESMRCmdEditorInitializationComplete );
   544         iCallback.ProcessCommandL( EESMRCmdEditorInitializationComplete );
   596         }
   545         }
       
   546 
       
   547     // initial stripe color
       
   548     MESMRCalDbMgr& dbMgr = entry->GetDBMgr();
       
   549     TPtrC calenName = dbMgr.GetCalendarNameByEntryL( *entry );
       
   550     dbMgr.SetCurCalendarByNameL( calenName );
   597     }
   551     }
   598 
   552 
   599 // ---------------------------------------------------------------------------
   553 // ---------------------------------------------------------------------------
   600 // CESMREditorDialog::IsAllowedToSaveL
   554 // CESMREditorDialog::IsAllowedToSaveL
   601 // ---------------------------------------------------------------------------
   555 // ---------------------------------------------------------------------------
   603 TBool CESMREditorDialog::IsAllowedToSaveL()
   557 TBool CESMREditorDialog::IsAllowedToSaveL()
   604     {
   558     {
   605     FUNC_LOG;
   559     FUNC_LOG;
   606     TBool ret(ETrue);
   560     TBool ret(ETrue);
   607 
   561 
   608 
   562     MESMRCalEntry* entry = iInfoProvider.EntryL();
   609     if ( ( iEntry.Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest ||
   563     if ( ( entry->Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest ||
   610             iEntry.Type() == MESMRCalEntry::EESMRCalEntryMeeting ) &&
   564             entry->Type() == MESMRCalEntry::EESMRCalEntryMeeting ) &&
   611          iEntry.IsStoredL() && iEntry.IsRecurrentEventL() &&
   565          entry->IsStoredL() && entry->IsRecurrentEventL() &&
   612          MESMRCalEntry::EESMRAllInSeries == iEntry.RecurrenceModRule() )
   566          MESMRCalEntry::EESMRAllInSeries == entry->RecurrenceModRule() )
   613         {
   567         {
   614         TDateTime originalDate =
   568         TDateTime originalDate =
   615                 iEntry.OriginalEntry().StartTimeL().TimeLocalL().DateTime();
   569                 entry->OriginalEntry().StartTimeL().TimeLocalL().DateTime();
   616         TDateTime modifiedDate =
   570         TDateTime modifiedDate =
   617                 iEntry.Entry().StartTimeL().TimeLocalL().DateTime();
   571                 entry->Entry().StartTimeL().TimeLocalL().DateTime();
   618 
   572 
   619         if ( !IsSameDay( originalDate, modifiedDate ) )
   573         if ( !IsSameDay( originalDate, modifiedDate ) )
   620         {
   574         {
   621             if ( !CESMRConfirmationQuery::ExecuteL(
   575             if ( !CESMRConfirmationQuery::ExecuteL(
   622                    CESMRConfirmationQuery::EESMRSaveMeetingChangedStartDay ) )
   576                    CESMRConfirmationQuery::EESMRSaveMeetingChangedStartDay ) )
   638     {
   592     {
   639     FUNC_LOG;
   593     FUNC_LOG;
   640     TRAPD( err, DoProcessCommandL( aCommand ) );
   594     TRAPD( err, DoProcessCommandL( aCommand ) );
   641     if ( err != KErrNone &&
   595     if ( err != KErrNone &&
   642          err != KErrCancel &&
   596          err != KErrCancel &&
   643          err != KErrArgument&&
   597          err != KErrArgument )
   644          err !=EESMRCmdSendMR)
       
   645         {
   598         {
   646         User::Leave(err);
   599         User::Leave(err);
   647         }           
   600         }
   648     }
   601     }
   649 
   602 
   650 // ---------------------------------------------------------------------------
   603 // ---------------------------------------------------------------------------
   651 // CESMREditorDialog::DoProcessCommandL
   604 // CESMREditorDialog::DoProcessCommandL
   652 // ---------------------------------------------------------------------------
   605 // ---------------------------------------------------------------------------
   655         TInt aCommand )
   608         TInt aCommand )
   656     {
   609     {
   657     FUNC_LOG;
   610     FUNC_LOG;
   658     CAknDialog::ProcessCommandL ( aCommand );
   611     CAknDialog::ProcessCommandL ( aCommand );
   659 
   612 
       
   613     MESMRCalEntry* entry = iInfoProvider.EntryL();
       
   614 
   660     switch ( aCommand )
   615     switch ( aCommand )
   661         {
   616         {
   662         case EESMRCmdPrint: //Fall through
       
   663         case EESMRCmdPrint_Reserved1: //Fall through
       
   664         case EESMRCmdPrint_Reserved2: //Fall through
       
   665         case EESMRCmdPrint_Reserved3: //Fall through
       
   666         case EESMRCmdPrint_Reserved4:
       
   667             {
       
   668             iView->ExternalizeL(); // no force validation
       
   669             TInt res(KErrGeneral);
       
   670             res = iCallback.ProcessCommandWithResultL ( EESMRCmdSaveMR );
       
   671 
       
   672             if (res == KErrNone )
       
   673                 {
       
   674                 this->MakeVisible(EFalse); 
       
   675                 HandlePrintCommandL (aCommand );
       
   676                 this->MakeVisible(ETrue); 
       
   677                 }
       
   678             break;
       
   679             }
       
   680 
       
   681         case EESMRCmdSendAs:
   617         case EESMRCmdSendAs:
   682             {
   618             {
   683             SendCalendarEntryL (aCommand );
   619             SendCalendarEntryL (aCommand );
   684             break;
   620             break;
   685             }
   621             }
   686             // pass-through all calentryui related command to call back
   622             // pass-through all calentryui related command to call back
   687         case EESMRCmdCalEntryUISend:
   623         case EESMRCmdCalEntryUISend:
   688             {
   624             {
   689             User::LeaveIfError(
   625             User::LeaveIfError(
   690             		iCallback.ProcessCommandWithResultL ( aCommand ));
   626                     iCallback.ProcessCommandWithResultL ( aCommand ));
   691             break;
   627             break;
   692             }
   628             }
   693         case EESMRCmdCalEntryUIDelete:
   629         case EESMRCmdCalEntryUIAddParticipants:
   694             {
   630             {
   695             iView->ExternalizeL(); // no force validation
   631             TRAPD( err,  SwitchEntryTypeL( EMRCommandSwitchToMR, ETrue ) )
   696             if (!(iCallback.ProcessCommandWithResultL(aCommand) == KErrCancel))
   632 
       
   633             if (KErrArgument == err )
   697             	{
   634             	{
   698                 TryExitL( EESMRCmdCalEntryUIDelete );
   635             	// There was validation error --> Just show the
       
   636             	// existing editor.
       
   637             	err = KErrNone;
   699             	}
   638             	}
   700             break;
   639             else if ( err )
   701             }
   640                 {
   702         case EESMRCmdCalEntryUIAddParticipants:
   641                 iCoeEnv->HandleError( err );
   703             {
   642                 TryExitL( EESMRCmdForceExit );
   704             iView->ExternalizeL (); // no force validation
   643                 }
   705             TInt result;
   644 
   706             TRAPD(err,result=iCallback.ProcessCommandWithResultL ( aCommand ))
   645             break;
   707 			if (err != EESMRCmdSendMR&&err!=KErrNone)
   646             }
   708 				{
   647         case EAknSoftkeyClose:
   709 				User::Leave(err);
   648             {
   710 				}
   649             TryExitL ( EAknCmdExit );
   711 			User::LeaveIfError(result);
       
   712             TryExitL ( EESMRCmdForceExit );
       
   713             break;
   650             break;
   714             }
   651             }
   715         case EEikBidCancel: //Fall through
   652         case EEikBidCancel: //Fall through
   716         case EAknCmdExit:
   653         case EAknCmdExit:
   717         	{
   654             {
   718             TryExitL ( aCommand );
   655             TryExitL ( aCommand );
   719             break;
   656             break;
   720         	}
   657             }
   721         case EAknCmdHelp:
   658         case EAknCmdHelp:
   722             {
   659             {
   723             iView->LaunchEditorHelpL ( );
   660             iView->LaunchEditorHelpL ( );
   724             break;
   661             break;
   725             }
   662             }
   747             if ( ret == KErrNone )
   684             if ( ret == KErrNone )
   748                 {
   685                 {
   749                 if ( iFeatures->FeatureSupported(
   686                 if ( iFeatures->FeatureSupported(
   750                         CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
   687                         CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
   751                     {
   688                     {
   752                     LocationPluginHandlerL().StoreLocationToHistoryL( iEntry );
   689                     LocationPluginHandlerL().StoreLocationToHistoryL( *entry );
   753                     }
   690                     }
   754                 
   691 
   755                 if ( iEntry.Type() == MESMRCalEntry::EESMRCalEntryTodo )
   692                 if ( entry->Type() == MESMRCalEntry::EESMRCalEntryTodo )
   756                     {
   693                     {
   757                     CESMRGlobalNote* note =
   694                     CESMRGlobalNote* note =
   758                         CESMRGlobalNote::NewL( 
   695                         CESMRGlobalNote::NewL(
   759                         		CESMRGlobalNote::EESMRTodoEntrySaved );
   696                                 CESMRGlobalNote::EESMRTodoEntrySaved );
   760                     note->ExecuteLD();
   697                     note->ExecuteLD();
   761                     }
   698                     }
   762                 else
   699                 else
   763                     {
   700                     {
   764                     CESMRGlobalNote* note =
   701                     CESMRGlobalNote* note =
   765                         CESMRGlobalNote::NewL( 
   702                         CESMRGlobalNote::NewL(
   766                         		CESMRGlobalNote::EESMREntrySaved );
   703                                 CESMRGlobalNote::EESMREntrySaved );
   767                     note->ExecuteLD();
   704                     note->ExecuteLD();
   768                     }
   705                     }
   769                 }
   706                 }
   770             }
   707             }
   771             break;
   708             break;
   772 
   709         case EESMRCmdSaveCloseMR:
       
   710         	{
       
   711             TryExitL( EAknSoftkeyDone );
       
   712         	break;
       
   713         	}
   773         case EESMRCmdSendMR: //Fall through
   714         case EESMRCmdSendMR: //Fall through
   774         case EESMRCmdSendMRUpdate:
   715         case EESMRCmdSendMRUpdate:
   775             {
   716             {
   776             TInt ret( KErrGeneral );
   717             TInt ret( KErrGeneral );
   777             iView->ExternalizeL();
   718             iView->ExternalizeL();
   783             if ( ret == KErrNone )
   724             if ( ret == KErrNone )
   784                 {
   725                 {
   785                 if ( iFeatures->FeatureSupported(
   726                 if ( iFeatures->FeatureSupported(
   786                              CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
   727                              CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
   787                     {
   728                     {
   788                     LocationPluginHandlerL().StoreLocationToHistoryL( iEntry );
   729                     LocationPluginHandlerL().StoreLocationToHistoryL( *entry );
   789                     }
   730                     }
   790                 
   731 
   791                 TInt exitCode = aCommand ==
   732                 TInt exitCode = aCommand ==
   792                         EESMRCmdDeleteMR ? EESMRCmdDeleteMR : EAknSoftkeyDone;
   733                         EESMRCmdDeleteMR ? EESMRCmdDeleteMR : EAknSoftkeyDone;
   793                 TryExitL ( exitCode );
   734                 TryExitL ( exitCode );
   794                 }
   735                 }
   795             }
   736             }
   796             break;
   737             break;
   797 
   738 
   798         case EESMRCmdDeleteMR:
   739         case EESMRCmdDeleteMR:
   799             {
   740         case EESMRCmdCalEntryUIDelete:
   800             if ( iEntry.Type () == MESMRCalEntry::EESMRCalEntryMeetingRequest )
   741             {
   801                 {
   742             TBool okToDelete = ETrue;
   802                 TBool okToDelete = ETrue;
   743 
   803 
   744             if ( entry->IsRecurrentEventL() )
   804                 if ( iEntry.IsRecurrentEventL() )
   745                 {
       
   746                 SetRecurrenceModRuleL(
       
   747                    *entry,
       
   748                    CESMRListQuery::EESMRDeleteThisOccurenceOrSeriesQuery );
       
   749                 }
       
   750             else
       
   751                 {
       
   752                 if( CCalenInterimUtils2::IsMeetingRequestL( entry->Entry() ) )
   805                     {
   753                     {
   806                     SetRecurrenceModRuleL(
   754                     okToDelete = CESMRConfirmationQuery::ExecuteL(
   807                        iEntry,
   755                             CESMRConfirmationQuery::EESMRDeleteMR );
   808                        CESMRListQuery::EESMRDeleteThisOccurenceOrSeriesQuery );
       
   809                     }
   756                     }
   810                 else
   757                 else
   811                     {
   758                     {
   812                     okToDelete = CESMRConfirmationQuery::ExecuteL(
   759                     okToDelete = CESMRConfirmationQuery::ExecuteL(
   813                             CESMRConfirmationQuery::EESMRDeleteMR );
   760                              CESMRConfirmationQuery::EESMRDeleteEntry );
   814 
       
   815                     }
   761                     }
   816 
   762                 }
   817                 if ( okToDelete )
   763 
       
   764             if ( okToDelete )
       
   765                 {
       
   766                 // When deleting we do not need to externalize entry
       
   767                 if( entry->IsStoredL() )
   818                     {
   768                     {
   819                     // When deleting we do not need to externalize entry
       
   820                     TInt res = iCallback.ProcessCommandWithResultL( aCommand );
   769                     TInt res = iCallback.ProcessCommandWithResultL( aCommand );
   821                     if ( res != KErrCancel )
   770                     if ( res != KErrCancel )
   822                         {
   771                         {
   823                         TInt exitCode = aCommand == EESMRCmdDeleteMR ?
   772                         TryExitL( EESMRCmdDeleteMR );
   824                                             EESMRCmdDeleteMR : EAknSoftkeyDone;
       
   825                         TryExitL ( exitCode );
       
   826                         }
   773                         }
   827                     }
   774                     }
   828                 }
   775                 else
   829             }
   776                     {
   830             break;
   777                     TryExitL( EESMRCmdDeleteMR );
   831         
   778                     }
       
   779                 }
       
   780             }
       
   781             break;
       
   782 
   832         case EESMRCmdAssignFromMap:
   783         case EESMRCmdAssignFromMap:
   833         case EESMRCmdLandmarks:
   784         case EESMRCmdLandmarks:
   834         case EESMRCmdPreviousLocations:
   785         case EESMRCmdPreviousLocations:
   835         	{
   786             {
   836             if ( iFeatures->FeatureSupported(
   787             if ( iFeatures->FeatureSupported(
   837                     CESMRFeatureSettings::EESMRUIMnFwIntegration
   788                     CESMRFeatureSettings::EESMRUIMnFwIntegration
   838                     | CESMRFeatureSettings::EESMRUILandmarksIntegration
   789                     | CESMRFeatureSettings::EESMRUILandmarksIntegration
   839                     | CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
   790                     | CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
   840                 {
   791                 {
   841                 TBool ignoreQuery = EFalse;
   792                 TBool ignoreQuery = EFalse;
   842                 
   793 
   843                 if ( aCommand == EESMRCmdAssignFromMap )
   794                 if ( aCommand == EESMRCmdAssignFromMap )
   844                     {
   795                     {
   845                     HBufC* oldLocation = iEntry.Entry().LocationL().AllocLC();
   796                     HBufC* oldLocation = entry->Entry().LocationL().AllocLC();
   846                     iView->ExternalizeL();
   797                     iView->ExternalizeL();
   847                     
   798 
   848                     // if old and new locations are different and old location
   799                     // if old and new locations are different and old location
   849                     // exists, the user is updating existing location. Let's discard
   800                     // exists, the user is updating existing location. Let's discard
   850                     // the existing coordinates by using command EESMRCmdUpdateFromMap
   801                     // the existing coordinates by using command EESMRCmdUpdateFromMap
   851                     if ( ( iEntry.Entry().LocationL().Compare( *oldLocation ) != 0
   802                     if ( ( entry->Entry().LocationL().Compare( *oldLocation ) != 0
   852                            && oldLocation->Length() != 0 )
   803                            && oldLocation->Length() != 0 )
   853                          || iLocationModified )
   804                          || iLocationModified )
   854                         {
   805                         {
   855                         aCommand = EESMRCmdUpdateFromMap;
   806                         aCommand = EESMRCmdUpdateFromMap;
   856                         }
   807                         }
   857                     else if ( oldLocation->Length() == 0 )
   808                     else if ( oldLocation->Length() == 0 )
   858                         {
   809                         {
   859                         // Assigning location from Maps for first time.
   810                         // Assigning location from Maps for first time.
   860                         ignoreQuery = EFalse;                                            
   811                         ignoreQuery = EFalse;
   861                         }
   812                         }
   862                     CleanupStack::PopAndDestroy( oldLocation );
   813                     CleanupStack::PopAndDestroy( oldLocation );
   863                     oldLocation = NULL;
   814                     oldLocation = NULL;
   864                     }
   815                     }
   865                 else
   816                 else
   866                     {
   817                     {
   867                     iView->ExternalizeL();
   818                     iView->ExternalizeL();
   868                     }
   819                     }
   869                 
   820 
   870                 iLocationModified |=
   821                 iLocationModified |=
   871                     LocationPluginHandlerL().HandleCommandL( aCommand,
   822                     LocationPluginHandlerL().HandleCommandL( aCommand,
   872                                                          iEntry,
   823                                                          *entry,
   873                                                          ignoreQuery ); 
   824                                                          ignoreQuery );
   874                 iView->InternalizeL();
   825                 iView->InternalizeL();
   875                 iView->SetControlFocusedL( EESMRFieldLocation );
   826                 iView->SetControlFocusedL( EESMRFieldLocation );
   876                 }
   827                 }
   877 			break;
   828             break;
   878         	}
   829             }
   879         case EESMRCmdSearchFromContacts:
   830         case EESMRCmdSearchFromContacts:
   880         	{
   831             {
   881             if ( iFeatures->FeatureSupported(
   832             if ( iFeatures->FeatureSupported(
   882                     CESMRFeatureSettings::EESMRUIContactsIntegration ) )
   833                     CESMRFeatureSettings::EESMRUIContactsIntegration ) )
   883                  {
   834                  {
   884                  iView->ExternalizeL();
   835                  iView->ExternalizeL();
   885                  iLocationModified |=
   836                  iLocationModified |=
   886                      AddressInfoHandlerL().SearchAddressFromContactsL( iEntry );
   837                      AddressInfoHandlerL().SearchAddressFromContactsL( *entry );
   887                  iView->InternalizeL();
   838                  iView->InternalizeL();
   888                  iView->SetControlFocusedL( EESMRFieldLocation );
   839                  iView->SetControlFocusedL( EESMRFieldLocation );
   889                  }
   840                  }
   890         	break;
   841             break;
   891         	}
   842             }
   892         // Scenarios with viewer location field in editor dialog.
   843         // Scenarios with viewer location field in editor dialog.
   893         case EESMRCmdShowOnMap:
   844         case EESMRCmdShowOnMap:
   894         case EESMRCmdSearchFromMap:
   845         case EESMRCmdSearchFromMap:
   895             {
   846             {
   896             LocationPluginHandlerL().HandleCommandL(aCommand, iEntry );
   847             if ( iFeatures->FeatureSupported(
   897             break;
   848                     CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
   898             }        	
   849                 {
       
   850                 LocationPluginHandlerL().HandleCommandL(aCommand, *entry );
       
   851                 }
       
   852             break;
       
   853             }
   899         case EAknCmdOpen:
   854         case EAknCmdOpen:
   900         	{
   855             {
   901         	HandleOpenCmdL();
   856             HandleOpenCmdL();
   902         	break;
   857             break;
   903         	}
   858             }
       
   859         case EESMRCmdAttendeeInsertContact:
       
   860             {
       
   861             OkToExitL(EESMRCmdAttendeeInsertContact);
       
   862             break;
       
   863             }
       
   864         /*
       
   865         * Attachment field editor context menu commands
       
   866         */
       
   867         case EESMREditorOpenAttachment:
       
   868         case EESMREditorRemoveAttachment:
       
   869         case EESMREditorRemoveAllAttachments:
       
   870         case EESMREditorAddAttachment:
       
   871            {
       
   872            iView->ProcessEditorCommandL( aCommand );
       
   873            break;
       
   874            }
       
   875 
       
   876         case EMRCommandMyLocations:
       
   877             {
       
   878             iView->ExternalizeL();
       
   879             iLocationModified |=
       
   880                 LocationPluginHandlerL().HandleCommandL( aCommand,
       
   881                                                          *entry,
       
   882                                                          EFalse );
       
   883             iView->InternalizeL();
       
   884             iView->SetControlFocusedL( EESMRFieldLocation );
       
   885             break;
       
   886             }
   904         default:
   887         default:
   905             break;
   888             break;
   906         }
   889         }
   907     }
   890     }
   908 
   891 
   913 void CESMREditorDialog::DynInitMenuPaneL(
   896 void CESMREditorDialog::DynInitMenuPaneL(
   914         TInt aResourceId,
   897         TInt aResourceId,
   915         CEikMenuPane* aMenu )
   898         CEikMenuPane* aMenu )
   916     {
   899     {
   917     FUNC_LOG;
   900     FUNC_LOG;
   918 
   901     MESMRCalEntry* entry = iInfoProvider.EntryL();
   919     if ( iServiceHandler && iServiceHandler->HandleSubmenuL ( *aMenu ) )
   902 
   920         {
   903     TMRMenuStyle menuStyle( EMROptionsMenu );
   921         return;
       
   922         }
       
   923 
   904 
   924     if ( aResourceId == R_MR_EDITOR_ORGANIZER_MENU )
   905     if ( aResourceId == R_MR_EDITOR_ORGANIZER_MENU )
   925         {
   906         {
       
   907         const CESMRPolicy& policy = Policy();
       
   908         const TInt count(aMenu->NumberOfItemsInPane());
       
   909         for ( TInt i(0); i < count; i++ )
       
   910             {
       
   911             CEikMenuPaneItem::SData& item = aMenu->ItemDataByIndexL ( i );
       
   912 
       
   913             if ( item.iCommandId )
       
   914                 {
       
   915                 // Checking from policy for commands that has valid command id and
       
   916                 aMenu->SetItemDimmed (
       
   917                             item.iCommandId,
       
   918                             !policy.IsDefaultCommand(item.iCommandId) );
       
   919                 }
       
   920             }
       
   921 
       
   922         //Open command
       
   923         if ( iView->IsComponentFocused( EESMRFieldSync ) ||
       
   924              iView->IsComponentFocused( EESMRFieldRecurrence ) ||
       
   925              iView->IsComponentFocused( EESMRFieldAlarm ) ||
       
   926              iView->IsComponentFocused( EESMRFieldPriority ))
       
   927             {
       
   928             aMenu->SetItemDimmed( EAknCmdOpen, EFalse );
       
   929             }
       
   930 
       
   931         if( iInterimUtils && !(iInterimUtils->MRViewersEnabledL()))
       
   932             {
       
   933             aMenu->SetItemDimmed( EESMRCmdCalEntryUIAddParticipants, ETrue );
       
   934             }
       
   935 
   926         
   936         
   927 	    if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
   937         TBool sendEnabled( EFalse );
   928 		   {
   938         TBool sentAndStored( EFalse );
   929 		   // remove help support in pf5250
       
   930 		   aMenu->SetItemDimmed( EAknCmdHelp, ETrue);      
       
   931 		   }        
       
   932         
   939         
   933         const TInt count(aMenu->NumberOfItemsInPane());
   940         if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == entry->Type() )
   934 		for (TInt i(0); i < count; i++ )
   941             {
   935 			{
   942             MESMRMeetingRequestEntry* mrEntry =
   936 			CEikMenuPaneItem::SData& item = aMenu->ItemDataByIndexL ( i );
   943                     static_cast<MESMRMeetingRequestEntry*>( iInfoProvider.EntryL() );
   937 			aMenu->SetItemDimmed (
       
   938 						item.iCommandId, 
       
   939 						!iPolicy->IsDefaultCommand(item.iCommandId) );
       
   940 			}
       
   941         
   944         
   942 		//Open command		
   945             // if the entry is saved (stored) and sent to recipients,
   943 		if ( iView->IsComponentFocused( EESMRFieldSync ) ||
   946             // show 'Send update', otherwise just 'Send'
   944 			 iView->IsComponentFocused( EESMRFieldRecurrence ) ||
   947             sentAndStored = mrEntry->IsSentL() && mrEntry->IsStoredL();
   945 			 iView->IsComponentFocused( EESMRFieldAlarm ) ||
   948 
   946 			 iView->IsComponentFocused( EESMRFieldPriority ))			
   949             // enable send only if attendee editors contain attendees and
   947 			{
   950             // entry does not occur in past.
   948 			aMenu->SetItemDimmed( EAknCmdOpen, EFalse );
   951             TBool bOccursInPast( OccursInPast( iStartTimeUtc ) );
   949 			}		
   952                 
   950 		
   953             TBool sendEnabled = ( !bOccursInPast &&
   951 		if( iInterimUtils && !(iInterimUtils->MRViewersEnabledL()))
   954                     ( mrEntry->RoleL() == EESMRRoleOrganizer ) &&            
   952 			{ 
   955                     ( iRequiredAttendeesEnabled | iOptionalAttendeesEnabled ) &&
   953 			aMenu->SetItemDimmed( EESMRCmdCalEntryUIAddParticipants, ETrue );
   956                     ((( mrEntry->RoleL() == EESMRRoleOrganizer ) &&
   954 			}
   957                     ( iInfoProvider.PolicyProvider().CurrentPolicy().ViewMode() == EESMREditMR )) ||
       
   958                     ( iInfoProvider.PolicyProvider().CurrentPolicy().ViewMode() == EESMRForwardMR )
       
   959                     ));
       
   960             }
   955         
   961         
   956         // if the entry is saved (stored) and sent to recipients,
   962         if ( policy.IsDefaultCommand( EESMRCmdSendMR ) )
   957         // show 'Send update', otherwise just 'Send'
       
   958         TBool sentAndStored = iEntry.IsSentL() && iEntry.IsStoredL();
       
   959 
       
   960         // enable send only if attendee editors contain attendees and
       
   961         // entry does not occur in past (unless if this is forwarded
       
   962         // MR in which case the "in past" sending is also allowed).
       
   963         TBool occurredInPastCheckPassed( !iOccursInPast );
       
   964         if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == iEntry.Type() )
       
   965             {
       
   966             // This is meeting request
       
   967             MESMRMeetingRequestEntry* mrEntry = 
       
   968                 static_cast<MESMRMeetingRequestEntry*>( &iEntry );
       
   969             occurredInPastCheckPassed = mrEntry->IsForwardedL();
       
   970             }
       
   971 
       
   972         TBool sendEnabled = 
       
   973 				( iRequiredAttendeesEnabled | iOptionalAttendeesEnabled ) &&
       
   974 				occurredInPastCheckPassed;
       
   975 
       
   976         if ( iPolicy->IsDefaultCommand( EESMRCmdSendMR ) )
       
   977            {
   963            {
   978            aMenu->SetItemDimmed ( EESMRCmdSendMR, !sendEnabled );
   964            aMenu->SetItemDimmed ( EESMRCmdSendMR, !sendEnabled );
   979            }
   965            }
   980 
   966 
   981         if ( iPolicy->IsDefaultCommand(EESMRCmdSendMRUpdate ) )
   967         if ( policy.IsDefaultCommand(EESMRCmdSendMRUpdate ) )
   982            {
   968            {
   983            if ( sendEnabled )
   969            if ( sendEnabled )
   984                {
   970                {
   985                //EESMRCmdSendMRUpdate and EESMRCmdSendMR shouldn't 
   971                //EESMRCmdSendMRUpdate and EESMRCmdSendMR shouldn't
   986                //be visible at the same time
   972                //be visible at the same time
   987                aMenu->SetItemDimmed( EESMRCmdSendMRUpdate, !sentAndStored );
   973                aMenu->SetItemDimmed( EESMRCmdSendMRUpdate, !sentAndStored );
   988                if(iPolicy->IsDefaultCommand( EESMRCmdSendMR ) )
   974                if( policy.IsDefaultCommand( EESMRCmdSendMR ) )
   989                    {
   975                    {
   990                    aMenu->SetItemDimmed( EESMRCmdSendMR, sentAndStored );
   976                    aMenu->SetItemDimmed( EESMRCmdSendMR, sentAndStored );
   991                    }
   977                    }
   992                }
   978                }
   993            else
   979            else
   994                {
   980                {
   995                aMenu->SetItemDimmed( EESMRCmdSendMRUpdate, ETrue );
   981                aMenu->SetItemDimmed( EESMRCmdSendMRUpdate, ETrue );
   996                }
   982                }
   997            }
   983            }
   998 
   984 
   999         if(iPolicy->IsDefaultCommand( EESMRCmdViewTrack ) )
   985         if ( policy.IsDefaultCommand( EESMRCmdAddOptAttendee ) )
  1000             {
       
  1001             //only show tracking view option when item is sent, stored
       
  1002             //and when cfsmailbox actually supports attendee status
       
  1003 
       
  1004             if (SupportsAttendeeStatusL())
       
  1005                 {
       
  1006                 aMenu->SetItemDimmed( EESMRCmdViewTrack, !sentAndStored );
       
  1007                 }
       
  1008             else
       
  1009                 {
       
  1010                 aMenu->SetItemDimmed( EESMRCmdViewTrack, ETrue );
       
  1011                 }
       
  1012 
       
  1013             }
       
  1014 
       
  1015         if ( iPolicy->IsDefaultCommand( EESMRCmdAddOptAttendee ) )
       
  1016             {
   986             {
  1017             // if optional attendee (recipient) is already visible, don't show
   987             // if optional attendee (recipient) is already visible, don't show
  1018             // the menu item.
   988             // the menu item.
  1019             TBool isVisible =
   989             TBool isVisible =
  1020                     iView->IsComponentVisible( EESMRFieldOptAttendee );
   990                     iView->IsControlVisible( EESMRFieldOptAttendee );
  1021             aMenu->SetItemDimmed( EESMRCmdAddOptAttendee, isVisible );
   991             aMenu->SetItemDimmed( EESMRCmdAddOptAttendee, isVisible );
  1022             }
   992             }
  1023 
   993 
       
   994         if ( policy.IsDefaultCommand( EESMRCmdViewTrack ) )
       
   995             {
       
   996             //only show tracking view option when item is sent, stored
       
   997             //and when cfsmailbox actually supports attendee status
       
   998 
       
   999             if ( SupportsMailBoxCapabilityL(
       
  1000                     MESMRBuilderExtension::EMRCFSAttendeeStatus ) )
       
  1001                 {
       
  1002                 aMenu->SetItemDimmed( EESMRCmdViewTrack, !sentAndStored );
       
  1003                 }
       
  1004             else
       
  1005                 {
       
  1006                 aMenu->SetItemDimmed( EESMRCmdViewTrack, ETrue );
       
  1007                 }
       
  1008             }
       
  1009 
  1024         // Insert send ui menu for all other entry types than meeting request
  1010         // Insert send ui menu for all other entry types than meeting request
  1025         if ( iEntry.Type ( )!= MESMRCalEntry::EESMRCalEntryMeetingRequest )
  1011         if ( entry->Type ( )!= MESMRCalEntry::EESMRCalEntryMeetingRequest )
  1026             {
  1012             {
  1027             TryInsertSendMenuL( aMenu );
  1013             TryInsertSendMenuL( aMenu );
  1028             }
  1014             }
  1029 
  1015 		}
  1030         if ( FeatureManager::FeatureSupported( 
  1016 
  1031         		KFeatureIdPrintingFrameworkCalendarPlugin ) )
       
  1032             {
       
  1033             // Initiliaze menu
       
  1034             iServiceHandler->InitializeMenuPaneL(
       
  1035                     *aMenu,
       
  1036                     aResourceId,
       
  1037                     EESMRCmdPrint,
       
  1038                     iServiceHandler->InParamListL() );
       
  1039             }
       
  1040         else
       
  1041             {
       
  1042             aMenu->SetItemDimmed( EESMRCmdPrint, ETrue );            
       
  1043             }
       
  1044         
       
  1045         HandleLocationOptionsL( aResourceId, aMenu );
       
  1046         }
       
  1047     
       
  1048     if ( aResourceId == R_LOCATION_OPTIONS
  1017     if ( aResourceId == R_LOCATION_OPTIONS
  1049          || aResourceId == R_MR_EDITOR_LOCATION_MENU
  1018          || aResourceId == R_MR_EDITOR_LOCATION_MENU
  1050          || aResourceId == R_MR_VIEWER_LOCATION_MENU )
  1019          || aResourceId == R_MR_VIEWER_LOCATION_MENU )
  1051         {
  1020         {
       
  1021         menuStyle = EMRContextMenu;
  1052         HandleLocationOptionsL( aResourceId, aMenu );
  1022         HandleLocationOptionsL( aResourceId, aMenu );
  1053         }
  1023         }
       
  1024     if ( aResourceId == R_MR_EDITOR_ATTACHMENT_CONTEXT_MENU
       
  1025          || aResourceId == R_MR_EDITOR_ATTENDEE_CONTEXT_MENU )
       
  1026         {
       
  1027         menuStyle = EMRContextMenu;
       
  1028         }
       
  1029 
       
  1030     // Field specific context menu
       
  1031     iView->DynInitMenuPaneL( menuStyle, aResourceId, aMenu );
  1054     }
  1032     }
  1055 
  1033 
  1056 // ---------------------------------------------------------------------------
  1034 // ---------------------------------------------------------------------------
  1057 // CESMREditorDialog::SupportsAttendeeStatusL
  1035 // CESMREditorDialog::SupportsAttendeeStatusL
  1058 // ---------------------------------------------------------------------------
  1036 // ---------------------------------------------------------------------------
  1059 //
  1037 //
  1060 TBool CESMREditorDialog::SupportsAttendeeStatusL( )
  1038 TBool CESMREditorDialog::SupportsMailBoxCapabilityL(
  1061     {
  1039         MESMRBuilderExtension::TMRCFSMailBoxCapability aCapa )
  1062     FUNC_LOG;
  1040     {
  1063     TBool supportsAttendeeStatus(EFalse);
  1041     FUNC_LOG;
       
  1042     TBool supportsCapability( EFalse );
  1064     CESMRFieldBuilderInterface* plugin = NULL;
  1043     CESMRFieldBuilderInterface* plugin = NULL;
  1065     TRAPD( error, 
  1044     TRAPD( error,
  1066     		plugin = CESMRFieldBuilderInterface::CreatePluginL( 
  1045             plugin = CESMRFieldBuilderInterface::CreatePluginL(
  1067 						TUid::Uid(KESMRUIFieldBuilderPluginImplUId) ) );
  1046                         TUid::Uid( KESMRUIFieldBuilderPluginImplUId ) ) );
  1068     CleanupStack::PushL( plugin );
  1047     CleanupStack::PushL( plugin );
  1069     
  1048 
  1070     if (error == KErrNone && plugin)
  1049     if ( error == KErrNone && plugin )
  1071         {
  1050         {
  1072         TUid uid = {0};
  1051         TUid uid = {0};
  1073         MESMRBuilderExtension* extension = 
  1052         MESMRBuilderExtension* extension =
  1074 			static_cast<MESMRBuilderExtension*>( plugin->ExtensionL(uid) );
  1053             static_cast<MESMRBuilderExtension*>( plugin->ExtensionL( uid ) );
  1075 
  1054 
  1076         if (extension)
  1055         if ( extension )
  1077             {
  1056             {
  1078             supportsAttendeeStatus = 
  1057             supportsCapability =
  1079 				extension->CFSMailBoxCapabilityL(
  1058                 extension->CFSMailBoxCapabilityL( aCapa );
  1080 						MESMRBuilderExtension::EMRCFSAttendeeStatus);
       
  1081             }
  1059             }
  1082         }
  1060         }
  1083 
  1061 
  1084     CleanupStack::PopAndDestroy( plugin );
  1062     CleanupStack::PopAndDestroy( plugin );
  1085 
  1063 
  1086     return supportsAttendeeStatus;
  1064     return supportsCapability;
  1087     }
  1065     }
  1088 
       
  1089 
  1066 
  1090 // ---------------------------------------------------------------------------
  1067 // ---------------------------------------------------------------------------
  1091 // CESMREditorDialog::ExecuteViewLD
  1068 // CESMREditorDialog::ExecuteViewLD
  1092 // ---------------------------------------------------------------------------
  1069 // ---------------------------------------------------------------------------
  1093 //
  1070 //
  1132 //
  1109 //
  1133 TInt CESMREditorDialog::HandleExitL() // codescanner::intleaves
  1110 TInt CESMREditorDialog::HandleExitL() // codescanner::intleaves
  1134     {
  1111     {
  1135     FUNC_LOG;
  1112     FUNC_LOG;
  1136     TInt res( KErrNone);
  1113     TInt res( KErrNone);
  1137 
  1114     
  1138     iView->ExternalizeL(); // no force validation
  1115     iView->ExternalizeL(); // no force validation
  1139     TBool isStored = iEntry.IsStoredL();
  1116 
  1140 
  1117     // If no attendees, switch MR to regular meeting
  1141     if ( iEntry.IsEntryEditedL() )
  1118     VerifyMeetingRequestL();
  1142         {
  1119 
  1143         if ( IsAllowedToSaveL() )
  1120     // Get the entry to be confirmed for saving
       
  1121     MESMRCalEntry* entry = iInfoProvider.EntryL();
       
  1122     
       
  1123     // if entry is stored and type changed, we will always save it
       
  1124     if( entry->IsStoredL() && entry->IsEntryTypeChangedL() )
       
  1125         {
       
  1126         res = TryToSaveEntryL();
       
  1127         }
       
  1128     // If entry is new and type changed, we have to see, if something has
       
  1129     // changed, before we save it.
       
  1130     else if( !entry->IsStoredL() && entry->IsEntryTypeChangedL() )
       
  1131         {
       
  1132         if( entry->IsEntryEditedL() )
       
  1133             {
       
  1134             res = TryToSaveEntryL();
       
  1135             }
       
  1136         }
       
  1137     // Entry is not type changed, we will use normal procedure to
       
  1138     // see if entry will be saved or not.
       
  1139     else
       
  1140         {
       
  1141         if( entry->IsEntryEditedL() )
       
  1142             {
       
  1143             res = TryToSaveEntryL();
       
  1144             }
       
  1145         }
       
  1146 
       
  1147     return res;
       
  1148     }
       
  1149 
       
  1150 // ---------------------------------------------------------------------------
       
  1151 // CESMREditorDialog::HandleForcedExitL
       
  1152 // ---------------------------------------------------------------------------
       
  1153 //
       
  1154 TInt CESMREditorDialog::HandleForcedExitL( TBool aShowConfirmationQuery ) // codescanner::intleaves
       
  1155     {
       
  1156     FUNC_LOG;
       
  1157 
       
  1158     MESMRCalEntry* entry = iInfoProvider.EntryL();
       
  1159 
       
  1160     TInt res( KErrNone);
       
  1161 
       
  1162     iView->ExternalizeL ( ETrue ); // force validation should be used
       
  1163 
       
  1164     // If no attendees, switch MR to regular meeting
       
  1165     VerifyMeetingRequestL();
       
  1166 
       
  1167     // The entry data may be changed by the above function VerifyMeetingRequestL()
       
  1168     entry = iInfoProvider.EntryL();
       
  1169 
       
  1170     if ( entry->IsEntryEditedL() )
       
  1171         {
       
  1172         if ( !aShowConfirmationQuery ||
       
  1173              CESMRConfirmationQuery::ExecuteL(
       
  1174                 CESMRConfirmationQuery::EESMRSaveChanges ))
  1144             {
  1175             {
  1145             res = iCallback.ProcessCommandWithResultL( EESMRCmdSaveMR );
  1176             res = iCallback.ProcessCommandWithResultL( EESMRCmdSaveMR );
  1146             
  1177 
  1147             if ( res == KErrNone
  1178             if ( res == KErrNone
  1148                  && iFeatures->FeatureSupported(
  1179                  && iFeatures->FeatureSupported(
  1149                          CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
  1180                          CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
  1150                 {
  1181                 {
  1151                 LocationPluginHandlerL().StoreLocationToHistoryL( iEntry );
  1182                 LocationPluginHandlerL().StoreLocationToHistoryL( *entry );
  1152                 }
  1183                 }
  1153             }
  1184             }
  1154         else
  1185         }
  1155             {
  1186 
  1156             res = KErrCancel;
       
  1157             }
       
  1158         }
       
  1159     return res;
       
  1160     }
       
  1161 
       
  1162 // ---------------------------------------------------------------------------
       
  1163 // CESMREditorDialog::HandleForcedExitL
       
  1164 // ---------------------------------------------------------------------------
       
  1165 //
       
  1166 TInt CESMREditorDialog::HandleForcedExitL( TBool aShowConfirmationQuery ) // codescanner::intleaves
       
  1167     {
       
  1168     FUNC_LOG;
       
  1169     TInt res( KErrNone);
       
  1170 
       
  1171     iView->ExternalizeL ( ETrue ); // force validation should be used
       
  1172 
       
  1173     if ( iEntry.IsEntryEditedL() && 
       
  1174     	 iEntry.Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest)
       
  1175         {
       
  1176         if ( !aShowConfirmationQuery ||
       
  1177              CESMRConfirmationQuery::ExecuteL(
       
  1178         		CESMRConfirmationQuery::EESMRSaveChanges ))
       
  1179             {
       
  1180             res = iCallback.ProcessCommandWithResultL( EESMRCmdSaveMR );
       
  1181             
       
  1182             if ( res == KErrNone
       
  1183                  && iFeatures->FeatureSupported(
       
  1184                          CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
       
  1185                 {
       
  1186                 LocationPluginHandlerL().StoreLocationToHistoryL( iEntry );
       
  1187                 }
       
  1188             }
       
  1189         }
       
  1190     return res;
  1187     return res;
  1191     }
  1188     }
  1192 
  1189 
  1193 // ---------------------------------------------------------------------------
  1190 // ---------------------------------------------------------------------------
  1194 // CESMREditorDialog::SendCalendarEntryL
  1191 // CESMREditorDialog::SendCalendarEntryL
  1196 //
  1193 //
  1197 void CESMREditorDialog::SendCalendarEntryL(
  1194 void CESMREditorDialog::SendCalendarEntryL(
  1198         TInt aCommandId )
  1195         TInt aCommandId )
  1199     {
  1196     {
  1200     FUNC_LOG;
  1197     FUNC_LOG;
       
  1198 
       
  1199     MESMRCalEntry* entry = iInfoProvider.EntryL();
       
  1200 
  1201     iView->ExternalizeL(); // no force validation
  1201     iView->ExternalizeL(); // no force validation
  1202     TInt res(KErrGeneral);
  1202     TInt res(KErrGeneral);
  1203     res = iCallback.ProcessCommandWithResultL( EESMRCmdSaveMR );
  1203     res = iCallback.ProcessCommandWithResultL( EESMRCmdSaveMR );
  1204 
  1204 
  1205     if ( res == KErrNone )
  1205     if ( res == KErrNone )
  1206         {
  1206         {
  1207         if ( iFeatures->FeatureSupported(
  1207         if ( iFeatures->FeatureSupported(
  1208                 CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
  1208                 CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
  1209             {
  1209             {
  1210             LocationPluginHandlerL().StoreLocationToHistoryL( iEntry );
  1210             LocationPluginHandlerL().StoreLocationToHistoryL( *entry );
  1211             }
  1211             }
  1212         
  1212 
  1213         // we don't need MenuPane in CCalSend but we need it for the API
  1213         // we don't need MenuPane in CCalSend but we need it for the API
  1214         CEikMenuPane* pane = NULL;
  1214         CEikMenuPane* pane = NULL;
  1215 
  1215 
  1216         // Show menu to user
  1216         // Show menu to user
  1217         // CCalenSend handles selection internally, 
  1217         // CCalenSend handles selection internally,
  1218         // so we don't get anything in return
  1218         // so we don't get anything in return
  1219         iESMRSendUI->DisplaySendCascadeMenuL( *pane );
  1219         iESMRSendUI->DisplaySendCascadeMenuL( *pane );
  1220 
  1220 
  1221         // Try to send
  1221         // Try to send
  1222         if (iESMRSendUI->CanSendL( aCommandId ) )
  1222         if (iESMRSendUI->CanSendL( aCommandId ) )
  1223             {
  1223             {
  1224             iESMRSendUI->SendAsVCalendarL( aCommandId, iEntry.Entry ( ) );
  1224             iESMRSendUI->SendAsVCalendarL( aCommandId, entry->Entry ( ) );
  1225             }
  1225             }
  1226         }
  1226         }
  1227     }
  1227     }
  1228 
  1228 
  1229 // ---------------------------------------------------------------------------
  1229 // ---------------------------------------------------------------------------
  1244     index++;
  1244     index++;
  1245     iESMRSendUI->DisplaySendMenuItemL(*aMenuPane, index);
  1245     iESMRSendUI->DisplaySendMenuItemL(*aMenuPane, index);
  1246     }
  1246     }
  1247 
  1247 
  1248 // ---------------------------------------------------------------------------
  1248 // ---------------------------------------------------------------------------
  1249 // CESMREditorDialog::HandlePrintCommandL
       
  1250 // ---------------------------------------------------------------------------
       
  1251 //
       
  1252 void CESMREditorDialog::HandlePrintCommandL(
       
  1253         TInt aCommand )
       
  1254     {
       
  1255     FUNC_LOG;
       
  1256     CAiwGenericParamList& inParams = iServiceHandler->InParamListL ( );
       
  1257 
       
  1258     // Param date
       
  1259 
       
  1260     TCalTime startTime = iEntry.Entry().StartTimeL ( );
       
  1261 
       
  1262     TAiwGenericParam dateParam( EGenericParamDateTime);
       
  1263     TTime activeDay = startTime.TimeUtcL ( );
       
  1264 
       
  1265     TAiwGenericParam calendarParam( EGenericParamCalendarItem);
       
  1266     calendarParam.Value().Set ( TUid::Uid (iEntry.Entry().LocalUidL ( ) ) );
       
  1267     inParams.AppendL ( calendarParam );
       
  1268 
       
  1269     // Append date param
       
  1270     dateParam.Value().Set ( activeDay );
       
  1271     inParams.AppendL ( dateParam );
       
  1272 
       
  1273     const TUid uid( TUid::Uid( KUidCalendarApplication ) );
       
  1274     TAiwGenericParam uidParam( EGenericParamApplication);
       
  1275     uidParam.Value().Set ( uid );
       
  1276     inParams.AppendL ( uidParam );
       
  1277 
       
  1278     // Execute service command with given parameters
       
  1279     iServiceHandler->ExecuteMenuCmdL ( aCommand,
       
  1280             inParams, iServiceHandler->OutParamListL ( ), 0,
       
  1281             NULL );
       
  1282     }
       
  1283 
       
  1284 // ---------------------------------------------------------------------------
       
  1285 // CESMREditorDialog::HandleOpenCmdL
  1249 // CESMREditorDialog::HandleOpenCmdL
  1286 // ---------------------------------------------------------------------------
  1250 // ---------------------------------------------------------------------------
  1287 //
  1251 //
  1288 void CESMREditorDialog::HandleOpenCmdL()
  1252 void CESMREditorDialog::HandleOpenCmdL()
  1289 	{
  1253     {
  1290     FUNC_LOG;
  1254     FUNC_LOG;
  1291 	iView->ProcessEditorCommandL( EAknCmdOpen );
  1255     iView->ProcessEditorCommandL( EAknCmdOpen );
  1292 	}
  1256     }
  1293 
  1257 
  1294 // ---------------------------------------------------------------------------
  1258 // ---------------------------------------------------------------------------
  1295 // CESMREditorDialog::HandleLocationOptionsL
  1259 // CESMREditorDialog::HandleLocationOptionsL
  1296 // ---------------------------------------------------------------------------
  1260 // ---------------------------------------------------------------------------
  1297 //
  1261 //
  1298 void CESMREditorDialog::HandleLocationOptionsL( TInt aResourceId,
  1262 void CESMREditorDialog::HandleLocationOptionsL( TInt aResourceId,
  1299                                                 CEikMenuPane* aMenuPane )
  1263                                                 CEikMenuPane* aMenuPane )
  1300     {
  1264     {
  1301     FUNC_LOG;
  1265     FUNC_LOG;
  1302     TInt menuPos = KErrNotFound;
  1266 
  1303     
  1267     MESMRCalEntry* entry = iInfoProvider.EntryL();
  1304     if ( aResourceId == R_MR_EDITOR_ORGANIZER_MENU )
  1268 
  1305         {
       
  1306         
       
  1307 	    if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
       
  1308 		   {
       
  1309 		   // remove help support in pf5250
       
  1310 		   aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue);      
       
  1311 		   }        
       
  1312                 
       
  1313         if ( iPolicy->FieldL( EESMRFieldLocation ).iFieldMode == EESMRFieldModeView )
       
  1314             {
       
  1315             // Dim Location cascade menu with viewer field
       
  1316             aMenuPane->SetItemDimmed( EESMRCmdAddLocation, ETrue );
       
  1317             
       
  1318             if ( iFeatures->FeatureSupported(
       
  1319                     CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
       
  1320                 {
       
  1321                 TBool showOnMap =
       
  1322                     LocationPluginHandlerL().IsCommandAvailableL( EESMRCmdShowOnMap,
       
  1323                                                                   iEntry );
       
  1324                 aMenuPane->SetItemDimmed( EESMRCmdShowOnMap, !showOnMap );
       
  1325                 aMenuPane->SetItemDimmed( EESMRCmdSearchFromMap, showOnMap );
       
  1326                 }
       
  1327             }
       
  1328         else if ( aMenuPane->MenuItemExists( EESMRCmdAddLocation, menuPos ) )
       
  1329             {
       
  1330             TInt numOptions = 0; // number of sub menu items
       
  1331             TInt commandId = 0; // command id if only one sub menu item
       
  1332             
       
  1333             if ( iFeatures->FeatureSupported(
       
  1334                     CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
       
  1335                 {
       
  1336                 ++numOptions;
       
  1337                 commandId = EESMRCmdAssignFromMap;
       
  1338                 }
       
  1339             
       
  1340             if ( iFeatures->FeatureSupported(
       
  1341                     CESMRFeatureSettings::EESMRUIContactsIntegration ) )
       
  1342                 {
       
  1343                 ++numOptions;
       
  1344                 commandId = EESMRCmdSearchFromContacts;
       
  1345                 }
       
  1346             
       
  1347             if ( iFeatures->FeatureSupported(
       
  1348                     CESMRFeatureSettings::EESMRUILandmarksIntegration) )
       
  1349                 {
       
  1350                 ++numOptions;
       
  1351                 commandId = EESMRCmdLandmarks;
       
  1352                 }
       
  1353             
       
  1354             if ( iFeatures->FeatureSupported(
       
  1355                     CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
       
  1356                 {
       
  1357                 ++numOptions;
       
  1358                 commandId = EESMRCmdPreviousLocations;
       
  1359                 }
       
  1360                         
       
  1361                         
       
  1362             
       
  1363             if ( numOptions == 0 )
       
  1364                 {
       
  1365                 // Delete whole sub menu
       
  1366                 aMenuPane->DeleteMenuItem( EESMRCmdAddLocation );
       
  1367                 }
       
  1368             else if ( numOptions == 1 )
       
  1369                 {
       
  1370                 // Replace submenu with available command
       
  1371                 aMenuPane->DeleteMenuItem( EESMRCmdAddLocation );
       
  1372                 
       
  1373                 // Insert new menu item
       
  1374                 HBufC* text = LoadOptionsMenuTextLC( commandId );
       
  1375                 CEikMenuPaneItem::SData menuItem;
       
  1376                 menuItem.iCommandId = commandId;
       
  1377                 menuItem.iCascadeId = 0;
       
  1378                 menuItem.iFlags = 0;
       
  1379                 menuItem.iText = *text;
       
  1380                 CleanupStack::PopAndDestroy( text );
       
  1381                 aMenuPane->InsertMenuItemL( menuItem, menuPos );
       
  1382                 }
       
  1383             }
       
  1384         else if ( aMenuPane->MenuItemExists( EESMRCmdPreviousLocations, menuPos )
       
  1385                   && !LocationPluginHandlerL().IsCommandAvailableL(
       
  1386                           EESMRCmdPreviousLocations, iEntry ) )
       
  1387             {
       
  1388             // No items in location history. Dim item.
       
  1389             aMenuPane->SetItemDimmed( EESMRCmdPreviousLocations, ETrue );
       
  1390             }
       
  1391         }
       
  1392     
       
  1393     if ( aResourceId == R_LOCATION_OPTIONS
       
  1394          || aResourceId == R_MR_EDITOR_LOCATION_MENU )
       
  1395         {
       
  1396         TBool assignFromMap = iFeatures->FeatureSupported(
       
  1397                 CESMRFeatureSettings::EESMRUIMnFwIntegration );
       
  1398         aMenuPane->SetItemDimmed( EESMRCmdAssignFromMap, !assignFromMap );
       
  1399         
       
  1400         TBool searchFromContacts = iFeatures->FeatureSupported(
       
  1401                 CESMRFeatureSettings::EESMRUIContactsIntegration );        
       
  1402         aMenuPane->SetItemDimmed( EESMRCmdSearchFromContacts,
       
  1403                                   !searchFromContacts );
       
  1404         
       
  1405         TBool landmarks = iFeatures->FeatureSupported(
       
  1406                 CESMRFeatureSettings::EESMRUILandmarksIntegration );        
       
  1407         aMenuPane->SetItemDimmed( EESMRCmdLandmarks,
       
  1408                                   !landmarks );
       
  1409         
       
  1410         TBool previousLocations = iFeatures->FeatureSupported(
       
  1411                         CESMRFeatureSettings::EESMRUIPreviousLocationsList );
       
  1412         if ( previousLocations
       
  1413              && !LocationPluginHandlerL().IsCommandAvailableL(
       
  1414                      EESMRCmdPreviousLocations, iEntry ) )
       
  1415             {
       
  1416             // No items in history. Dim option.
       
  1417             previousLocations = EFalse;
       
  1418             }
       
  1419         aMenuPane->SetItemDimmed( EESMRCmdPreviousLocations,
       
  1420                                   !previousLocations );
       
  1421         }
       
  1422     
       
  1423     if ( aResourceId == R_MR_VIEWER_LOCATION_MENU )
  1269     if ( aResourceId == R_MR_VIEWER_LOCATION_MENU )
  1424         {
  1270         {
  1425         TBool showOnMap =
  1271         TBool showOnMap = EFalse;
  1426             LocationPluginHandlerL().IsCommandAvailableL( EESMRCmdShowOnMap,
  1272         TBool searchFromMap = EFalse;
  1427                                                           iEntry );
  1273 
  1428         
  1274         if ( iFeatures->FeatureSupported(
       
  1275                 CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
       
  1276             {
       
  1277             showOnMap = LocationPluginHandlerL().IsCommandAvailableL(
       
  1278                     EESMRCmdShowOnMap,
       
  1279                     *entry );
       
  1280             searchFromMap = !showOnMap;
       
  1281             }
       
  1282 
  1429         aMenuPane->SetItemDimmed( EESMRCmdShowOnMap, !showOnMap );
  1283         aMenuPane->SetItemDimmed( EESMRCmdShowOnMap, !showOnMap );
  1430         aMenuPane->SetItemDimmed( EESMRCmdSearchFromMap, showOnMap );
  1284         aMenuPane->SetItemDimmed( EESMRCmdSearchFromMap, !searchFromMap );
  1431         
  1285 
       
  1286         const CESMRPolicy& policy = Policy();
  1432         aMenuPane->SetItemDimmed( EESMRCmdEdit,
  1287         aMenuPane->SetItemDimmed( EESMRCmdEdit,
  1433                                   !iPolicy->IsDefaultCommand( EESMRCmdEdit ) );
  1288                                   !policy.IsDefaultCommand( EESMRCmdEdit ) );
  1434         aMenuPane->SetItemDimmed( EESMRCmdEditLocal,
  1289         aMenuPane->SetItemDimmed( EESMRCmdEditLocal,
  1435                                   !iPolicy->IsDefaultCommand( EESMRCmdEditLocal ) );
  1290                                   !policy.IsDefaultCommand( EESMRCmdEditLocal ) );
  1436         aMenuPane->SetItemDimmed( EESMRCmdCalEntryUIEdit,
  1291         aMenuPane->SetItemDimmed( EESMRCmdCalEntryUIEdit,
  1437                                   !iPolicy->IsDefaultCommand( EESMRCmdCalEntryUIEdit ) );
  1292                                   !policy.IsDefaultCommand( EESMRCmdCalEntryUIEdit ) );
  1438         }
  1293         }
  1439     }
       
  1440 
       
  1441 // ---------------------------------------------------------------------------
       
  1442 // CESMREditorDialog::LoadOptionsMenuTextLC
       
  1443 // ---------------------------------------------------------------------------
       
  1444 //
       
  1445 HBufC* CESMREditorDialog::LoadOptionsMenuTextLC( TInt aCommandId )
       
  1446     {
       
  1447     FUNC_LOG;
       
  1448     TInt resourceId = 0;
       
  1449     
       
  1450     switch ( aCommandId )
       
  1451         {
       
  1452         case EESMRCmdAssignFromMap:
       
  1453             {
       
  1454             resourceId = R_MEET_REQ_OPTIONS_ASSIGN_FROM_MAP;
       
  1455             break;
       
  1456             }
       
  1457         case EESMRCmdSearchFromContacts:
       
  1458             {
       
  1459             resourceId = R_MEET_REQ_OPTIONS_SEARCH_FROM_CONTACTS;
       
  1460             break;
       
  1461             }
       
  1462         case EESMRCmdPreviousLocations:
       
  1463             {
       
  1464             resourceId = R_MEET_REQ_OPTIONS_PREVIOUS_LOCATIONS;
       
  1465             break;
       
  1466             }
       
  1467         case EESMRCmdLandmarks:
       
  1468             {
       
  1469             resourceId = R_MEET_REQ_OPTIONS_LANDMARKS;
       
  1470             break;
       
  1471             }
       
  1472         default:
       
  1473             {
       
  1474             User::Leave( KErrArgument );
       
  1475             }
       
  1476         }
       
  1477     
       
  1478     HBufC* text = StringLoader::LoadLC( resourceId, iCoeEnv );
       
  1479     return text;
       
  1480     }
  1294     }
  1481 
  1295 
  1482 // ---------------------------------------------------------------------------
  1296 // ---------------------------------------------------------------------------
  1483 // CESMREditorDialog::LocationPluginHandlerL
  1297 // CESMREditorDialog::LocationPluginHandlerL
  1484 // ---------------------------------------------------------------------------
  1298 // ---------------------------------------------------------------------------
  1488     FUNC_LOG;
  1302     FUNC_LOG;
  1489     if ( !iLocationPluginHandler )
  1303     if ( !iLocationPluginHandler )
  1490         {
  1304         {
  1491         iLocationPluginHandler = CESMRLocationPluginHandler::NewL( *this );
  1305         iLocationPluginHandler = CESMRLocationPluginHandler::NewL( *this );
  1492         }
  1306         }
  1493     
  1307 
  1494     return *iLocationPluginHandler;
  1308     return *iLocationPluginHandler;
  1495     }
  1309     }
  1496     
  1310 
  1497 // ---------------------------------------------------------------------------
  1311 // ---------------------------------------------------------------------------
  1498 // CESMREditorDialog::AddressInfoHandlerL
  1312 // CESMREditorDialog::AddressInfoHandlerL
  1499 // ---------------------------------------------------------------------------
  1313 // ---------------------------------------------------------------------------
  1500 //
  1314 //
  1501 CESMRAddressInfoHandler& CESMREditorDialog::AddressInfoHandlerL()
  1315 CESMRAddressInfoHandler& CESMREditorDialog::AddressInfoHandlerL()
  1503     FUNC_LOG;
  1317     FUNC_LOG;
  1504     if ( !iAddressInfoHandler )
  1318     if ( !iAddressInfoHandler )
  1505         {
  1319         {
  1506         iAddressInfoHandler = CESMRAddressInfoHandler::NewL();
  1320         iAddressInfoHandler = CESMRAddressInfoHandler::NewL();
  1507         }
  1321         }
  1508     
  1322 
  1509     return *iAddressInfoHandler;
  1323     return *iAddressInfoHandler;
  1510     }
  1324     }
  1511 
  1325 
  1512 // ---------------------------------------------------------------------------
  1326 // ---------------------------------------------------------------------------
  1513 // CESMREditorDialog::HandleFieldEventL
  1327 // CESMREditorDialog::HandleFieldEventL
  1525             break;
  1339             break;
  1526             }
  1340             }
  1527         case MESMRFieldEvent::EESMRFieldChangeEvent:
  1341         case MESMRFieldEvent::EESMRFieldChangeEvent:
  1528             {
  1342             {
  1529             HandleFieldChangeEventL( aEvent );
  1343             HandleFieldChangeEventL( aEvent );
  1530             break;    
  1344             break;
  1531             }
  1345             }
  1532         default:
  1346         default:
  1533             {
  1347             {
  1534             break;
  1348             break;
  1535             }
  1349             }
  1542 //
  1356 //
  1543 void CESMREditorDialog::HandleFieldCommandEventL(
  1357 void CESMREditorDialog::HandleFieldCommandEventL(
  1544         const MESMRFieldEvent& aEvent )
  1358         const MESMRFieldEvent& aEvent )
  1545     {
  1359     {
  1546     FUNC_LOG;
  1360     FUNC_LOG;
       
  1361     CEikButtonGroupContainer& cba = ButtonGroupContainer();
  1547     TInt* command = static_cast< TInt* >( aEvent.Param( 0 ) );
  1362     TInt* command = static_cast< TInt* >( aEvent.Param( 0 ) );
  1548     switch ( *command )
  1363     switch ( *command )
  1549         {
  1364         {
  1550         case EESMRCmdAttendeeRequiredEnabled:
  1365         case EESMRCmdAttendeeRequiredEnabled:
  1551             {
  1366             {
  1552             iRequiredAttendeesEnabled = ETrue;
  1367             iRequiredAttendeesEnabled = ETrue;
  1553             break;
  1368             break;
  1554             }            
  1369             }
  1555         case EESMRCmdAttendeeRequiredDisabled:
  1370         case EESMRCmdAttendeeRequiredDisabled:
  1556             {
  1371             {
  1557             iRequiredAttendeesEnabled = EFalse;
  1372             iRequiredAttendeesEnabled = EFalse;
  1558             break;
  1373             break;
  1559             }            
  1374             }
  1560         case EESMRCmdAttendeeOptionalEnabled:
  1375         case EESMRCmdAttendeeOptionalEnabled:
  1561             {
  1376             {
  1562             iOptionalAttendeesEnabled = ETrue;
  1377             iOptionalAttendeesEnabled = ETrue;
  1563             break;
  1378             break;
  1564             }
  1379             }
  1567             iOptionalAttendeesEnabled = EFalse;
  1382             iOptionalAttendeesEnabled = EFalse;
  1568             break;
  1383             break;
  1569             }
  1384             }
  1570         case EESMRCmdRestoreMiddleSoftKey:
  1385         case EESMRCmdRestoreMiddleSoftKey:
  1571             {
  1386             {
  1572             CEikButtonGroupContainer& cba = ButtonGroupContainer();
  1387             iContextMenuResourceId = 0;
  1573             
  1388 
  1574             if ( iPolicy->FieldL( iView->FocusedField() ).iFieldMode
  1389             if ( Policy().FieldL(
  1575                  == EESMRFieldModeView )
  1390                     iView->FocusedField() ).iFieldMode == EESMRFieldModeView )
  1576                 {
  1391                 {
  1577                 // Dim default MSK if editor contains viewer fields
  1392                 // Dim default MSK if editor contains viewer fields
  1578                 cba.MakeCommandVisibleByPosition(
  1393                 cba.MakeCommandVisibleByPosition(
  1579                         CEikButtonGroupContainer::EMiddleSoftkeyPosition,
  1394                         CEikButtonGroupContainer::EMiddleSoftkeyPosition,
  1580                         EFalse );
  1395                         EFalse );
  1581                 }
  1396                 }
  1582             else
  1397             else
  1583                 {
  1398                 {
  1584                 cba.SetCommandL(
  1399                 cba.SetCommandL(
  1585                     CEikButtonGroupContainer::EMiddleSoftkeyPosition, 
  1400                     CEikButtonGroupContainer::EMiddleSoftkeyPosition,
  1586                     R_MR_SELECT_SOFTKEY );
  1401                     R_MR_SELECT_SOFTKEY );
  1587                             
  1402 
  1588                 cba.MakeCommandVisibleByPosition(
  1403                 cba.MakeCommandVisibleByPosition(
  1589                         CEikButtonGroupContainer::EMiddleSoftkeyPosition,
  1404                         CEikButtonGroupContainer::EMiddleSoftkeyPosition,
  1590                         ETrue );
  1405                         ETrue );
  1591                 cba.DrawDeferred();
  1406                 cba.DrawDeferred();
  1592                 }
  1407                 }
  1593             }
  1408             }
  1594             break;
  1409             break;
  1595         case EESMRCmdSizeExceeded:
  1410         case EESMRCmdSizeExceeded:
  1596         	iView->ProcessEditorCommandL( *command );
  1411             iView->ProcessEditorCommandL( *command );
  1597         	break;
  1412             break;
       
  1413 
       
  1414         case EMRCommandSwitchToMR:
       
  1415         case EMRCommandSwitchToMeeting:
       
  1416         case EMRCommandSwitchToMemo:
       
  1417         case EMRCommandSwitchToAnniversary:
       
  1418         case EMRCommandSwitchToTodo:
       
  1419             {
       
  1420             TRAPD( err, SwitchEntryTypeL( *command, ETrue ) )
       
  1421 
       
  1422             if (KErrArgument == err )
       
  1423                  {
       
  1424                  // There was validation error --> Just show the
       
  1425                  // existing editor.
       
  1426                  err = KErrNone;
       
  1427                  }
       
  1428              else if ( err )
       
  1429                 {
       
  1430                 // UI and engine not consistent. Show error and exit
       
  1431                 iCoeEnv->HandleError( err );
       
  1432                 TryExitL( EESMRCmdForceExit );
       
  1433                 }
       
  1434 
       
  1435             break;
       
  1436             }
       
  1437         case EESMRCmdLongtapDetected:
       
  1438             {
       
  1439             OkToExitL(EESMRCmdLongtapDetected);
       
  1440             break;
       
  1441             }
       
  1442         case EMRLaunchAttachmentContextMenu:
       
  1443         case EAknSoftkeyContextOptions:
       
  1444             {
       
  1445             OkToExitL( EAknSoftkeyContextOptions );
       
  1446             break;
       
  1447             }
       
  1448         case EESMRCmdCalendarChange:
       
  1449             {
       
  1450             DrawDeferred();
       
  1451             break;
       
  1452             }
       
  1453         case EESMRCmdAssignFromMap:
       
  1454         case EMRCommandMyLocations:
       
  1455             {
       
  1456             DoProcessCommandL( *command );
       
  1457             break;
       
  1458             }
  1598         default:
  1459         default:
  1599             {
  1460             {
  1600             break;
  1461             break;
  1601             }
  1462             }
  1602         }
  1463         }
  1603     }
  1464 
  1604     
  1465 
       
  1466     MESMRCalEntry* entry = iInfoProvider.EntryL();
       
  1467     if ( entry->Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest )
       
  1468     	{
       
  1469 		MESMRMeetingRequestEntry* mrEntry =
       
  1470             static_cast<MESMRMeetingRequestEntry*>( iInfoProvider.EntryL() );
       
  1471 
       
  1472 		TBool bOccursInPast( OccursInPast( iStartTimeUtc ) );
       
  1473 		
       
  1474 		TBool sendEnabled = ( !bOccursInPast &&
       
  1475 			( mrEntry->RoleL() == EESMRRoleOrganizer || mrEntry->IsForwardedL() ) &&            
       
  1476 			( iRequiredAttendeesEnabled | iOptionalAttendeesEnabled ) &&
       
  1477 			(( ( iInfoProvider.PolicyProvider().CurrentPolicy().ViewMode() == EESMREditMR )) ||
       
  1478 			( iInfoProvider.PolicyProvider().CurrentPolicy().ViewMode() == EESMRForwardMR )
       
  1479 			));
       
  1480 
       
  1481 		if( sendEnabled )
       
  1482 			{
       
  1483 			cba.SetCommandL(
       
  1484                     CEikButtonGroupContainer::ERightSoftkeyPosition,
       
  1485                     R_MR_SEND_SOFTKEY);
       
  1486             cba.MakeCommandVisibleByPosition(
       
  1487                     CEikButtonGroupContainer::ERightSoftkeyPosition,
       
  1488                     ETrue );
       
  1489 			cba.DrawDeferred();
       
  1490 			}
       
  1491 		else
       
  1492 			{
       
  1493 			cba.SetCommandL(
       
  1494                     CEikButtonGroupContainer::ERightSoftkeyPosition,
       
  1495                     R_MR_DONE_SOFTKEY);
       
  1496             cba.MakeCommandVisibleByPosition(
       
  1497                     CEikButtonGroupContainer::ERightSoftkeyPosition,
       
  1498                     ETrue );
       
  1499 			cba.DrawDeferred();
       
  1500 			}
       
  1501     	}
       
  1502 	else
       
  1503 		{
       
  1504 		cba.SetCommandL(
       
  1505                 CEikButtonGroupContainer::ERightSoftkeyPosition,
       
  1506                 R_MR_DONE_SOFTKEY);
       
  1507         cba.MakeCommandVisibleByPosition(
       
  1508                 CEikButtonGroupContainer::ERightSoftkeyPosition,
       
  1509                 ETrue );
       
  1510 		cba.DrawDeferred();
       
  1511 		}
       
  1512     }
       
  1513 
  1605 // ---------------------------------------------------------------------------
  1514 // ---------------------------------------------------------------------------
  1606 // CESMREditorDialog::HandleFieldChangeEventL
  1515 // CESMREditorDialog::HandleFieldChangeEventL
  1607 // ---------------------------------------------------------------------------
  1516 // ---------------------------------------------------------------------------
  1608 //
  1517 //
  1609 void CESMREditorDialog::HandleFieldChangeEventL(
  1518 void CESMREditorDialog::HandleFieldChangeEventL(
  1610         const MESMRFieldEvent& aEvent )
  1519         const MESMRFieldEvent& aEvent )
  1611     {
  1520     {
  1612     FUNC_LOG;
  1521     FUNC_LOG;
       
  1522 
  1613     TInt* fieldId = static_cast< TInt* >( aEvent.Param( 0 ) );
  1523     TInt* fieldId = static_cast< TInt* >( aEvent.Param( 0 ) );
       
  1524     MESMRCalEntry* entry = iInfoProvider.EntryL();
       
  1525 
  1614     switch ( *fieldId )
  1526     switch ( *fieldId )
  1615         {
  1527         {
  1616         case EESMRFieldLocation:
  1528         case EESMRFieldLocation:
  1617             {
  1529             {
  1618             MESMRFieldEventValue* value =
  1530             MESMRFieldEventValue* value =
  1619                 static_cast< MESMRFieldEventValue* >( aEvent.Param( 1 ) );
  1531                 static_cast< MESMRFieldEventValue* >( aEvent.Param( 1 ) );
  1620             if ( iEntry.Entry().LocationL() != value->StringValue() )
  1532             if ( entry->Entry().LocationL() != value->StringValue() )
  1621                 {
  1533                 {
  1622                 // Show query dialog only if entry has geocoordinates.
  1534                 // Show query dialog only if entry has geocoordinates.
  1623                 // It can be verified by checking if "Show on map" is available
  1535                 // It can be verified by checking if "Show on map" is available
  1624                 // for iEntry as geocoordinates are required for that.
  1536                 // for iEntry as geocoordinates are required for that.
  1625                 TBool enableQuery =
  1537                 TBool enableQuery =
  1626                     LocationPluginHandlerL().IsCommandAvailableL(
  1538                     LocationPluginHandlerL().IsCommandAvailableL(
  1627                             EESMRCmdShowOnMap, iEntry );
  1539                             EESMRCmdShowOnMap, *entry );
  1628                 
  1540 
  1629                 if ( enableQuery
  1541                 if ( enableQuery
  1630                      && CESMRConfirmationQuery::ExecuteL(
  1542                      && CESMRConfirmationQuery::ExecuteL(
  1631                         CESMRConfirmationQuery::EESMRAssignUpdatedLocation ) )
  1543                         CESMRConfirmationQuery::EESMRAssignUpdatedLocation ) )
  1632                     {
  1544                     {
  1633                     HBufC* oldLocation = iEntry.Entry().LocationL().AllocLC();
  1545                     HBufC* oldLocation = entry->Entry().LocationL().AllocLC();
  1634                     iView->ExternalizeL();
  1546                     iView->ExternalizeL();
  1635                                        
  1547 
  1636                     // if old and new locations are different and old location
  1548                     // if old and new locations are different and old location
  1637                     // exists, the user is updating existing location. Let's discard
  1549                     // exists, the user is updating existing location. Let's discard
  1638                     // the existing coordinates by using command EESMRCmdUpdateFromMap
  1550                     // the existing coordinates by using command EESMRCmdUpdateFromMap
  1639                     if ( iEntry.Entry().LocationL().Compare( *oldLocation ) != 0 && 
  1551                     if ( entry->Entry().LocationL().Compare( *oldLocation ) != 0 &&
  1640                             oldLocation->Length() != 0 )
  1552                             oldLocation->Length() != 0 )
  1641                         {
  1553                         {
  1642                         LocationPluginHandlerL().HandleCommandL( 
  1554                         LocationPluginHandlerL().HandleCommandL(
  1643                                 EESMRCmdUpdateFromMap, 
  1555                                 EESMRCmdUpdateFromMap,
  1644                                 iEntry );
  1556                                 *entry );
  1645                         }
  1557                         }
  1646                     else
  1558                     else
  1647                         {
  1559                         {
  1648                         LocationPluginHandlerL().HandleCommandL(
  1560                         LocationPluginHandlerL().HandleCommandL(
  1649                             EESMRCmdAssignFromMap,
  1561                             EESMRCmdAssignFromMap,
  1650                             iEntry,
  1562                             *entry,
  1651 							   EFalse );
  1563                             EFalse );
  1652                         }
  1564                         }
  1653 
  1565 
  1654                     iView->InternalizeL();
  1566                     iView->InternalizeL();
  1655                     iView->SetControlFocusedL( EESMRFieldLocation );
  1567                     iView->SetControlFocusedL( EESMRFieldLocation );
  1656                     
  1568 
  1657                     CleanupStack::PopAndDestroy( oldLocation );
  1569                     CleanupStack::PopAndDestroy( oldLocation );
  1658                     oldLocation = NULL;
  1570                     oldLocation = NULL;
  1659                     }
  1571                     }
  1660                 else if ( enableQuery )
  1572                 else if ( enableQuery )
  1661                     {
  1573                     {
  1662                     // Externalize entry, so query won't be displayed
  1574                     // Externalize entry, so query won't be displayed
  1663                     // again for the same text. 
  1575                     // again for the same text.
  1664                     iView->ExternalizeL();
  1576                     iView->ExternalizeL();
  1665                     }
  1577                     }
  1666                 }
  1578                 }
  1667             break;
  1579             break;
  1668             }
  1580             }
       
  1581 
  1669         case EESMRFieldStartDate:
  1582         case EESMRFieldStartDate:
  1670             {
  1583             {
  1671             if ( iEntry.Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest )
  1584 			// for update iStartTimeUtc when meeting & mr event changing start time
  1672                 {
  1585             TBool bOccursInPast( OccursInPastL( aEvent ) );
  1673                 MESMRFieldEventValue* value =
  1586             
  1674                     static_cast< MESMRFieldEventValue* >( aEvent.Param( 1 ) );
  1587             if ( entry->Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest )
  1675                 TTime now;
  1588             	{
  1676                 now.UniversalTime();
  1589         		MESMRMeetingRequestEntry* mrEntry =
  1677                 if ( value->TimeValue() < now )
  1590                     static_cast<MESMRMeetingRequestEntry*>( iInfoProvider.EntryL() );
       
  1591  	            TBool bIsOrganizer( mrEntry->RoleL() == EESMRRoleOrganizer );            
       
  1592 				
       
  1593             	ChangeRightSoftkeyL( bOccursInPast, bIsOrganizer );
       
  1594             	}
       
  1595             break;
       
  1596             }
       
  1597             
       
  1598         case EESMRFieldAllDayEvent:
       
  1599             {
       
  1600             TBool bOccursInPast( OccursInPast( iStartTimeUtc ) );   
       
  1601             TInt* bChecked = static_cast< TInt* >( aEvent.Param( 1 ) );
       
  1602             if( *bChecked == 1 )
       
  1603             	{
       
  1604 				TDateTime startTime = iStartTimeUtc.DateTime();
       
  1605 				startTime.SetHour( 0 );
       
  1606 				startTime.SetMinute( 0 );
       
  1607 				startTime.SetSecond( 0 );
       
  1608 				bOccursInPast = OccursInPast( startTime );
       
  1609             	}               
       
  1610 
       
  1611             if ( entry->Type() == MESMRCalEntry::EESMRCalEntryMeetingRequest )
       
  1612             	{
       
  1613         		MESMRMeetingRequestEntry* mrEntry =
       
  1614                     static_cast<MESMRMeetingRequestEntry*>( iInfoProvider.EntryL() );
       
  1615                 TBool bIsOrganizer( mrEntry->RoleL() == EESMRRoleOrganizer );
       
  1616 				
       
  1617             	ChangeRightSoftkeyL( bOccursInPast, bIsOrganizer );
       
  1618             	}
       
  1619             break;
       
  1620             }              
       
  1621         default:
       
  1622             {
       
  1623             break;
       
  1624             }
       
  1625         }
       
  1626     }
       
  1627 
       
  1628 // ---------------------------------------------------------------------------
       
  1629 // CESMREditorDialog::SetContextMenuL
       
  1630 // ---------------------------------------------------------------------------
       
  1631 //
       
  1632 TBool CESMREditorDialog::SetContextMenuL()
       
  1633     {
       
  1634     FUNC_LOG;
       
  1635     TInt ret( EFalse );
       
  1636 
       
  1637     TESMREntryFieldId fieldId = iView->ClickedOrFocusedField();
       
  1638 
       
  1639     switch( fieldId )
       
  1640         {
       
  1641         case EESMRFieldLocation:
       
  1642             {
       
  1643             ret = ETrue;
       
  1644 
       
  1645             if ( Policy().FieldL( EESMRFieldLocation ).iFieldMode
       
  1646                     == EESMRFieldModeEdit )
       
  1647                 {
       
  1648                 iContextMenuResourceId =
       
  1649                         R_MR_EDITOR_LOCATION_CONTEXT_MENU;
       
  1650                 }
       
  1651             else
       
  1652                 {
       
  1653                 iContextMenuResourceId =
       
  1654                         R_MR_VIEWER_CONTEXT_MENU;
       
  1655                 }
       
  1656 
       
  1657             if ( !iFeatures->FeatureSupported(
       
  1658                     CESMRFeatureSettings::EESMRUIMnFwIntegration )
       
  1659                  && iContextMenuResourceId == R_MR_EDITOR_LOCATION_CONTEXT_MENU )
       
  1660                 {
       
  1661 #ifndef RD_USE_MYLOCATIONUI
       
  1662                 // Maps not supported and My Locations UI disabled
       
  1663                 ret = EFalse;
       
  1664 #endif //RD_USE_MYLOCATIONUI
       
  1665                 }
       
  1666             }
       
  1667             break;
       
  1668 
       
  1669         case EESMRFieldAttachments:
       
  1670             {
       
  1671             if ( Policy().FieldL(
       
  1672                     EESMRFieldAttachments ).iFieldMode
       
  1673                     == EESMRFieldModeEdit )
       
  1674                 {
       
  1675                 iContextMenuResourceId = R_MR_EDITOR_ATTACHMENT_CONTEXT_MENU;
       
  1676                 ret = ETrue;
       
  1677                 }
       
  1678             }
       
  1679             break;
       
  1680         case EESMRFieldAttendee:
       
  1681         case EESMRFieldOptAttendee:
       
  1682             {
       
  1683             if ( Policy().FieldL(
       
  1684                     EESMRFieldAttendee ).iFieldMode == EESMRFieldModeEdit  ||
       
  1685                  Policy().FieldL(
       
  1686                     EESMRFieldOptAttendee ).iFieldMode == EESMRFieldModeEdit )
       
  1687                 {
       
  1688                 iContextMenuResourceId = R_MR_EDITOR_ATTENDEE_CONTEXT_MENU;
       
  1689                 ret = ETrue;
       
  1690                 }
       
  1691             }
       
  1692             break;
       
  1693         default:
       
  1694             break;
       
  1695         }
       
  1696 
       
  1697     if ( ret )
       
  1698         {
       
  1699         iMenuBar->SetContextMenuTitleResourceId(
       
  1700                 iContextMenuResourceId );
       
  1701         }
       
  1702     else
       
  1703         {
       
  1704         iContextMenuResourceId = 0;
       
  1705         }
       
  1706 
       
  1707     return ret;
       
  1708     }
       
  1709 
       
  1710 // ---------------------------------------------------------------------------
       
  1711 // CESMREditorDialog::SwitchEntryTypeL
       
  1712 // ---------------------------------------------------------------------------
       
  1713 //
       
  1714 void CESMREditorDialog::SwitchEntryTypeL(
       
  1715         TInt aCommand,
       
  1716         TBool aAdjustView )
       
  1717     {
       
  1718     FUNC_LOG;
       
  1719     TBool change( EFalse );
       
  1720     MESMRCalEntry* entry = iInfoProvider.EntryL();
       
  1721 
       
  1722     switch ( aCommand )
       
  1723         {
       
  1724         case EMRCommandSwitchToMR:
       
  1725             {
       
  1726             TBool ret( ETrue );
       
  1727 
       
  1728             // Show confirmation note if current mailbox does not
       
  1729             // support attachments and attachments exist in the entry
       
  1730             if( entry->Entry().AttachmentCountL() > 0 &&
       
  1731                     !SupportsMailBoxCapabilityL(
       
  1732                             MESMRBuilderExtension::
       
  1733                                 EMRCFSSupportsAttachmentsInMR ) )
       
  1734                 {
       
  1735                 if ( !CESMRConfirmationQuery::ExecuteL(
       
  1736                                    CESMRConfirmationQuery::
       
  1737                                        EESMRAttachmentsNotSupported ) )
  1678                     {
  1738                     {
  1679                     // disable send option
  1739                     ret = EFalse;
  1680                     iOccursInPast = ETrue;
       
  1681                     }
  1740                     }
  1682                 else
  1741                 }
  1683                     {
  1742 
  1684                     iOccursInPast = EFalse;
  1743             if( ret )
  1685                     }
  1744                 {
  1686                 }
  1745                 change =
       
  1746                     ( entry->Type() !=
       
  1747                         MESMRCalEntry::EESMRCalEntryMeetingRequest );
       
  1748                 }
       
  1749 
       
  1750             break;
       
  1751             }
       
  1752         case EMRCommandSwitchToMeeting:
       
  1753             {
       
  1754             change =
       
  1755                 ( entry->Type() != MESMRCalEntry::EESMRCalEntryMeeting );
       
  1756             break;
       
  1757             }
       
  1758         case EMRCommandSwitchToMemo:
       
  1759             {
       
  1760             change =
       
  1761                 ( entry->Type() != MESMRCalEntry::EESMRCalEntryMemo );
       
  1762             break;
       
  1763             }
       
  1764         case EMRCommandSwitchToAnniversary:
       
  1765             {
       
  1766             change =
       
  1767                 ( entry->Type() != MESMRCalEntry::EESMRCalEntryAnniversary );
       
  1768             break;
       
  1769             }
       
  1770         case EMRCommandSwitchToTodo:
       
  1771             {
       
  1772             change =
       
  1773                 ( entry->Type() != MESMRCalEntry::EESMRCalEntryTodo);
  1687             break;
  1774             break;
  1688             }
  1775             }
  1689         default:
  1776         default:
  1690             {
  1777             {
  1691             break;
  1778             break;
  1692             }
  1779             }
  1693         }
  1780         }
       
  1781 
       
  1782     if ( change )
       
  1783         {
       
  1784         iView->ExternalizeL(ETrue);
       
  1785         iStartTimeUtc = entry->Entry().StartTimeL().TimeUtcL();
       
  1786         iCallback.ProcessCommandL( aCommand );
       
  1787 
       
  1788         if( aAdjustView )
       
  1789             {
       
  1790             MESMRCalEntry* entry = iInfoProvider.EntryL();
       
  1791             iView->AdjustViewL( entry, Policy() );
       
  1792             SetTitleL();
       
  1793             }
       
  1794         }
       
  1795     }
       
  1796 
       
  1797 // ---------------------------------------------------------------------------
       
  1798 // CESMREditorDialog::Policy
       
  1799 // ---------------------------------------------------------------------------
       
  1800 //
       
  1801 const CESMRPolicy& CESMREditorDialog::Policy() const
       
  1802     {
       
  1803     FUNC_LOG;
       
  1804     return iInfoProvider.PolicyProvider().CurrentPolicy();
       
  1805     }
       
  1806 
       
  1807 // ---------------------------------------------------------------------------
       
  1808 // CESMREditorDialog::DynInitToolbarL
       
  1809 // ---------------------------------------------------------------------------
       
  1810 //
       
  1811 void CESMREditorDialog::DynInitToolbarL ( TInt /*aResourceId*/,
       
  1812         CAknToolbar* /*aToolbar*/ )
       
  1813     {
       
  1814     // TODO: Not implemented yet
       
  1815     }
       
  1816 
       
  1817 // ---------------------------------------------------------------------------
       
  1818 // CESMREditorDialog::OfferToolbarEventL
       
  1819 // ---------------------------------------------------------------------------
       
  1820 //
       
  1821 void CESMREditorDialog::OfferToolbarEventL ( TInt aCommand )
       
  1822     {
       
  1823     DoProcessCommandL(aCommand);
       
  1824     }
       
  1825 
       
  1826 
       
  1827 // ---------------------------------------------------------------------------
       
  1828 // CESMREditorDialog::SetTitleL
       
  1829 // ---------------------------------------------------------------------------
       
  1830 //
       
  1831 void CESMREditorDialog::SetTitleL ()
       
  1832     {
       
  1833     FUNC_LOG;
       
  1834 
       
  1835     MESMRCalEntry* entry = iInfoProvider.EntryL();
       
  1836 
       
  1837     // Setting title to status pane's title pane
       
  1838     TInt titleStringId = -1;
       
  1839     switch ( entry->Type() )
       
  1840         {
       
  1841         case MESMRCalEntry::EESMRCalEntryMeetingRequest:
       
  1842             titleStringId = R_QTN_MEET_REQ_TITLE_MEETING;
       
  1843             break;
       
  1844         case MESMRCalEntry::EESMRCalEntryMeeting:
       
  1845             titleStringId = R_QTN_CALENDAR_TITLE_MEETING;
       
  1846             break;
       
  1847         case MESMRCalEntry::EESMRCalEntryTodo:
       
  1848             titleStringId = R_QTN_CALENDAR_TITLE_TODO;
       
  1849             break;
       
  1850         case MESMRCalEntry::EESMRCalEntryMemo:
       
  1851             titleStringId = R_QTN_CALENDAR_TITLE_MEMO;
       
  1852             break;
       
  1853         case MESMRCalEntry::EESMRCalEntryReminder:
       
  1854             break;
       
  1855         case MESMRCalEntry::EESMRCalEntryAnniversary:
       
  1856             titleStringId = R_QTN_CALENDAR_TITLE_ANNIVERSARY;
       
  1857             break;
       
  1858         default:
       
  1859             break;
       
  1860         }
       
  1861 
       
  1862     if ( titleStringId != -1 )
       
  1863         {
       
  1864         if( !iTitlePane )
       
  1865             {
       
  1866             iTitlePane = CESMRTitlePaneHandler::NewL( *iEikonEnv );
       
  1867             }
       
  1868 
       
  1869         HBufC* titleText = StringLoader::LoadLC( titleStringId, iCoeEnv );
       
  1870         iTitlePane->SetNewTitle( titleText );
       
  1871         CleanupStack::PopAndDestroy( titleText );
       
  1872         }
       
  1873 
       
  1874     // If subject does not exist, let's update the title also
       
  1875     // to main window
       
  1876     if( entry->Entry().SummaryL().Length() <= 0 )
       
  1877         {
       
  1878         HBufC* title ;
       
  1879         switch( entry->Type() )
       
  1880            {
       
  1881            case MESMRCalEntry::EESMRCalEntryTodo:
       
  1882                {
       
  1883                title = StringLoader::LoadLC ( R_QTN_CALENDAR_TITLE_NEW_TODO );
       
  1884                break;
       
  1885                }
       
  1886            case MESMRCalEntry::EESMRCalEntryMemo:
       
  1887                {
       
  1888                title = StringLoader::LoadLC ( R_QTN_CALENDAR_TITLE_NEW_MEMO );
       
  1889                break;
       
  1890                }
       
  1891            case MESMRCalEntry::EESMRCalEntryAnniversary:
       
  1892                {
       
  1893                title = StringLoader::LoadLC(R_QTN_CALENDAR_TITLE_NEW_ANNIVERSARY);
       
  1894                break;
       
  1895                }
       
  1896            case MESMRCalEntry::EESMRCalEntryMeetingRequest: // Fall through
       
  1897            case MESMRCalEntry::EESMRCalEntryMeeting: // Fall through
       
  1898            case MESMRCalEntry::EESMRCalEntryReminder: // Fall through
       
  1899            default:
       
  1900                {
       
  1901                title = StringLoader::LoadLC( R_QTN_MEET_REQ_TITLE );
       
  1902                break;
       
  1903                }
       
  1904            }
       
  1905         iView->SetTitleL( *title );
       
  1906         CleanupStack::PopAndDestroy( title );
       
  1907         }
       
  1908     }
       
  1909 
       
  1910 // ---------------------------------------------------------------------------
       
  1911 // CESMREditorDialog::VerifyMeetingRequestL
       
  1912 // ---------------------------------------------------------------------------
       
  1913 //
       
  1914 void CESMREditorDialog::VerifyMeetingRequestL()
       
  1915     {
       
  1916     FUNC_LOG;
       
  1917 
       
  1918     MESMRCalEntry* entry = iInfoProvider.EntryL();
       
  1919 
       
  1920     // If entry is meeting request, but no attendees have been added,
       
  1921     // entry is switched to and saved as regular meeting
       
  1922     if( CCalenInterimUtils2::IsMeetingRequestL( entry->Entry() ) )
       
  1923         {
       
  1924         RPointerArray<CCalAttendee>& attendees(
       
  1925                 entry->Entry().AttendeesL() );
       
  1926 
       
  1927         TInt attendeeCount = attendees.Count();
       
  1928 
       
  1929         if( ( attendeeCount == 0 ) &&
       
  1930         	(iInfoProvider.PolicyProvider().CurrentPolicy().ViewMode() != EESMRForwardMR) )
       
  1931             {
       
  1932             TRAPD( err, SwitchEntryTypeL( EMRCommandSwitchToMeeting, EFalse ) )
       
  1933 
       
  1934             if ( err )
       
  1935                {
       
  1936                // UI and engine not consistent. Show error and exit
       
  1937                iCoeEnv->HandleError( err );
       
  1938                TryExitL( EESMRCmdForceExit );
       
  1939                }
       
  1940             }
       
  1941         }
       
  1942     }
       
  1943 
       
  1944 // -----------------------------------------------------------------------------
       
  1945 // CESMREditorDialog::ShowContextMenuL
       
  1946 // -----------------------------------------------------------------------------
       
  1947 //
       
  1948 void CESMREditorDialog::ShowContextMenuL()
       
  1949     {
       
  1950     FUNC_LOG;
       
  1951 
       
  1952     if ( iMenuBar )
       
  1953         {
       
  1954         iMenuBar->TryDisplayContextMenuBarL();
       
  1955         }
       
  1956     }
       
  1957 
       
  1958 
       
  1959 // -----------------------------------------------------------------------------
       
  1960 // CESMREditorDialog::OccursInPast
       
  1961 // -----------------------------------------------------------------------------
       
  1962 //
       
  1963 TBool CESMREditorDialog::OccursInPastL( const MESMRFieldEvent& aEvent )
       
  1964     {
       
  1965     FUNC_LOG;
       
  1966     MESMRFieldEventValue* value = static_cast< MESMRFieldEventValue* >( aEvent.Param( 1) );
       
  1967 
       
  1968     TCalTime startCalTime;
       
  1969     startCalTime.SetTimeLocalL( value->TimeValue() );
       
  1970 
       
  1971     iStartTimeUtc = startCalTime.TimeUtcL();
       
  1972 
       
  1973 	return OccursInPast( iStartTimeUtc );
       
  1974     }
       
  1975 
       
  1976 // -----------------------------------------------------------------------------
       
  1977 // CESMREditorDialog::OccursInPast
       
  1978 // -----------------------------------------------------------------------------
       
  1979 //
       
  1980 TBool CESMREditorDialog::OccursInPast( const TTime& aStartUtc )
       
  1981 	{
       
  1982     FUNC_LOG;
       
  1983 	TBool bOccursInPast(EFalse);
       
  1984 
       
  1985 	TTime now;
       
  1986     now.UniversalTime();
       
  1987 
       
  1988     if ( aStartUtc < now )
       
  1989     	{
       
  1990     	bOccursInPast = ETrue;
       
  1991     	}
       
  1992 
       
  1993     return bOccursInPast;
       
  1994 	}
       
  1995 
       
  1996 // -----------------------------------------------------------------------------
       
  1997 // CESMREditorDialog::ChangeRightSoftkeyL
       
  1998 // -----------------------------------------------------------------------------
       
  1999 //
       
  2000 void CESMREditorDialog::ChangeRightSoftkeyL( TBool aOccursInPast, TBool aIsOrganizer )
       
  2001 	{
       
  2002     FUNC_LOG;
       
  2003 	TBool sendEnabled = 
       
  2004 		( iRequiredAttendeesEnabled | iOptionalAttendeesEnabled ) && 
       
  2005 		!aOccursInPast && aIsOrganizer;
       
  2006 
       
  2007 	CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
  2008 	
       
  2009 	if( sendEnabled )
       
  2010 		{
       
  2011 		cba.SetCommandL(
       
  2012                 CEikButtonGroupContainer::ERightSoftkeyPosition,
       
  2013                 R_MR_SEND_SOFTKEY);
       
  2014 		cba.DrawDeferred();
       
  2015 		}
       
  2016 	else
       
  2017 		{
       
  2018 		cba.SetCommandL(
       
  2019                 CEikButtonGroupContainer::ERightSoftkeyPosition,
       
  2020                 R_MR_DONE_SOFTKEY);
       
  2021 		cba.DrawDeferred();   
       
  2022 		}	
       
  2023 	}
       
  2024 
       
  2025 // -----------------------------------------------------------------------------
       
  2026 // CESMREditorDialog::TryToSaveEntryL
       
  2027 // -----------------------------------------------------------------------------
       
  2028 //
       
  2029 TInt CESMREditorDialog::TryToSaveEntryL()
       
  2030     {
       
  2031     FUNC_LOG;
       
  2032     TInt res( KErrNone );
       
  2033     
       
  2034     MESMRCalEntry* entry = iInfoProvider.EntryL();
       
  2035 
       
  2036     if ( IsAllowedToSaveL() )
       
  2037         {
       
  2038         res = iCallback.ProcessCommandWithResultL( EESMRCmdSaveMR );
       
  2039 
       
  2040         if ( res == KErrNone
       
  2041              && iFeatures->FeatureSupported(
       
  2042                      CESMRFeatureSettings::EESMRUIPreviousLocationsList ) )
       
  2043             {
       
  2044             LocationPluginHandlerL().StoreLocationToHistoryL( *entry );
       
  2045             }
       
  2046             if ( entry->Type() == MESMRCalEntry::EESMRCalEntryTodo )
       
  2047                 {
       
  2048                 CESMRGlobalNote* note =
       
  2049                     CESMRGlobalNote::NewL(
       
  2050                             CESMRGlobalNote::EESMRTodoEntrySaved );
       
  2051                 note->ExecuteLD();
       
  2052                 }
       
  2053             else
       
  2054                 {
       
  2055                 CESMRGlobalNote* note =
       
  2056                     CESMRGlobalNote::NewL(
       
  2057                             CESMRGlobalNote::EESMREntrySaved );
       
  2058                 note->ExecuteLD();
       
  2059                 }
       
  2060         }
       
  2061     else
       
  2062         {
       
  2063         res = KErrCancel;
       
  2064         }
       
  2065     
       
  2066     return res;
  1694     }
  2067     }
  1695 
  2068 
  1696 // EOF
  2069 // EOF
  1697