eventsui/eventsmgmtui/src/evtmgmtuistartupview.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  View class for Events Management UI.
       
    15 *
       
    16 */
       
    17 
       
    18 // SYSTEM INCLUDES
       
    19 #include <evtmgmtui.rsg>
       
    20 #include <hlplch.h>
       
    21 #include <featmgr.h>
       
    22 #include <eikmenup.h>
       
    23 #include <eikbtgpc.h>
       
    24 #include <StringLoader.h>
       
    25 #include <aknmessagequerydialog.h>
       
    26 #include <aknnotewrappers.h> 
       
    27 #include <eikserverapp.h>
       
    28 #include <textresolver.h>
       
    29 #include <csxhelp/loc.hlp.hrh>
       
    30 
       
    31 // USER INCLUDES
       
    32 #include "evtmgmtuiuid.hrh"
       
    33 #include "evtmgmtuistartupview.h"
       
    34 #include "evtmgmtuistartupcontainer.h"
       
    35 #include "evtmgmtuiappui.h"
       
    36 #include "evtmgmtui.hrh"
       
    37 #include "evteventsdlg.h"
       
    38 #include "evtdebug.h"
       
    39 #include "evtmgmtuilocsettinglauncher.h"
       
    40 #include "evtmgmtuimodel.h"
       
    41 #include "evtmgmtuilbtadapter.h"
       
    42 #include "evtmgmtuimapnavigationadapter.h"
       
    43 
       
    44 // CONSTANT DEFINTIONS
       
    45 const TUid	KEvtMgmtUiStartupViewId = TUid::Uid( 1 );
       
    46 const TInt KMaxEvents = 50;
       
    47 _LIT( KWaitCycleError, "Wait Cycle Error" );
       
    48 
       
    49 // ----------------- Member funtions for CEvtMgmtUiStartupView class -----------------------
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CEvtMgmtUiStartupView::CEvtMgmtUiStartupView
       
    53 // ---------------------------------------------------------------------------
       
    54 //  
       
    55 CEvtMgmtUiStartupView::CEvtMgmtUiStartupView()
       
    56     {
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // CEvtMgmtUiStartupView::~CEvtMgmtUiStartupView
       
    61 // ---------------------------------------------------------------------------
       
    62 //  
       
    63 CEvtMgmtUiStartupView::~CEvtMgmtUiStartupView()
       
    64     {
       
    65     if ( iContainer )
       
    66         {
       
    67         AppUi()->RemoveFromViewStack( *this, iContainer );
       
    68     	delete iContainer; 
       
    69         }
       
    70     
       
    71     // Unregister the command handler as an observer
       
    72     if( iEngine )
       
    73 	{
       
    74 	iEngine->RemoveObserver( this );
       
    75        	delete iEngine;
       
    76 	}
       
    77     
       
    78     delete iPosSetLauncher;
       
    79     
       
    80     if(iEvtIdArray)
       
    81         {
       
    82         iEvtIdArray->Close();
       
    83         delete iEvtIdArray;
       
    84         }
       
    85     
       
    86     delete iModel;
       
    87     FeatureManager::UnInitializeLib();
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // CEvtMgmtUiStartupView* CEvtMgmtUiStartupView::NewL
       
    92 // ---------------------------------------------------------------------------
       
    93 //        
       
    94 CEvtMgmtUiStartupView* CEvtMgmtUiStartupView::NewL()
       
    95     {
       
    96     CEvtMgmtUiStartupView* self = new ( ELeave ) CEvtMgmtUiStartupView();
       
    97     CleanupStack::PushL(self);
       
    98     self->ConstructL();
       
    99     CleanupStack::Pop(self);
       
   100     return self;
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // void CEvtMgmtUiStartupView::ConstructL
       
   105 // ---------------------------------------------------------------------------
       
   106 //  
       
   107 void CEvtMgmtUiStartupView::ConstructL()
       
   108     {
       
   109     if(iEikonEnv->StartedAsServerApp())
       
   110         {
       
   111         iIsEmbeddedApp = ETrue;
       
   112         BaseConstructL( R_EVTMGMTUI_STARTUP_VIEW_EMBEDDED );
       
   113         }
       
   114     else
       
   115         {
       
   116         iIsEmbeddedApp = EFalse;
       
   117         BaseConstructL( R_EVTMGMTUI_STARTUP_VIEW );
       
   118         }
       
   119     // Create Log Directory.
       
   120     //CREATELOGDIR();
       
   121     
       
   122     // Feature manager required for Help feature check
       
   123     FeatureManager::InitializeLibL();
       
   124     
       
   125     iEngine = CEvtMgmtUiEngine::NewL();    
       
   126     iEngine->SetObserver(this);  
       
   127     
       
   128     iEngine->SyncDbsL();
       
   129     
       
   130     iModel = CEvtMgmtUiModel::NewL();
       
   131     iEngine->UpdateModelL(iModel->EventsArray(), CEvtMgmtUiEngine::EEvtFilterAll ); 
       
   132     iModel->SetStatusFilter( CEvtMgmtUiEngine::EEvtFilterAll );  
       
   133     iModel->UpdateEventsStatus( );
       
   134     }
       
   135 			
       
   136 // ---------------------------------------------------------------------------
       
   137 // void CEvtMgmtUiStartupView::DoActivateL
       
   138 // ---------------------------------------------------------------------------
       
   139 //  	
       
   140 void CEvtMgmtUiStartupView::DoActivateL( const TVwsViewId&  /* PrevViewId*/,
       
   141                                              TUid           /* aCustomMessageId*/,
       
   142                                        const TDesC8&        /* aCustomMessage */)
       
   143     {
       
   144     // Destroy the existing container if it exists
       
   145     if( iContainer )
       
   146         {
       
   147         AppUi()->RemoveFromViewStack( *this, iContainer );
       
   148         delete iContainer;
       
   149         iContainer=NULL;
       
   150         }                       
       
   151     
       
   152     // Create new Container 
       
   153     iContainer = CEvtMgmtUiStartupContainer::NewL( ClientRect(), iModel, *this);
       
   154     iContainer->SetMopParent( this );
       
   155     AppUi()->AddToViewStackL( *this, iContainer );   	   
       
   156     if(iModel->TotalEvents())
       
   157         MenuBar()->SetMenuTitleResourceId ( R_EVTMGMTUI_STARTUP_MENUBAR_MARK );
       
   158     else
       
   159         MenuBar()->SetMenuTitleResourceId ( R_EVTMGMTUI_STARTUP_MENUBAR );
       
   160     }
       
   161     
       
   162 // ---------------------------------------------------------------------------
       
   163 // void CEvtMgmtUiStartupView::DoDeactivate
       
   164 // ---------------------------------------------------------------------------
       
   165 //           
       
   166 void CEvtMgmtUiStartupView::DoDeactivate()
       
   167     {
       
   168     // Destroy Container
       
   169     if ( iContainer )
       
   170         {
       
   171         AppUi()->RemoveFromViewStack( *this, iContainer );
       
   172         delete iContainer;
       
   173         iContainer = NULL;
       
   174         }
       
   175     }
       
   176     
       
   177 // ---------------------------------------------------------------------------
       
   178 // TUid CEvtMgmtUiStartupView::Id
       
   179 // ---------------------------------------------------------------------------
       
   180 //   
       
   181 TUid CEvtMgmtUiStartupView::Id() const
       
   182     {
       
   183     return KEvtMgmtUiStartupViewId;
       
   184     }
       
   185 
       
   186 // -----------------------------------------------------------------------------
       
   187 //  CEvtMgmtUiStartupView::HandleShowOnMapCommandL
       
   188 //  It will handle 'show on map' command.
       
   189 // -----------------------------------------------------------------------------
       
   190 //
       
   191 void CEvtMgmtUiStartupView::HandleShowOnMapCommandL()
       
   192     {
       
   193     EVTUIDEBUG("+ CEvtMgmtUiStartupView::HandleShowOnMapCommandL()" );
       
   194     CEvtMgmtUiMapNavigationAdapter* map = CEvtMgmtUiMapNavigationAdapter::NewL();
       
   195     CleanupStack::PushL(map);
       
   196     TCoordinate loc;
       
   197     iEngine->RetrieveLocationL( iModel->EventId( iContainer->CurrentItemIndex() ), loc );        
       
   198     map->ShowOnMapL( loc );
       
   199     CleanupStack::PopAndDestroy(); //map
       
   200     EVTUIDEBUG("- CEvtMgmtUiStartupView::HandleShowOnMapCommandL()" );
       
   201     }
       
   202 
       
   203 // -----------------------------------------------------------------------------
       
   204 //  CEvtMgmtUiStartupView::HandleNavigateToPlaceCommandL
       
   205 //  It will handle 'navigate to place' command.
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 void CEvtMgmtUiStartupView::HandleNavigateToPlaceCommandL()
       
   209     {
       
   210     EVTUIDEBUG("+ CEvtMgmtUiStartupView::HandleNavigateToPlaceCommandL()" );
       
   211     CEvtMgmtUiMapNavigationAdapter* map = CEvtMgmtUiMapNavigationAdapter::NewL();
       
   212     CleanupStack::PushL(map);    
       
   213     TCoordinate loc;
       
   214     iEngine->RetrieveLocationL( iModel->EventId( iContainer->CurrentItemIndex() ), loc );
       
   215     map->NavigateToPlaceL( loc );
       
   216     CleanupStack::PopAndDestroy(); //map
       
   217     EVTUIDEBUG("- CEvtMgmtUiStartupView::HandleNavigateToPlaceCommandL()" );
       
   218     }
       
   219 // ---------------------------------------------------------------------------
       
   220 // void CEvtMgmtUiStartupView::HandleCommandL
       
   221 // ---------------------------------------------------------------------------
       
   222 //       
       
   223 void CEvtMgmtUiStartupView::HandleCommandL( TInt aCommand )   
       
   224     {
       
   225     EVTUIDEBUG1("+ CEvtMgmtUiStartupView::HandleCommandL = %d", aCommand);
       
   226     
       
   227     TInt currentItemIndex= iContainer->CurrentItemIndex();
       
   228     // This class only handles the commands specific to this view
       
   229     switch( aCommand )
       
   230     	{
       
   231     	case EEvtMgmtUiStartupViewOpen:
       
   232 			{			
       
   233 			if(currentItemIndex>0)
       
   234 				{ 
       
   235                 TCoeHelpContext context;
       
   236                 context.iContext = KHLP_LOC_EVENTS_EDITOR();
       
   237                 context.iMajor = TUid::Uid( KEvtMgmtUiUid );	
       
   238                 
       
   239 				CEvtEvent* evt = iEngine->EventL( EventIdOfCurrentItem() );	
       
   240 				CleanupStack::PushL( evt );
       
   241 				CEvtEventsDlg* form = CEvtEventsDlg::NewL(EFalse, *evt, *iEngine);  
       
   242 				form->SetHelpContext( context );            
       
   243 				form->ExecuteLD( ); 	
       
   244 				CleanupStack::PopAndDestroy( evt );
       
   245 				iContainer->MakeTitleL();
       
   246 				}           
       
   247 			break;
       
   248 			} 
       
   249     	case EEvtMgmtUiStartupViewCreate:
       
   250 			{
       
   251 			currentItemIndex = KErrNotFound;
       
   252 			if(iModel->TotalEvents() < KMaxEvents )
       
   253 			    {
       
   254                 TCoeHelpContext context;
       
   255                 context.iContext = KHLP_LOC_EVENTS_EDITOR();
       
   256                 context.iMajor = TUid::Uid( KEvtMgmtUiUid );	
       
   257                 
       
   258 				CEvtEvent* evt = iEngine->EventL( 0 );	
       
   259 				CleanupStack::PushL( evt );
       
   260 			    CEvtEventsDlg* form = CEvtEventsDlg::NewL(ETrue, *evt, *iEngine );                
       
   261 				form->SetHelpContext( context );            
       
   262 			    form->ExecuteLD( );
       
   263 				CleanupStack::PopAndDestroy( evt );
       
   264 				iContainer->MakeTitleL();
       
   265 				if(iModel->TotalEvents())
       
   266 			        MenuBar()->SetMenuTitleResourceId ( R_EVTMGMTUI_STARTUP_MENUBAR_MARK );
       
   267 			    else
       
   268 			        MenuBar()->SetMenuTitleResourceId ( R_EVTMGMTUI_STARTUP_MENUBAR );
       
   269 			    }
       
   270 			else
       
   271 			    {
       
   272 			    HBufC* errMsg = StringLoader::LoadLC( R_EVTUI_MAXEVENTS_ERROR, iCoeEnv );
       
   273                 CAknInformationNote* errNote = new(ELeave) CAknInformationNote();
       
   274                 errNote->ExecuteLD( *errMsg );
       
   275                 CleanupStack::PopAndDestroy(errMsg);   
       
   276 			    }
       
   277 			break;
       
   278 			}   
       
   279     	case EEvtEditorCmdDelete:
       
   280     	    {
       
   281     	    TInt cnt = iContainer->NumberOfMarkedItems();
       
   282     	    if( currentItemIndex != 0 || cnt )
       
   283     	        {
       
   284                 HBufC* msg = NULL;
       
   285                 if(cnt>1)
       
   286                     msg = StringLoader::LoadLC(R_LOCEV_CONFIRM_MULTIDELETE_EVENT, cnt, CEikonEnv::Static() );
       
   287                 else
       
   288                     msg = StringLoader::LoadLC(R_LOCEV_CONFIRM_DELETE_EVENT, CEikonEnv::Static() );
       
   289                 
       
   290                 //if not deleted, do nothing
       
   291                if(DisplayConfirmationQueryDlgL(*msg))
       
   292                    { 	         
       
   293                     iWaitState = EWaitDlgLaunchToDelete;   
       
   294                     StartWaitDialogL();
       
   295                    }
       
   296                 CleanupStack::PopAndDestroy(msg);
       
   297     	        }
       
   298             break;
       
   299             }   	
       
   300     	case EEvtEditorCmdShowAll:
       
   301     		{
       
   302     		iModel->SetCurrentItemId( iContainer->CurrentItemIndex() );
       
   303     		iModel->SetStatusFilter( CEvtMgmtUiEngine::EEvtFilterAll );
       
   304     		UpdateViewL(); 
       
   305     		break;
       
   306     		}
       
   307     	case EEvtEditorCmdShowDrafts:
       
   308     		{    		
       
   309     		iModel->SetCurrentItemId( iContainer->CurrentItemIndex() );
       
   310     		iModel->SetStatusFilter( CEvtMgmtUiEngine::EEvtFilterDraft );
       
   311     		UpdateViewL(); 
       
   312     		break;
       
   313     		}
       
   314     	case EEvtEditorCmdShowActive:
       
   315     		{ 
       
   316     		iModel->SetCurrentItemId( iContainer->CurrentItemIndex() );
       
   317     		iModel->SetStatusFilter( CEvtMgmtUiEngine::EEvtFilterActive );
       
   318     		UpdateViewL(); 
       
   319     		break;
       
   320     		}
       
   321         case EEvtEditorCmdShowCompleted:
       
   322             {           
       
   323             iModel->SetCurrentItemId( iContainer->CurrentItemIndex() );
       
   324             iModel->SetStatusFilter( CEvtMgmtUiEngine::EEvtFilterCompleted );
       
   325             UpdateViewL(); 
       
   326             break;
       
   327             }
       
   328     	case EEvtEditorCmdActivate:
       
   329     	    {    	    
       
   330     	    iEvtStatus = EActive;
       
   331     	    iWaitState = EWaitDlgLaunchToChangeStatus;   
       
   332     	    StartWaitDialogL();    	        	    
       
   333     	    break;
       
   334     	    }
       
   335 	   case EEvtEditorCmdSaveDraft:
       
   336             {
       
   337             iEvtStatus = EDraft;  
       
   338             iWaitState = EWaitDlgLaunchToChangeStatus;   
       
   339             StartWaitDialogL();                    
       
   340             break;
       
   341             }
       
   342 	   case EAknCmdMark:
       
   343 	   case EAknSoftkeyMark:
       
   344 	       {
       
   345 	       if(currentItemIndex != KErrNotFound)
       
   346 	           {
       
   347 	           iContainer->HandleMarkCmdL(currentItemIndex, ETrue);
       
   348 	           HandleCmdL( EListBoxItemFocused );
       
   349 	           }
       
   350 	       break;
       
   351 	       }
       
   352 	   case EAknCmdUnmark:
       
   353 	   case EAknSoftkeyUnmark:
       
   354 	       {
       
   355 	       if(currentItemIndex != KErrNotFound)
       
   356 	           {
       
   357     	       iContainer->HandleMarkCmdL(currentItemIndex, EFalse);
       
   358     	       HandleCmdL( EListBoxItemFocused );
       
   359 	           }
       
   360 	       break;
       
   361 	       }
       
   362 	   case EAknMarkAll:
       
   363 	       {
       
   364 	       iContainer->HandleMarkCmdL(KErrNotFound, ETrue);
       
   365 	       HandleCmdL( EListBoxItemFocused );
       
   366 	       break;
       
   367 	       }
       
   368 	   case EAknUnmarkAll:
       
   369 	        {	                   
       
   370 	        iContainer->HandleMarkCmdL(KErrNotFound, EFalse);
       
   371 	        HandleCmdL( EListBoxItemFocused );
       
   372 	        }
       
   373 		    break;  
       
   374 	   case EEvtEditorCmdNavigateToPlace:
       
   375 	       {
       
   376 	       HandleNavigateToPlaceCommandL();
       
   377 	       break;
       
   378 	       }
       
   379 	   case EEvtEditorCmdShowOnMap:
       
   380 	       {
       
   381 	       HandleShowOnMapCommandL();
       
   382 	       break;
       
   383 	       }
       
   384 	   case EEvtMgmtUiEventUiPosSettings:
       
   385 	       {
       
   386 	       if(!iPosSetLauncher)
       
   387                {
       
   388                iPosSetLauncher = CEvtMgmtUiLocSettingsLauncher::NewL();                
       
   389                }
       
   390 	       iPosSetLauncher->LaunchL();
       
   391            break;
       
   392 	       }
       
   393     	case EAknCmdHelp:
       
   394             {
       
   395             HlpLauncher::LaunchHelpApplicationL( iCoeEnv->WsSession(),
       
   396                                                  AppUi()->AppHelpContextL());
       
   397             break;  
       
   398             }
       
   399         default:
       
   400         	{
       
   401 			AppUi()->HandleCommandL( aCommand );
       
   402 			break;        	
       
   403         	}
       
   404     	}
       
   405     EVTUIDEBUG("- CEvtMgmtUiStartupView::HandleCommandL");
       
   406     }
       
   407 
       
   408 // ---------------------------------------------------------------------------
       
   409 // void CEvtMgmtUiStartupView::ChangeEventStatus
       
   410 // Change status of the event
       
   411 // param[in] aStatus -  value to which event status should be changed
       
   412 // ---------------------------------------------------------------------------
       
   413 //  
       
   414 void CEvtMgmtUiStartupView::ChangeEventStatusL( TEvtEventStatus aStatus )
       
   415     {      
       
   416     TInt cnt = iContainer->NumberOfMarkedItems();
       
   417     TInt index;
       
   418     if(iEvtIdArray)
       
   419         iEvtIdArray->Reset();
       
   420     else
       
   421         iEvtIdArray = new(ELeave) RArray<TEvtEventId>();
       
   422     
       
   423     if(cnt)
       
   424           {
       
   425           iDisplayNote = EFalse;
       
   426           EVTUIDEBUG1("CEvtMgmtUiStartupView::ChangeEventStatusL() selected items = %d", cnt );  
       
   427           const CArrayFix<TInt>* evtarray = iContainer->MarkItems();          
       
   428           TInt itemIndex = 0;             
       
   429           for(index=0;index<cnt;index++)
       
   430               {        
       
   431               itemIndex = iContainer->FilteredIndex((*evtarray)[index]);
       
   432               EVTUIDEBUG1("CEvtMgmtUiStartupView::ChangeEventStatusL() listboxindexid = %d", itemIndex);          
       
   433               EVTUIDEBUG1("Changing status of event Event id = %u", EventId(itemIndex) );
       
   434               
       
   435               //retrieve event details from model
       
   436               CEvtBasicEventInfo& event = iModel->EventFromModel(itemIndex);
       
   437               
       
   438               if( aStatus == EActive )
       
   439                  {               
       
   440                  //if manadatory fields are empty, display info note
       
   441                  if( event.Subject().Compare(KNullDesC)==0 || event.Place().Compare(KNullDesC)==0 )
       
   442                      {                    
       
   443                      iDisplayNote  = ETrue;
       
   444                      }
       
   445                  else
       
   446                      {
       
   447                      //if event is not having state to which it is supposed to change 
       
   448                      // then add it to id-list
       
   449                      if( event.EventStatus() !=  aStatus )
       
   450                          iEvtIdArray->Append( event.EventId() );
       
   451                      }
       
   452                   }  
       
   453               else
       
   454                   {
       
   455                   //if event is not having state to which it is supposed to change 
       
   456                   // then add it to id-list
       
   457                   if( event.EventStatus() !=  aStatus )
       
   458                       iEvtIdArray->Append( event.EventId() );
       
   459                   }
       
   460               }
       
   461           if(iEvtIdArray->Count())
       
   462               {
       
   463               iEngine->SetEventsStateL( aStatus, iEvtIdArray );
       
   464               }
       
   465           else
       
   466               {
       
   467               iWaitState = EWaitDlgDestroy;
       
   468               }
       
   469           HandleCommandL(EAknUnmarkAll);
       
   470           }
       
   471      else
       
   472           {
       
   473            TInt currentItemIndex = iContainer->CurrentItemIndex();
       
   474            if(aStatus == EActive)
       
   475                 {
       
   476                 if( iModel->EventFromModel(currentItemIndex).Subject().Compare(KNullDesC)==0 || 
       
   477 					iModel->EventFromModel(currentItemIndex).Place().Compare(KNullDesC)==0 )
       
   478                     {                   
       
   479                     
       
   480                     HBufC* warningMsg = StringLoader::LoadLC( R_EVTUI_MANDATORYFIELDS_WARNING, iCoeEnv );
       
   481                     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(*warningMsg);
       
   482                     dlg->PrepareLC(R_EVTUI_MESSAGE_QUERY);
       
   483                     dlg->RunLD();
       
   484                     CleanupStack::PopAndDestroy(warningMsg);
       
   485                     return;
       
   486                     }
       
   487                 } 
       
   488            iEvtIdArray->Append( EventId( currentItemIndex ) ); 
       
   489            iEngine->SetEventsStateL(aStatus, iEvtIdArray  );
       
   490           }
       
   491     }
       
   492 
       
   493 // ---------------------------------------------------------------------------
       
   494 // void CEvtMgmtUiStartupView::ShowEvents
       
   495 // Show all events with given status
       
   496 // param[in] aStatusFilter - status filter to display events
       
   497 // ---------------------------------------------------------------------------
       
   498 //
       
   499 void CEvtMgmtUiStartupView::ShowEventsL( CEvtMgmtUiEngine::TEvtEventStatusFilter aStatusFilter )
       
   500     {
       
   501 	iModel->SetCurrentItemId( iContainer->CurrentItemIndex() );
       
   502 	iModel->SetStatusFilter( aStatusFilter );
       
   503     UpdateViewL();
       
   504     }
       
   505 
       
   506 // ---------------------------------------------------------------------------
       
   507 // void CEvtMgmtUiStartupView::EnableMapFunctionalityL
       
   508 // Check wether map functionality can be disabled.
       
   509 // ret ETrue if map functionality should be enabled else EFalse
       
   510 // ---------------------------------------------------------------------------
       
   511 //
       
   512 TBool CEvtMgmtUiStartupView::EnableMapFunctionalityL( )
       
   513     {
       
   514     EVTUIDEBUG("+ CEvtMgmtUiStartupView::DisableMapFunctionality()" );
       
   515     CEvtMgmtUiMapNavigationAdapter* map = CEvtMgmtUiMapNavigationAdapter::NewL();
       
   516     CleanupStack::PushL(map);
       
   517     //if no map service provider
       
   518     if ( map->MapServiceProvidersL() == 0 ) 
       
   519         {
       
   520         CleanupStack::PopAndDestroy(); //map
       
   521         EVTUIDEBUG("- CEvtMgmtUiStartupView::DisableMapFunctionality() EFalse" );
       
   522         return EFalse;
       
   523         }
       
   524     
       
   525     //Retrieve coordinate info
       
   526     TCoordinate loc;
       
   527     iEngine->RetrieveLocationL( iModel->EventId( iContainer->CurrentItemIndex() ), loc );        
       
   528     CleanupStack::PopAndDestroy(); //map
       
   529     
       
   530     if( Math::IsNaN( loc.Latitude() ) || Math::IsNaN( loc.Latitude() )
       
   531                                 || loc.Latitude() == 0 || loc.Latitude() == 0 )
       
   532         { //if loc is not defined or it is not coordinate based
       
   533         EVTUIDEBUG("- CEvtMgmtUiStartupView::DisableMapFunctionality() EFalse" );
       
   534         return EFalse;
       
   535         }
       
   536     else
       
   537         {
       
   538         EVTUIDEBUG("- CEvtMgmtUiStartupView::DisableMapFunctionality() ETrue" );
       
   539         return ETrue;
       
   540         }    
       
   541     }
       
   542 
       
   543 // ---------------------------------------------------------------------------
       
   544 // void CEvtMgmtUiStartupView::DynInitMenuPaneL
       
   545 // ---------------------------------------------------------------------------
       
   546 //  
       
   547 void CEvtMgmtUiStartupView::DynInitMenuPaneL( TInt aResourceId, 
       
   548                                               CEikMenuPane*  aMenuPane  )
       
   549     {   
       
   550     iContainer->HandleMarkableListDynInitMenuPane( aResourceId, aMenuPane );
       
   551     
       
   552     TInt index = iContainer->CurrentItemIndex();
       
   553     TInt markItems = iContainer->NumberOfMarkedItems();
       
   554     switch ( aResourceId )
       
   555         {
       
   556         case R_EVTMGMTUI_STARTUP_MAINVIEWMENU:
       
   557         	{
       
   558         	// Order is
       
   559         	// 1. Marked
       
   560         	// 2. Index
       
   561         	// 3. Total Events 
       
   562         	
       
   563         	if(iContainer->NumberOfMarkedItems() == 0) // no item is marked
       
   564         	    {
       
   565             	//if no events then disable 'show'
       
   566             	if( iModel->TotalEvents() )
       
   567             	    {    
       
   568             		TEvtEventsStatusMask mask = iModel->EventsStatus();   	    
       
   569             	    
       
   570             	    switch( mask )
       
   571             	    	{
       
   572             	    	case CEvtMgmtUiModel::EEvtShowAttributeActive:
       
   573             	    	case CEvtMgmtUiModel::EEvtShowAttributeDraft:
       
   574             	    	case CEvtMgmtUiModel::EEvtShowAttributeCompleted:
       
   575           	        		aMenuPane->SetItemDimmed( EEvtMgmtUiEventUiEvtShow, ETrue ); 
       
   576           	        		break;
       
   577             	    	default:
       
   578           	        		aMenuPane->SetItemDimmed( EEvtMgmtUiEventUiEvtShow, EFalse ); 
       
   579             	    		break;	
       
   580             	    	}     	        
       
   581             	    }
       
   582             	 else
       
   583           	        aMenuPane->SetItemDimmed( EEvtMgmtUiEventUiEvtShow, ETrue ); 
       
   584             	 	
       
   585             	    
       
   586             	//if focus on 'create event'
       
   587     		    if( index == 0 )
       
   588     			    {
       
   589     				aMenuPane->SetItemDimmed( EEvtMgmtUiStartupViewOpen, ETrue );
       
   590     				aMenuPane->SetItemDimmed( EEvtEditorCmdDelete, ETrue );
       
   591     				aMenuPane->SetItemDimmed( EEvtEditorCmdActivate, ETrue ); 
       
   592     				aMenuPane->SetItemDimmed( EEvtEditorCmdSaveDraft, ETrue );
       
   593     				aMenuPane->SetItemDimmed(EEvtEditorCmdNavigateToPlace, ETrue);
       
   594     				aMenuPane->SetItemDimmed(EEvtEditorCmdShowOnMap, ETrue);
       
   595     			    }
       
   596     			else
       
   597     			    {
       
   598     			    if( iModel->TotalEvents() ) //if events are present 
       
   599     				    {
       
   600     				    aMenuPane->SetItemDimmed( EEvtMgmtUiStartupViewOpen, EFalse );
       
   601     					aMenuPane->SetItemDimmed( EEvtEditorCmdDelete, EFalse );
       
   602     					aMenuPane->SetItemDimmed( EEvtEditorCmdActivate, EFalse );
       
   603     					aMenuPane->SetItemDimmed( EEvtEditorCmdSaveDraft, EFalse );
       
   604     					
       
   605     					//change status
       
   606                         switch(iModel->EventFromModel(index).EventStatus())
       
   607                             {
       
   608                             case EActive:
       
   609                                {
       
   610                                aMenuPane->SetItemDimmed( EEvtEditorCmdActivate, ETrue ); // State                          
       
   611                                break;
       
   612                                }
       
   613                             case EDraft:
       
   614                                {
       
   615                                aMenuPane->SetItemDimmed( EEvtEditorCmdSaveDraft, ETrue ); // State
       
   616                                if( !iModel->MandatoryFieldsFilled(index))
       
   617                                    aMenuPane->SetItemDimmed( EEvtEditorCmdActivate, ETrue );    
       
   618                                break;
       
   619                                }
       
   620                             default:                      
       
   621                                break;
       
   622                             }
       
   623                         
       
   624                         // if support for map functionality is there
       
   625                        if( EnableMapFunctionalityL() )
       
   626                             {
       
   627                             aMenuPane->SetItemDimmed(EEvtEditorCmdNavigateToPlace, EFalse);
       
   628                             aMenuPane->SetItemDimmed(EEvtEditorCmdShowOnMap, EFalse);
       
   629                             }
       
   630                         else
       
   631                             {
       
   632                             aMenuPane->SetItemDimmed(EEvtEditorCmdNavigateToPlace, ETrue);
       
   633                             aMenuPane->SetItemDimmed(EEvtEditorCmdShowOnMap, ETrue);
       
   634                             }
       
   635     				    }
       
   636     				else
       
   637     					{
       
   638     					aMenuPane->SetItemDimmed( EEvtMgmtUiStartupViewOpen, ETrue );
       
   639     					aMenuPane->SetItemDimmed( EEvtEditorCmdDelete, ETrue );	
       
   640     					aMenuPane->SetItemDimmed( EEvtEditorCmdActivate, ETrue ); 
       
   641     					aMenuPane->SetItemDimmed( EEvtEditorCmdSaveDraft, ETrue );
       
   642     					aMenuPane->SetItemDimmed(EEvtEditorCmdNavigateToPlace, ETrue);
       
   643     					aMenuPane->SetItemDimmed(EEvtEditorCmdShowOnMap, ETrue);
       
   644     					}
       
   645     				} 
       
   646         	    }
       
   647         	else // if there are marked items
       
   648         	    {
       
   649         	    aMenuPane->SetItemDimmed( EEvtMgmtUiEventUiEvtShow, ETrue );
       
   650         	    aMenuPane->SetItemDimmed( EEvtMgmtUiStartupViewCreate, ETrue );
       
   651         	    aMenuPane->SetItemDimmed( EEvtMgmtUiStartupViewOpen, ETrue );   
       
   652         	    aMenuPane->SetItemDimmed(EEvtEditorCmdNavigateToPlace, ETrue);
       
   653         	    aMenuPane->SetItemDimmed(EEvtEditorCmdShowOnMap, ETrue);
       
   654       	    
       
   655         	    switch(MarkedEventsStatus())
       
   656                     {
       
   657                     case EMarkedEventsStatusDraft:
       
   658                         {
       
   659                         aMenuPane->SetItemDimmed( EEvtEditorCmdActivate, EFalse ); 
       
   660                         aMenuPane->SetItemDimmed( EEvtEditorCmdSaveDraft, ETrue );
       
   661                         }
       
   662                         break;
       
   663                     case EMarkedEventsStatusActive:
       
   664                         {
       
   665                         aMenuPane->SetItemDimmed( EEvtEditorCmdActivate, ETrue ); 
       
   666                         aMenuPane->SetItemDimmed( EEvtEditorCmdSaveDraft, EFalse );
       
   667                         }
       
   668                         break;       
       
   669                    case EMarkedEventsStatusCompleted:       
       
   670                     default:
       
   671                         {
       
   672                         aMenuPane->SetItemDimmed( EEvtEditorCmdActivate, EFalse ); 
       
   673                         aMenuPane->SetItemDimmed( EEvtEditorCmdSaveDraft, EFalse );
       
   674                         }
       
   675                         break;        
       
   676                     }
       
   677         	    }
       
   678 		   
       
   679 			 break;           
       
   680              }
       
   681         case R_EVTMGMTUI_STARTUP_EVTSHOWMENU:
       
   682             {
       
   683             TEvtEventsStatusMask mask = iModel->EventsStatus();
       
   684            
       
   685 	        aMenuPane->SetItemDimmed( EEvtEditorCmdShowAll, EFalse );
       
   686 	        aMenuPane->SetItemDimmed( EEvtEditorCmdShowActive, EFalse );
       
   687 	        aMenuPane->SetItemDimmed( EEvtEditorCmdShowDrafts, EFalse );
       
   688 	        aMenuPane->SetItemDimmed( EEvtEditorCmdShowCompleted, EFalse );
       
   689             
       
   690             switch( iModel->StatusFilter() )
       
   691             	{
       
   692             	case CEvtMgmtUiEngine::EEvtFilterActive:
       
   693 	            	{
       
   694 			        aMenuPane->SetItemDimmed( EEvtEditorCmdShowActive, ETrue );
       
   695             		break;
       
   696 	            	}
       
   697             	case CEvtMgmtUiEngine::EEvtFilterDraft:
       
   698 	            	{
       
   699 			        aMenuPane->SetItemDimmed( EEvtEditorCmdShowDrafts, ETrue );
       
   700             		break;
       
   701 	            	}
       
   702                 case CEvtMgmtUiEngine::EEvtFilterCompleted:
       
   703                     {
       
   704                     aMenuPane->SetItemDimmed( EEvtEditorCmdShowCompleted, ETrue );
       
   705                     break;
       
   706                     }
       
   707             	case CEvtMgmtUiEngine::EEvtFilterAll:
       
   708 	            	{
       
   709 			        aMenuPane->SetItemDimmed( EEvtEditorCmdShowAll, ETrue );
       
   710             		break;
       
   711 	            	}
       
   712             	default:
       
   713             		break;
       
   714             	}
       
   715             	
       
   716         	if( !(mask & CEvtMgmtUiModel::EEvtShowAttributeActive) )
       
   717               	aMenuPane->SetItemDimmed( EEvtEditorCmdShowActive, ETrue );
       
   718             if( !(mask & CEvtMgmtUiModel::EEvtShowAttributeDraft) )
       
   719               	aMenuPane->SetItemDimmed( EEvtEditorCmdShowDrafts, ETrue );
       
   720             if( !(mask & CEvtMgmtUiModel::EEvtShowAttributeCompleted) )
       
   721                 aMenuPane->SetItemDimmed( EEvtEditorCmdShowCompleted, ETrue );         
       
   722             
       
   723             break;
       
   724             }
       
   725         case R_EVTMGMTUI_STARTUP_CHANGESTATUSMENU:
       
   726             {
       
   727 
       
   728             switch(MarkedEventsStatus())
       
   729                {
       
   730                case EMarkedEventsStatusDraft:
       
   731                    {
       
   732                    aMenuPane->SetItemDimmed( EEvtEditorCmdActivate, EFalse ); 
       
   733                    aMenuPane->SetItemDimmed( EEvtEditorCmdSaveDraft, ETrue );
       
   734                    }
       
   735                    break;
       
   736                case EMarkedEventsStatusActive:
       
   737                    {
       
   738                    aMenuPane->SetItemDimmed( EEvtEditorCmdActivate, ETrue ); 
       
   739                    aMenuPane->SetItemDimmed( EEvtEditorCmdSaveDraft, EFalse );
       
   740                    }
       
   741                    break;       
       
   742                case EMarkedEventsStatusCompleted:  
       
   743                default:
       
   744                    {
       
   745                    aMenuPane->SetItemDimmed( EEvtEditorCmdActivate, EFalse ); 
       
   746                    aMenuPane->SetItemDimmed( EEvtEditorCmdSaveDraft, EFalse );
       
   747                    }
       
   748                    break;        
       
   749                }
       
   750             }
       
   751             break;     
       
   752         case R_EVTMGMTUI_STARTUP_APPMENU:
       
   753         	{
       
   754 			HandleHelpFeature(*aMenuPane);
       
   755         	}
       
   756 			break; 
       
   757 		default:
       
   758 			break;
       
   759         }
       
   760     }
       
   761 
       
   762 // ---------------------------------------------------------------------------
       
   763 // void CEvtMgmtUiStartupView::HandleHelpFeature
       
   764 // ---------------------------------------------------------------------------
       
   765 //      
       
   766 void CEvtMgmtUiStartupView::HandleHelpFeature( CEikMenuPane& aMenuPane ) const
       
   767     {
       
   768     // The Help menu item must be displayed only if the Feature is supported.
       
   769     // If not, the Help item must be dimmed in the Options menu.
       
   770     if ( FeatureManager::FeatureSupported( KFeatureIdHelp ))
       
   771         {
       
   772         aMenuPane.SetItemDimmed( EAknCmdHelp, EFalse );
       
   773         }
       
   774     else
       
   775         {
       
   776         aMenuPane.SetItemDimmed( EAknCmdHelp, ETrue );
       
   777         }
       
   778     }
       
   779 
       
   780 // ---------------------------------------------------------------------------
       
   781 // CEvtMgmtUiStartupView::DeleteEventL()
       
   782 // It will delete event from database
       
   783 // ---------------------------------------------------------------------------
       
   784 //
       
   785 void CEvtMgmtUiStartupView::DeleteEventL()
       
   786     { 
       
   787     TInt cnt = iContainer->NumberOfMarkedItems();
       
   788     TInt index; 
       
   789     if(iEvtIdArray)
       
   790         iEvtIdArray->Reset();
       
   791     else
       
   792         iEvtIdArray = new(ELeave) RArray<TEvtEventId>();
       
   793     if(cnt)
       
   794         {
       
   795         EVTUIDEBUG1("CEvtMgmtUiStartupView::DeleteEventL() selected items = %d", cnt );  
       
   796 
       
   797         const CArrayFix<TInt>* evtarray = iContainer->MarkItems();  
       
   798         for(index=0;index<cnt;index++)
       
   799             {        
       
   800             TInt orginalIndex = iContainer->FilteredIndex((*evtarray)[index]);
       
   801             EVTUIDEBUG1("CEvtMgmtUiStartupView::DeleteEventL() listboxindexid = %d", orginalIndex );          
       
   802             EVTUIDEBUG1("Deleting event Event id = %d", EventId( orginalIndex ) );
       
   803             iEvtIdArray->Append( EventId( orginalIndex ) );
       
   804             }
       
   805         iEngine->DeleteEventsL( iEvtIdArray );
       
   806         }
       
   807     else
       
   808         {
       
   809         index = iContainer->CurrentItemIndex();
       
   810         EVTUIDEBUG1("CEvtMgmtUiStartupView::DeleteEventL() listboxindexid = %d", index );          
       
   811         if(index==KErrNotFound)
       
   812             return;        
       
   813         EVTUIDEBUG1("Deleting event Event id = %d", EventId(index) );
       
   814         iEvtIdArray->Append( EventId( index ) );
       
   815         iEngine->DeleteEventsL( iEvtIdArray );   
       
   816         }
       
   817     }
       
   818 
       
   819 // -----------------------------------------------------------------------------
       
   820 // CEvtMgmtUiEditorCmdHandler::DisplayConfirmationQueryDlg()
       
   821 // It shows confirmation query dialog
       
   822 // -----------------------------------------------------------------------------
       
   823 //
       
   824 TBool CEvtMgmtUiStartupView::DisplayConfirmationQueryDlgL( const TDesC& aMsg )
       
   825     {
       
   826     TBool response= EFalse;
       
   827     CAknQueryDialog* confirmationQuery = CAknQueryDialog::NewL();     
       
   828     response = confirmationQuery->ExecuteLD(R_EVTUI_CONFIRMATION_QUERY, aMsg);         
       
   829     return response;
       
   830     }
       
   831     
       
   832 // ---------------------------------------------------------------------------
       
   833 // CEvtMgmtUiStartupView::UpdateViewL()
       
   834 // It will update view
       
   835 // ---------------------------------------------------------------------------
       
   836 //
       
   837 void CEvtMgmtUiStartupView::UpdateViewL( )
       
   838     {     
       
   839     TInt index = iModel->UpdatedCurrentItemIndex( );
       
   840     
       
   841     iContainer->UpdateListBoxL( index );
       
   842     
       
   843     HandleCmdL( EListBoxItemFocused );
       
   844     
       
   845     if(iModel->TotalEvents())
       
   846        MenuBar()->SetMenuTitleResourceId ( R_EVTMGMTUI_STARTUP_MENUBAR_MARK );
       
   847     else
       
   848        MenuBar()->SetMenuTitleResourceId ( R_EVTMGMTUI_STARTUP_MENUBAR );
       
   849     }
       
   850 	
       
   851 // ---------------------------------------------------------------------------
       
   852 // CEvtMgmtUiStartupView::HandleCmdL()
       
   853 // Derived from MEvtMgmtUiEditorExitCmdHandler
       
   854 // ---------------------------------------------------------------------------
       
   855 //
       
   856 void CEvtMgmtUiStartupView::HandleCmdL( TEvtMgmtUiCmd aCommand )
       
   857 	{
       
   858 
       
   859     switch( aCommand )
       
   860         {
       
   861         // Handle any plug-in specific internal commands here
       
   862         case EListBoxItemDoubleClicked:
       
   863             {
       
   864             if( iContainer->NumberOfMarkedItems() )
       
   865                 {
       
   866                 TRAPD( err, MenuBar()->TryDisplayContextMenuBarL() );
       
   867                 User::LeaveIfError( err );  
       
   868                 }
       
   869             else
       
   870                 {
       
   871     			TInt index = iContainer->CurrentItemIndex();
       
   872     			if(index>0)
       
   873     				{
       
   874     				HandleCommandL(EEvtMgmtUiStartupViewOpen);
       
   875     				}
       
   876     			else
       
   877     			    {
       
   878                     HandleCommandL(EEvtMgmtUiStartupViewCreate);
       
   879                     }		
       
   880                 }
       
   881 			break;
       
   882             }
       
   883         case EListBoxItemFocused:
       
   884         		{
       
   885         		if(iIsEmbeddedApp)
       
   886         		    {
       
   887         		    if(iContainer->NumberOfMarkedItems())       
       
   888         		        {
       
   889         		        MenuBar()->SetContextMenuTitleResourceId( R_EVTMGMTUI_STARTUP_CONTEXTMENUBAR );
       
   890         		        SetCba(R_EVTMGMTUI_STARTUP_CBA_OPTIONS_EMBEDDED);
       
   891         		        }
       
   892         		    else
       
   893         		        {
       
   894         	        	if( 0 == iContainer->CurrentItemIndex() )    	        	    
       
   895         	        		SetCba(R_EVTMGMTUI_STARTUP_CBA_EMBEDDED);    	        	    
       
   896         	        	else
       
   897         	        	    SetCba(R_EVTMGMTUI_STARTUP_CBA_OPEN_EMBEDDED);
       
   898         		        }
       
   899         		    }
       
   900         		else
       
   901         		    {
       
   902         		    if(iContainer->NumberOfMarkedItems())
       
   903         		        {        		       
       
   904         		        MenuBar()->SetContextMenuTitleResourceId( R_EVTMGMTUI_STARTUP_CONTEXTMENUBAR );        		                 
       
   905                         SetCba(R_EVTMGMTUI_STARTUP_CBA_OPTIONS);
       
   906         		        }
       
   907                     else
       
   908                         {
       
   909             		    if( 0 == iContainer->CurrentItemIndex() )                     
       
   910                             SetCba(R_EVTMGMTUI_STARTUP_CBA);                        
       
   911                         else
       
   912                             SetCba(R_EVTMGMTUI_STARTUP_CBA_OPEN);
       
   913                         }
       
   914         		    }
       
   915 	        	break;
       
   916 	        	}
       
   917         case EScreenSizeChanged:
       
   918             {
       
   919             if( iContainer )
       
   920                 {
       
   921                 iContainer->SetRect( ClientRect());     
       
   922                 }
       
   923             break;
       
   924             }
       
   925         case EListBoxItemDeleted:
       
   926             {
       
   927             HandleCommandL( EEvtEditorCmdDelete );
       
   928             break;
       
   929             }
       
   930         case EListBoxFilterCountChanged:
       
   931             {
       
   932             if( iContainer->FilteredCount() > 1 )
       
   933                MenuBar()->SetMenuTitleResourceId ( R_EVTMGMTUI_STARTUP_MENUBAR_MARK );
       
   934             else
       
   935                MenuBar()->SetMenuTitleResourceId ( R_EVTMGMTUI_STARTUP_MENUBAR );
       
   936             break;
       
   937             }
       
   938         default:
       
   939             {
       
   940             break;  
       
   941             }
       
   942         }
       
   943 	}
       
   944 
       
   945 // -----------------------------------------------------------------------------
       
   946 // CEvtMgmtUiStartupView::SetCba
       
   947 // -----------------------------------------------------------------------------
       
   948 //
       
   949 void CEvtMgmtUiStartupView::SetCba( TInt aResourceId ) 
       
   950 	{
       
   951 	if( Cba() )
       
   952 	    {
       
   953 	   	TRAP_IGNORE(Cba()->SetCommandSetL(aResourceId));
       
   954 	    }
       
   955 	Cba()->DrawDeferred(); 
       
   956 	}
       
   957 		
       
   958 // ---------------------------------------------------------------------------
       
   959 // CEvtMgmtUiStartupView::EventIdOfCurrentItem()
       
   960 // It will return the event-id of the selected item 
       
   961 // ---------------------------------------------------------------------------
       
   962 //
       
   963 TEvtEventId CEvtMgmtUiStartupView::EventIdOfCurrentItem()
       
   964     {
       
   965     TInt index = iContainer->CurrentItemIndex();
       
   966     return iModel->EventId( index );
       
   967     }
       
   968 
       
   969 // ---------------------------------------------------------------------------
       
   970 // CEvtMgmtUiStartupView::EventId()
       
   971 // It will return the event id of event
       
   972 // ---------------------------------------------------------------------------
       
   973 //
       
   974 TEvtEventId CEvtMgmtUiStartupView::EventId( TInt aIndex )
       
   975     {     
       
   976     return iModel->EventId( aIndex );
       
   977     }
       
   978 
       
   979 // ---------------------------------------------------------------------------
       
   980 // CEvtMgmtUiStartupView::MarkedEventsStatus()
       
   981 // It will return type of marked events
       
   982 // ---------------------------------------------------------------------------
       
   983 //
       
   984 TInt CEvtMgmtUiStartupView::MarkedEventsStatus()
       
   985     {
       
   986     TInt index=0;
       
   987     TInt cnt = iContainer->NumberOfMarkedItems();
       
   988     const CArrayFix<TInt>* evtarray = iContainer->MarkItems();  
       
   989     
       
   990     TInt orginalIndex = iContainer->FilteredIndex((*evtarray)[index]);
       
   991     TMarkedEventsStatus status = static_cast<TMarkedEventsStatus>(iModel->EventStatus(orginalIndex));
       
   992     for( index = 1; index<cnt; index++ )
       
   993         {
       
   994         orginalIndex = iContainer->FilteredIndex((*evtarray)[index]);
       
   995         if( status != iModel->EventStatus( orginalIndex ) )
       
   996             { 
       
   997             return EMarkedEventsStatusMix;            
       
   998             }
       
   999         }
       
  1000     return status;    
       
  1001     }
       
  1002 
       
  1003 // ---------------------------------------------------------------------------
       
  1004 // CEvtMgmtUiStartupView::NotifyEventChangeL()
       
  1005 // Derived from MEvtMgmtUiEngineObserver
       
  1006 // ---------------------------------------------------------------------------
       
  1007 //
       
  1008 void CEvtMgmtUiStartupView::NotifyEventChangeL(TInt aErrorCode, TInt aState )
       
  1009     {
       
  1010     if( aErrorCode == KErrServerTerminated || 
       
  1011         aErrorCode == KErrServerBusy ||
       
  1012         aErrorCode == KErrNotReady ||
       
  1013         aErrorCode == KErrNoMemory || aErrorCode == KErrDiskFull )
       
  1014         {
       
  1015 	    TPtrC buf;
       
  1016     	CTextResolver* textResolver = CTextResolver::NewLC(*iCoeEnv);
       
  1017     	buf.Set(textResolver->ResolveErrorString(aErrorCode));
       
  1018     	
       
  1019 	    CAknErrorNote* dialog = 
       
  1020 	        new(ELeave)CAknErrorNote(ETrue);    
       
  1021 	    dialog->SetTone(CAknNoteDialog::EErrorTone);
       
  1022 	    dialog->ExecuteLD( buf ); 
       
  1023     	
       
  1024     	CleanupStack::PopAndDestroy( textResolver );
       
  1025     	
       
  1026         EVTUIDEBUG("Exiting application as server is not ready." );
       
  1027         // The User has exited the application using the Exit option from
       
  1028         //.Options menu.  But, thats possible only if we exit the application
       
  1029         // with EAknCmdExit.
       
  1030         // A bit of convoluted logic but needed because we are using the
       
  1031         // same components for the Settings UI Server as well as LC.
       
  1032         
       
  1033         CEikonEnv* env = CEikonEnv::Static();
       
  1034        	CEikAppServer* server = env->AppServer();
       
  1035 		if ( server )
       
  1036 			{
       
  1037 			server->NotifyServerExit( EAknCmdExit );
       
  1038 			}
       
  1039 	    CAknAppUi* appUi = static_cast< CAknAppUi* >( env->AppUi());
       
  1040 	    appUi->RunAppShutter();  
       
  1041         return;
       
  1042         }
       
  1043 
       
  1044     if( aState == CEvtMgmtUiLbtAdapter::ELbtAdapterDelete || 
       
  1045 		aState == CEvtMgmtUiLbtAdapter::ELbtAdapterDeleteTriggers || 
       
  1046 		aState == CEvtMgmtUiLbtAdapter::ELbtAdapterSetTriggersState  || 
       
  1047 		aState == CEvtMgmtUiLbtAdapter::ELbtAdapterSetTriggerState )
       
  1048         {
       
  1049         EVTUIDEBUG1("+ CEvtMgmtUiStartupView::NotifyEventChangeL error =%d", aErrorCode ); 
       
  1050            
       
  1051         iWaitState = EWaitDlgDestroy;
       
  1052         if(aErrorCode != KErrNone && aErrorCode != KErrCancel)
       
  1053             {
       
  1054             TBuf<32> err;
       
  1055             err.Copy(_L("Error ="));
       
  1056             err.AppendNum( aErrorCode );
       
  1057             CEikonEnv::Static()->AlertWin(err);
       
  1058             }      
       
  1059             
       
  1060         EVTUIDEBUG("- CEvtMgmtUiStartupView::NotifyEventChangeL");
       
  1061         }
       
  1062 	
       
  1063 
       
  1064     if( aState == CEvtMgmtUiLbtAdapter::ELbtAdapterSetTriggersState  || 
       
  1065 		aState == CEvtMgmtUiLbtAdapter::ELbtAdapterSetTriggerState ||
       
  1066     	aState == CEvtMgmtUiLbtAdapter::ELbtAdapterCreate  || 
       
  1067 		aState == CEvtMgmtUiLbtAdapter::ELbtAdapterUpdate ||
       
  1068     	aState == CEvtMgmtUiLbtAdapter::ELbtAdapterDelete  || 
       
  1069 		aState == CEvtMgmtUiLbtAdapter::ELbtAdapterDeleteTriggers )
       
  1070 		{
       
  1071         if( iModel && iContainer )
       
  1072         	{
       
  1073     		iModel->SetCurrentItemId( iContainer->CurrentItemIndex() );
       
  1074     		if( !( aState == CEvtMgmtUiLbtAdapter::ELbtAdapterDelete  || 
       
  1075 					aState == CEvtMgmtUiLbtAdapter::ELbtAdapterDeleteTriggers ) )
       
  1076 				{
       
  1077     			iModel->SetStatusFilter( CEvtMgmtUiEngine::EEvtFilterAll ); 
       
  1078 				}
       
  1079         	}
       
  1080 		}
       
  1081     }
       
  1082 
       
  1083 // ---------------------------------------------------------------------------
       
  1084 // CEvtMgmtUiStartupView::NotifyModelChangeL()
       
  1085 // Derived from MEvtMgmtUiEngineObserver
       
  1086 // ---------------------------------------------------------------------------
       
  1087 //
       
  1088 void CEvtMgmtUiStartupView::NotifyModelChangeL()
       
  1089     {
       
  1090 	iEngine->UpdateModelL(iModel->EventsArray(), CEvtMgmtUiEngine::EEvtFilterAll );
       
  1091 	iModel->UpdateEventsStatus( );
       
  1092     UpdateViewL( ); 
       
  1093     }    
       
  1094 
       
  1095 // ---------------------------------------------------------------------------
       
  1096 // void CEvtMgmtUiStartupView::StartWaitDialogL
       
  1097 // ---------------------------------------------------------------------------
       
  1098 //  
       
  1099 void CEvtMgmtUiStartupView::StartWaitDialogL()
       
  1100     {    
       
  1101     HBufC* waitText = NULL;
       
  1102     TInt cnt = iContainer->NumberOfMarkedItems();
       
  1103     if(cnt>1)
       
  1104         {
       
  1105         if( iWaitState == EWaitDlgLaunchToDelete )
       
  1106             waitText = StringLoader::LoadLC(R_LOCEV_NOTE_MULTIPLEEVT_DELETE, CEikonEnv::Static() );
       
  1107         if(  iWaitState == EWaitDlgLaunchToChangeStatus && iEvtStatus == EActive )
       
  1108             waitText = StringLoader::LoadLC(R_LOCEV_NOTE_MULTIPLEEVT_ACTIVATE, CEikonEnv::Static() );
       
  1109         if(  iWaitState == EWaitDlgLaunchToChangeStatus && iEvtStatus == EDraft )
       
  1110             waitText = StringLoader::LoadLC(R_LOCEV_NOTE_MULTIPLEEVT_DRAFT, CEikonEnv::Static() );
       
  1111         }
       
  1112     else
       
  1113         {
       
  1114         if( iWaitState == EWaitDlgLaunchToDelete )
       
  1115             waitText = StringLoader::LoadLC(R_LOCEV_NOTE_SINGLEEVT_DELETE, CEikonEnv::Static() );
       
  1116         if(  iWaitState == EWaitDlgLaunchToChangeStatus && iEvtStatus == EActive )
       
  1117             waitText = StringLoader::LoadLC(R_LOCEV_NOTE_SINGLEEVT_ACTIVATE, CEikonEnv::Static() );
       
  1118         if(  iWaitState == EWaitDlgLaunchToChangeStatus && iEvtStatus == EDraft )
       
  1119             waitText = StringLoader::LoadLC(R_LOCEV_NOTE_SINGLEEVT_DRAFT, CEikonEnv::Static() );
       
  1120         }
       
  1121     
       
  1122     CAknWaitNoteWrapper* waitNoteWrapper = CAknWaitNoteWrapper::NewL();
       
  1123 	// Required reinterpret_cast as CAknWaitNoteWrapper inherits privately from CActive
       
  1124     CleanupStack::PushL(reinterpret_cast<CBase*>(waitNoteWrapper)); 
       
  1125 	
       
  1126 	// This is a blocking call, remember the wrapper isn't a dialog, so it doesn't need the 
       
  1127 	// EEikDialogFlagWait flag to make it blocking 
       
  1128     waitNoteWrapper->ExecuteL(R_EVTMGMTUI_WAITDLG_CANCEL, *this, *waitText, ETrue); // this is a blocking call, remember the wrapper isn't a dialog, so it doesn't need the EEikDialogFlagWait flag to make it blocking 
       
  1129        
       
  1130     CleanupStack::PopAndDestroy(2); //waitText, waitNoteWrapper
       
  1131     	
       
  1132   	if(iDisplayNote )
       
  1133       {
       
  1134       iDisplayNote = EFalse;
       
  1135       HBufC* warningMsg = StringLoader::LoadLC( R_EVTUI_MANDATORYFIELDS_WARNING, iCoeEnv );
       
  1136       CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( *warningMsg );
       
  1137       dlg->PrepareLC(R_EVTUI_MESSAGE_QUERY);
       
  1138       dlg->RunLD();
       
  1139       CleanupStack::PopAndDestroy(warningMsg); 
       
  1140       }
       
  1141     }
       
  1142 
       
  1143 // ---------------------------------------------------------------------------
       
  1144 // void CEvtMgmtUiStartupView::DialogDismissedL
       
  1145 // ---------------------------------------------------------------------------
       
  1146 //  
       
  1147 void CEvtMgmtUiStartupView::DialogDismissedL(TInt aButtonId)
       
  1148     {   
       
  1149     if(aButtonId == EEikBidCancel)
       
  1150         iEngine->CancelRequest();// Cancel
       
  1151     }
       
  1152 
       
  1153 // ---------------------------------------------------------------------------
       
  1154 // void CEvtMgmtUiStartupView::IsProcessDone
       
  1155 // ---------------------------------------------------------------------------
       
  1156 //  
       
  1157 TBool CEvtMgmtUiStartupView::IsProcessDone() const
       
  1158     {
       
  1159     if(iWaitState == EWaitDlgDestroy)
       
  1160         return ETrue;
       
  1161     else
       
  1162         return EFalse;
       
  1163     }
       
  1164 
       
  1165 // ---------------------------------------------------------------------------
       
  1166 // void CEvtMgmtUiStartupView::ProcessFinished
       
  1167 // ---------------------------------------------------------------------------
       
  1168 //  
       
  1169 void CEvtMgmtUiStartupView::ProcessFinished()
       
  1170     {      
       
  1171     }
       
  1172 
       
  1173 // ---------------------------------------------------------------------------
       
  1174 // void CEvtMgmtUiStartupView::StepL
       
  1175 // ---------------------------------------------------------------------------
       
  1176 //  
       
  1177 void CEvtMgmtUiStartupView::StepL()
       
  1178     {
       
  1179     if(iWaitState == EWaitDlgLaunchToDelete)
       
  1180         {
       
  1181         iWaitState = EWaitDlgInitiateProcess;
       
  1182         DeleteEventL();        
       
  1183         }
       
  1184     if(iWaitState == EWaitDlgLaunchToChangeStatus)
       
  1185         {
       
  1186         iWaitState = EWaitDlgInitiateProcess;
       
  1187         ChangeEventStatusL(iEvtStatus);        
       
  1188         }
       
  1189     }
       
  1190 
       
  1191 // ---------------------------------------------------------------------------
       
  1192 // void CEvtMgmtUiStartupView::StepL
       
  1193 // ---------------------------------------------------------------------------
       
  1194 // 
       
  1195 TInt CEvtMgmtUiStartupView::CycleError(TInt aError)
       
  1196 	{ 
       
  1197 	if(aError != KErrNone)
       
  1198 		{
       
  1199 		CEikonEnv::Static()->AlertWin(KWaitCycleError());
       
  1200 		iWaitState = EWaitDlgDestroy;
       
  1201 		}
       
  1202 	return KErrNone; 
       
  1203 	}
       
  1204 	
       
  1205 // End of File
       
  1206