calendarui/controller/src/calendeleteui.cpp
changeset 0 f979ecb2b13e
child 14 21239b3bcd78
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Handles deletion
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include <Calendar.rsg>
       
    21 #include <calendateutils.h>
       
    22 #include <calenagendautils.h>
       
    23 #include <aknnotewrappers.h>
       
    24 #include <AknWaitDialog.h>
       
    25 #include <calcommon.h>
       
    26 #include <calentryview.h>
       
    27 #include <calinstance.h>
       
    28 #include <calinstanceview.h>
       
    29 #include <caltime.h>
       
    30 #include <centralrepository.h>
       
    31 #include <eikenv.h>
       
    32 #include <StringLoader.h>
       
    33 #include <sysutil.h>
       
    34 #include <calenglobaldata.h>
       
    35 #include <calrrule.h>
       
    36 #include <calsession.h>
       
    37 #include <calencommands.hrh>            // Calendar commands
       
    38 #include <calencontext.h>
       
    39 #include <caleninstanceid.h>            // TCalenInstanceId
       
    40 #include <calenactionuiutils.h>
       
    41 #include <calcalendarinfo.h>
       
    42 
       
    43 #include "calendarui_debug.h"           // Debug
       
    44 #include "calendeleteui.h"
       
    45 #include "calencontroller.h"
       
    46 #include "CleanupResetAndDestroy.h"
       
    47 #include "CalenInterimUtils2.h"
       
    48 #include "CalendarPrivateCRKeys.h"      // For CalendarInternalCRKeys.h
       
    49 #include "calenmultipledbmanager.h"
       
    50 
       
    51 // Local constants
       
    52 const TInt KEntriesToDelete = 1;
       
    53 
       
    54 // ----------------------------------------------------------------------------
       
    55 // CCalenDeleteUi::NewL
       
    56 // Two phased constructor
       
    57 // (other items were commented in a header).
       
    58 // ----------------------------------------------------------------------------
       
    59 //
       
    60 CCalenDeleteUi* CCalenDeleteUi::NewL( CCalenController& aController )
       
    61     {
       
    62     TRACE_ENTRY_POINT;
       
    63 
       
    64     CCalenDeleteUi* self = new( ELeave ) CCalenDeleteUi( aController );
       
    65     CleanupStack::PushL( self );
       
    66     self->ConstructL();
       
    67     CleanupStack::Pop( self );
       
    68 
       
    69     TRACE_EXIT_POINT;
       
    70     return self;
       
    71     }
       
    72 
       
    73 // ----------------------------------------------------------------------------
       
    74 // CCalenDeleteUi::CCalenDeleteUi
       
    75 // ?implementation_description
       
    76 // (other items were commented in a header).
       
    77 // ----------------------------------------------------------------------------
       
    78 //
       
    79 CCalenDeleteUi::CCalenDeleteUi( CCalenController& aController )
       
    80     : iEikEnv( CEikonEnv::Static() ), iController( aController )
       
    81     {
       
    82     TRACE_ENTRY_POINT;
       
    83     TRACE_EXIT_POINT;
       
    84     }
       
    85 
       
    86 // ----------------------------------------------------------------------------
       
    87 // CCalenDeleteUi::~CCalenDeleteUi
       
    88 // Destructor
       
    89 // (other items were commented in a header).
       
    90 // ----------------------------------------------------------------------------
       
    91 //
       
    92 CCalenDeleteUi::~CCalenDeleteUi()
       
    93     {
       
    94     TRACE_ENTRY_POINT;
       
    95 
       
    96     if( iWaitDialog )
       
    97         {
       
    98         delete iWaitDialog;
       
    99         iWaitDialog = NULL;
       
   100         }
       
   101 
       
   102     if( iGlobalData )
       
   103         {
       
   104         iGlobalData->Release();
       
   105         }
       
   106 
       
   107     if( iDelAllRange )
       
   108         delete iDelAllRange;
       
   109 
       
   110     iDeleteColIds.Reset();
       
   111     
       
   112     TRACE_EXIT_POINT;
       
   113     }
       
   114 
       
   115 // ----------------------------------------------------------------------------
       
   116 // CCalenDeleteUi::ConstructL
       
   117 // Second phase of construction
       
   118 // (other items were commented in a header).
       
   119 // ----------------------------------------------------------------------------
       
   120 //
       
   121 void CCalenDeleteUi::ConstructL()
       
   122     {
       
   123     TRACE_ENTRY_POINT;
       
   124 
       
   125     iGlobalData = CCalenGlobalData::InstanceL();
       
   126 
       
   127     // Both the entry view and instance views are needed
       
   128     // by the deleteUi commands, there queue the construction of both
       
   129     RArray<TInt> colArray;
       
   130     iController.GetActiveCollectionidsL(colArray);
       
   131     
       
   132     CCalInstanceView* instanceView = iGlobalData->InstanceViewL(colArray);
       
   133     colArray.Reset();
       
   134     if( !instanceView )
       
   135         {
       
   136         iController.RegisterForNotificationsL( this, ECalenNotifyEntryInstanceViewCreated );
       
   137         }
       
   138     iController.RegisterForNotificationsL( this, ECalenNotifyCancelDelete );
       
   139     iMoreEntriesToDelete = EFalse;
       
   140     iDisplayQuery = EFalse;
       
   141     iEntriesToDelete = KEntriesToDelete;
       
   142     iDelAllRange = NULL;
       
   143     TRACE_EXIT_POINT;
       
   144     }
       
   145 
       
   146 // ----------------------------------------------------------------------------
       
   147 // CCalenDeleteUi::HandleECalenNotifyViewCreatedL
       
   148 // Handles ECalenNotifyViewCreated.
       
   149 // (other items were commented in a header).
       
   150 // ----------------------------------------------------------------------------
       
   151 //
       
   152 void CCalenDeleteUi::HandleECalenNotifyViewCreatedL()
       
   153     {
       
   154     TRACE_ENTRY_POINT;
       
   155     RArray<TInt> colArray;
       
   156     iController.GetActiveCollectionidsL(colArray);
       
   157     
       
   158     if( iGlobalData->InstanceViewL(colArray) )
       
   159         {
       
   160         // Handle the outstanding command
       
   161         HandleCommandL( iStoredCommand );
       
   162 
       
   163         // Cancel the notify as the entry view is now
       
   164         // constructed.
       
   165         iController.CancelNotifications( this );
       
   166         }
       
   167     colArray.Reset();
       
   168     TRACE_EXIT_POINT;
       
   169     }
       
   170 
       
   171 // ----------------------------------------------------------------------------
       
   172 // CCalenDeleteUi::HandleNotification
       
   173 // Handles notifications.
       
   174 // (other items were commented in a header).
       
   175 // ----------------------------------------------------------------------------
       
   176 //
       
   177 void CCalenDeleteUi::HandleNotification(const TCalenNotification aNotification )
       
   178     {
       
   179     TRACE_ENTRY_POINT;
       
   180 
       
   181     if ( aNotification == ECalenNotifyEntryInstanceViewCreated )
       
   182         {
       
   183         PIM_TRAPD_HANDLE( HandleECalenNotifyViewCreatedL() );
       
   184         }
       
   185     if( aNotification == ECalenNotifyCancelDelete)
       
   186         {
       
   187         if(iMutlipleContextIdsCount)
       
   188             {
       
   189             // get the context
       
   190             MCalenContext& context = iGlobalData->Context();
       
   191             // reset the multiple contexts
       
   192             context.ResetMultipleContextIds();
       
   193             
       
   194             // dismiss the waitdialog
       
   195             if(iWaitDialog)
       
   196                 {
       
   197                 TRAP_IGNORE(iWaitDialog->ProcessFinishedL());
       
   198                 }
       
   199             }
       
   200         }
       
   201     TRACE_EXIT_POINT;
       
   202     }
       
   203 
       
   204 // ----------------------------------------------------------------------------
       
   205 // CCalenDeleteUi::HandleCommandL
       
   206 // Handles action ui commands
       
   207 // (other items were commented in a header).
       
   208 // ----------------------------------------------------------------------------
       
   209 //
       
   210 TBool CCalenDeleteUi::HandleCommandL( const TCalenCommand& aCommand )
       
   211     {
       
   212     TRACE_ENTRY_POINT;
       
   213     TBool continueCommand(EFalse);
       
   214     
       
   215     RArray<TInt> colArray;
       
   216     iController.GetActiveCollectionidsL(colArray);
       
   217     
       
   218     if( colArray.Count() && !( iGlobalData->InstanceViewL(colArray) ) )
       
   219         {
       
   220         iStoredCommand = aCommand;
       
   221         }
       
   222     else
       
   223         {
       
   224         switch( aCommand.Command() )
       
   225             {
       
   226             case ECalenDeleteCurrentEntry:
       
   227                 DeleteCurrentEntryL(); // Entry & instance
       
   228                 break;
       
   229 
       
   230             case ECalenDeleteSeries:
       
   231                 DeleteThisOrAllL( CalCommon::EThisAndAll );
       
   232                 break;
       
   233                 
       
   234             case ECalenDeleteCurrentOccurrence:
       
   235                 DeleteThisOrAllL( CalCommon::EThisOnly );
       
   236                 break;
       
   237                 
       
   238             case ECalenDeleteEntryWithoutQuery:
       
   239                 continueCommand = DeleteEntryWithoutQueryL();
       
   240                 break;
       
   241 
       
   242             case ECalenDeleteAllEntries:
       
   243                 HandleDeleteAllEntriesL();
       
   244                 break;
       
   245 
       
   246             case ECalenDeleteEntriesBeforeDate:
       
   247                 DeleteEntriesBeforeDateL(); // EntryView & instance
       
   248                 break;
       
   249 
       
   250             default:
       
   251                 // Controller decided this class was the place to handle this
       
   252                 // command but it wasn't in our list; something has gone wrong.
       
   253                 //ASSERT( EFalse );
       
   254                 break;
       
   255             }
       
   256         }
       
   257     colArray.Reset();
       
   258     TRACE_EXIT_POINT;
       
   259     return continueCommand;
       
   260     }
       
   261 
       
   262 // ----------------------------------------------------------------------------
       
   263 // CCalenDeleteUi::CalenCommandHandlerExtensionL
       
   264 // Dummy implementation.
       
   265 // (other items were commented in a header).
       
   266 // ----------------------------------------------------------------------------
       
   267 //
       
   268 TAny* CCalenDeleteUi::CalenCommandHandlerExtensionL( TUid /*aExtensionUid*/ )
       
   269     {
       
   270     TRACE_ENTRY_POINT;
       
   271     TRACE_EXIT_POINT;
       
   272     return NULL;
       
   273     }
       
   274 
       
   275 // ----------------------------------------------------------------------------
       
   276 // CCalenDeleteUi::DeleteThisOrAllL
       
   277 // Deletes series repeating entry
       
   278 // (other items were commented in a header).
       
   279 // ----------------------------------------------------------------------------
       
   280 //
       
   281 void CCalenDeleteUi::DeleteThisOrAllL( CalCommon::TRecurrenceRange aRepeatType )
       
   282     {
       
   283     TRACE_ENTRY_POINT;
       
   284     
       
   285     TBool isDeleted( EFalse );
       
   286     
       
   287     RArray<TInt> colIdArray;
       
   288     colIdArray.AppendL(iGlobalData->Context().InstanceId().iColId);
       
   289     
       
   290     if( iGlobalData->Context().InstanceId().iEntryLocalUid )
       
   291         {
       
   292         CCalInstance* instance = 
       
   293             CalenActionUiUtils::FindPossibleInstanceL( 
       
   294                                            iGlobalData->Context().InstanceId(),
       
   295                                            *iGlobalData->InstanceViewL(colIdArray) );
       
   296             if( instance )
       
   297             {
       
   298             CleanupStack::PushL( instance );
       
   299             isDeleted = DeleteSingleInstanceL( instance, aRepeatType );
       
   300             
       
   301             if( isDeleted )
       
   302                 {
       
   303                 CleanupStack::Pop( instance );
       
   304                 }
       
   305             else
       
   306                 {
       
   307                 CleanupStack::PopAndDestroy( instance );
       
   308                 }
       
   309             }
       
   310         }
       
   311     colIdArray.Reset();
       
   312     
       
   313     iController.BroadcastNotification( isDeleted? ECalenNotifyEntryDeleted :
       
   314                                                                ECalenNotifyDeleteFailed );
       
   315     
       
   316     TRACE_EXIT_POINT;
       
   317     }
       
   318 
       
   319 // ----------------------------------------------------------------------------
       
   320 // CCalenDeleteUi::DeleteEntryWithoutQueryL()
       
   321 // Deletes the current entry
       
   322 // (other items were commented in a header).
       
   323 // ----------------------------------------------------------------------------
       
   324 //
       
   325 TBool CCalenDeleteUi::DeleteEntryWithoutQueryL()
       
   326     {
       
   327     TRACE_ENTRY_POINT;
       
   328 	TBool continueCommand(EFalse);
       
   329     
       
   330 	// get the context
       
   331 	MCalenContext& context = iGlobalData->Context();
       
   332 	
       
   333 	// get the multliple context ids count
       
   334 	iMutlipleContextIdsCount = context.MutlipleContextIdsCount();
       
   335 	
       
   336 	ASSERT( iMutlipleContextIdsCount );
       
   337 
       
   338 	    if(!iMoreEntriesToDelete)
       
   339 		    {
       
   340 		    iDisplayQuery = ShowMultipleEntriesDeleteQueryL(iMutlipleContextIdsCount);
       
   341 		    }
       
   342 		
       
   343 		if(iDisplayQuery)
       
   344 			{
       
   345 			if(!iMoreEntriesToDelete)	
       
   346 			    {
       
   347 			    DisplayWaitDialogL();
       
   348 			    }
       
   349 			// get the multiple context instance ids
       
   350 			RArray<TCalenInstanceId>& multipleContextIds = context.GetMutlipleContextIds();
       
   351 			
       
   352 			if(iMutlipleContextIdsCount <= iEntriesToDelete )
       
   353 			    {
       
   354 			    iMoreEntriesToDelete = EFalse; 
       
   355 			    iEntriesToDelete = iMutlipleContextIdsCount;
       
   356 			    }
       
   357 			else
       
   358 			    {
       
   359 			    iMoreEntriesToDelete = ETrue;
       
   360 	            // set the continue command flag if more entries are there to delete
       
   361 			    continueCommand = ETrue;
       
   362 			    }
       
   363 			    
       
   364 			TInt index(0);
       
   365 			while(index<iEntriesToDelete)
       
   366 			    {
       
   367 			    // get the local uid of the entry through multiple context list
       
   368 			    TCalLocalUid entryLocalUid = multipleContextIds[0].iEntryLocalUid;			    
       
   369 			    if(entryLocalUid)
       
   370 			        {
       
   371 			        DeleteEntryL(entryLocalUid, multipleContextIds[0].iColId);
       
   372 			        }
       
   373 			    // remove mutliple context based on the instanceid
       
   374 			    context.RemoveMultipleContextId(multipleContextIds[0]);
       
   375 			    index++;
       
   376 			   }
       
   377 
       
   378 			if(!iMoreEntriesToDelete)
       
   379 			    {
       
   380 			    MarkedEntriesDeletedL();    
       
   381 			    }
       
   382 			}
       
   383         else
       
   384             {
       
   385             context.ResetMultipleContextIds();
       
   386             // notify delete failed
       
   387             iController.BroadcastNotification(ECalenNotifyDeleteFailed);    
       
   388             }
       
   389 	
       
   390     TRACE_EXIT_POINT;
       
   391     return continueCommand;
       
   392     }
       
   393 
       
   394 // ----------------------------------------------------------------------------
       
   395 // CCalenDeleteUi::DeleteCurrentEntryL
       
   396 // Deletes the current entry
       
   397 // (other items were commented in a header).
       
   398 // ----------------------------------------------------------------------------
       
   399 //
       
   400 void CCalenDeleteUi::DeleteCurrentEntryL()
       
   401     {
       
   402     TRACE_ENTRY_POINT;
       
   403 
       
   404     TBool deleted( EFalse );
       
   405     TCalenNotification notification = ECalenNotifyDeleteFailed;
       
   406     
       
   407     // Make sure we're focused on an entry.
       
   408     if( iGlobalData->Context().InstanceId().iEntryLocalUid )
       
   409         {
       
   410         //If todo, use the LUid.
       
   411         //Todos returns the current time if start or end time has not been saved.
       
   412         if( CCalEntry::ETodo == iGlobalData->Context().InstanceId().iType )
       
   413             {
       
   414             CCalEntry* entry = iGlobalData->EntryViewL(iGlobalData->Context().InstanceId().iColId)->FetchL(
       
   415                                     iGlobalData->Context().InstanceId().iEntryLocalUid );
       
   416 
       
   417             if( entry )
       
   418                 {
       
   419                 CleanupStack::PushL( entry );
       
   420                 deleted = DeleteEntryL( iGlobalData->EntryViewL(iGlobalData->Context().InstanceId().iColId), entry );
       
   421 
       
   422                 if( deleted )
       
   423                     {
       
   424                     CleanupStack::Pop( entry );
       
   425                     notification = ECalenNotifyEntryDeleted;
       
   426                     }
       
   427                 else
       
   428                     {
       
   429                     CleanupStack::PopAndDestroy( entry );
       
   430                     }
       
   431                 }
       
   432             }
       
   433         else // Not todo
       
   434             {
       
   435             RArray<TInt> colIdArray;
       
   436             colIdArray.AppendL(iGlobalData->Context().InstanceId().iColId);
       
   437                 
       
   438             CCalInstance* instance = CalenActionUiUtils::FindPossibleInstanceL( 
       
   439                                                             iGlobalData->Context().InstanceId(),
       
   440                                                             *iGlobalData->InstanceViewL(colIdArray) );
       
   441             // if we have instance we will do delete other wise just return
       
   442             if( instance )
       
   443                 {
       
   444                 // Note: ownership handling of instance is dirty in this case, 
       
   445                 // because DeleteSingleInstanceLtakes ownership, if it's deletes 
       
   446                 // instance (property of CalInterimApi), otherwise not.
       
   447                 CleanupStack::PushL( instance );
       
   448                 deleted = DeleteSingleInstanceL( instance );
       
   449 
       
   450                 if( deleted )
       
   451                     {
       
   452                     CleanupStack::Pop( instance );
       
   453                     notification = ECalenNotifyEntryDeleted;
       
   454                     }
       
   455                 else
       
   456                     {
       
   457                     CleanupStack::PopAndDestroy( instance );
       
   458                     }
       
   459                 }
       
   460             colIdArray.Reset();
       
   461             }
       
   462         }
       
   463     else
       
   464         {
       
   465          TBool doDelete( ETrue );
       
   466          
       
   467          doDelete = CalenActionUiUtils::ShowDeleteConfirmationQueryL( 
       
   468                                                                    iGlobalData->Context().InstanceId().iType == CCalEntry::ETodo ?
       
   469                                                                    CalenActionUiUtils::EDeleteToDo :
       
   470                                                                    CalenActionUiUtils::EDeleteEntry );
       
   471 		if ( doDelete )
       
   472 			{
       
   473 			notification = ECalenNotifyEntryDeleted;	
       
   474 			}
       
   475         }
       
   476         
       
   477     iController.BroadcastNotification( notification );
       
   478 
       
   479     TRACE_EXIT_POINT;
       
   480     }
       
   481 
       
   482 // ----------------------------------------------------------------------------
       
   483 // CCalenDeleteUi::DeleteAllEntriesL
       
   484 // Deletes all entries
       
   485 // (other items were commented in a header).
       
   486 // ----------------------------------------------------------------------------
       
   487 //
       
   488 void CCalenDeleteUi::DeleteAllEntriesL()
       
   489     {
       
   490     TRACE_ENTRY_POINT;
       
   491 
       
   492     ASSERT( !iIsDeleting );
       
   493 
       
   494     const TInt buttonId = CalenActionUiUtils::ShowDeleteConfirmationQueryL( 
       
   495                                            CalenActionUiUtils::EDeleteAll );
       
   496 
       
   497     if( buttonId )
       
   498         {
       
   499         HandleDeleteMultipleEventsL( TCalTime::MinTime(), TCalTime::MaxTime(),
       
   500                                  R_QTN_CALE_CONF_ALL_NOTES_DELETED );
       
   501         }
       
   502     else
       
   503         {
       
   504         // notify delete failed
       
   505         iController.BroadcastNotification(ECalenNotifyDeleteFailed); 
       
   506         }
       
   507 
       
   508     TRACE_EXIT_POINT;
       
   509     }
       
   510 
       
   511 // ----------------------------------------------------------------------------
       
   512 // CCalenDeleteUi::DeleteEntriesBeforeDateL
       
   513 // Deletes all entries before a set date.
       
   514 // (other items were commented in a header).
       
   515 // ----------------------------------------------------------------------------
       
   516 //
       
   517 void CCalenDeleteUi::DeleteEntriesBeforeDateL()
       
   518     {
       
   519     TRACE_ENTRY_POINT;
       
   520 
       
   521     ASSERT( !iIsDeleting );
       
   522     TTime date;
       
   523     date.HomeTime();
       
   524     TTime today = date;
       
   525 
       
   526     TBool execute( EFalse );
       
   527     TBool exit( ETrue );
       
   528     do{
       
   529         exit = ETrue;
       
   530         execute = EFalse;
       
   531 
       
   532         TInt buttonId = CalenActionUiUtils::DateQueryL(date, R_CALEN_DEL_BEFORE_DATE_PROMPT);
       
   533 
       
   534         if( buttonId == EAknSoftkeyOk || buttonId == EEikBidOk )
       
   535             {
       
   536             execute = ETrue;
       
   537             if( today < date )
       
   538                 {
       
   539                 CAknNoteDialog* dialog = new( ELeave ) CAknNoteDialog( 
       
   540                                                             CAknNoteDialog::EConfirmationTone,
       
   541                                                             CAknNoteDialog::ELongTimeout );
       
   542                 dialog->ExecuteLD( R_CALEN_DELETEERROR_NOTE );
       
   543                 execute = EFalse;
       
   544                 exit = EFalse;
       
   545                 }
       
   546             }
       
   547         }while( !exit );
       
   548 
       
   549     // Do delete only if inputted day is after beginning of range
       
   550     if( execute && date > TCalTime::MinTime() )
       
   551         {
       
   552         // Two pass delete:
       
   553         // 1. pass
       
   554         // To prevent destroying entries starting and ending midnight
       
   555         // subtract one microsecond and do delete on that range.
       
   556         date -= TTimeIntervalMicroSeconds32( 1 );
       
   557         date = Max( date, TCalTime::MinTime() );
       
   558 
       
   559         HandleDeleteMultipleEventsL( TCalTime::MinTime(),
       
   560                                                 date,
       
   561                                                R_QTN_CALE_CONF_PAST_NOTE_DELETED );
       
   562         }
       
   563     else
       
   564         {
       
   565         iController.BroadcastNotification( ECalenNotifyDeleteFailed );
       
   566         }
       
   567     
       
   568     TRACE_EXIT_POINT;
       
   569     }
       
   570 
       
   571 // ----------------------------------------------------------------------------
       
   572 // CCalenDeleteUi::HandleDeleteMultipleEventsL
       
   573 // Handles multiple delete events
       
   574 // (other items were commented in a header).
       
   575 // ----------------------------------------------------------------------------
       
   576 //
       
   577 void CCalenDeleteUi::HandleDeleteMultipleEventsL( const TTime& aFirstDay,
       
   578                                                                      const TTime& aLastDay,
       
   579                                                                      TInt aConfNoteId )
       
   580     {
       
   581     TRACE_ENTRY_POINT;
       
   582 
       
   583     ASSERT( !iWaitDialog );
       
   584     ASSERT( !iIsDeleting );
       
   585     iConfirmationNoteId = aConfNoteId;
       
   586 
       
   587     iWaitDialog = new( ELeave ) CAknWaitDialog( REINTERPRET_CAST( CEikDialog**, 
       
   588                                                                   &iWaitDialog ) );
       
   589     iWaitDialog->ExecuteLD( R_CALEN_DELETE_WAIT_NOTE );
       
   590 
       
   591     DeleteDayRangeL( aFirstDay, aLastDay );
       
   592 
       
   593     TRACE_EXIT_POINT;
       
   594     }
       
   595 
       
   596 // ----------------------------------------------------------------------------
       
   597 // CCalenDeleteUi::DeleteDayRangeL
       
   598 // Deletes all entries in a given range.
       
   599 // (other items were commented in a header).
       
   600 // ----------------------------------------------------------------------------
       
   601 //
       
   602 void CCalenDeleteUi::DeleteDayRangeL( const TTime& aStart,
       
   603                                                       const TTime& aEnd )
       
   604     {
       
   605     TRACE_ENTRY_POINT;
       
   606 
       
   607     iStartTime = aStart;
       
   608     iEndTime = aEnd;
       
   609 
       
   610     TCalTime start, end;
       
   611     start.SetTimeLocalL( iStartTime );
       
   612     end.SetTimeLocalL( iEndTime );
       
   613 
       
   614     if( iDelAllRange )
       
   615         {
       
   616         delete iDelAllRange;
       
   617         iDelAllRange = NULL;
       
   618         }
       
   619     
       
   620     iDelAllRange = new(ELeave) CalCommon::TCalTimeRange( start, end );
       
   621     iDeleteColIds.Reset();
       
   622 
       
   623     iIsDeleting = ETrue;   
       
   624 
       
   625     iController.GetActiveCollectionidsL(iDeleteColIds);
       
   626     
       
   627     //remember the calenders, delete entries in each calendar one by one by calling DeleteL(...) after completed()
       
   628     iNumberOfCalendars = iDeleteColIds.Count();
       
   629     iToShowDeleteNote = 0;
       
   630     iGlobalData->EntryViewL(iDeleteColIds[iToShowDeleteNote])->DeleteL( *iDelAllRange, CalCommon::EIncludeAll, *this );
       
   631         
       
   632     TRACE_EXIT_POINT;
       
   633     }
       
   634 
       
   635 // ----------------------------------------------------------------------------
       
   636 // CCalenDeleteUi::Completed
       
   637 // Completed callback
       
   638 // (other items were commented in a header).
       
   639 // ----------------------------------------------------------------------------
       
   640 //
       
   641 void CCalenDeleteUi::Completed( TInt aFirstPassError )
       
   642     {
       
   643     TRACE_ENTRY_POINT;
       
   644 
       
   645     PIM_TRAPD_HANDLE( DoCompletedL( aFirstPassError ) );
       
   646 
       
   647     TRACE_EXIT_POINT;
       
   648     }
       
   649 
       
   650 // ----------------------------------------------------------------------------
       
   651 // CCalenDeleteUi::DoCompletedL
       
   652 // Handles delete callback
       
   653 // (other items were commented in a header).
       
   654 // ----------------------------------------------------------------------------
       
   655 //
       
   656 void CCalenDeleteUi::DoCompletedL( TInt aFirstPassError )
       
   657     {
       
   658     TRACE_ENTRY_POINT;
       
   659     iToShowDeleteNote++;
       
   660     if(iNumberOfCalendars == iToShowDeleteNote)
       
   661         {
       
   662 	    if( aFirstPassError == KErrNone )
       
   663 	        {
       
   664 	        // 2: Second pass, delete notes that end 00:00 of next day of iEndTime
       
   665 	        // We didn't delete them in first pass
       
   666 	        TTime nextMidnight = CalenDateUtils::BeginningOfDay( iEndTime + TTimeIntervalDays( 1 ) );
       
   667 	        nextMidnight = Min( nextMidnight, TCalTime::MaxTime() );
       
   668 	        PIM_TRAPD_HANDLE( DeleteEntriesEndingAtMidnightL( nextMidnight ) );
       
   669 	        }
       
   670 	        
       
   671 		// 3. End deleting, close wait dialog, and show confirmation or error note
       
   672 		iIsDeleting = EFalse;
       
   673 		iToShowDeleteNote = 0;
       
   674 		// dismiss the waitdialog
       
   675 		if(iWaitDialog)
       
   676 			{
       
   677 			TRAP_IGNORE(iWaitDialog->ProcessFinishedL());
       
   678 			}
       
   679 
       
   680 		if( aFirstPassError == KErrNone )
       
   681 			{
       
   682 			// Show confirmation note
       
   683 			HBufC* buf = StringLoader::LoadLC( iConfirmationNoteId, iEikEnv );
       
   684 			CAknConfirmationNote* dialog = new( ELeave ) CAknConfirmationNote();
       
   685 			dialog->ExecuteLD(*buf);
       
   686 			CleanupStack::PopAndDestroy( buf );
       
   687 			}
       
   688 		else
       
   689 			{
       
   690 			// Show error note
       
   691 			if(iEikEnv)
       
   692 			   {
       
   693 			   iEikEnv->ResolveError( aFirstPassError );
       
   694 			   }
       
   695 			}
       
   696 		iDeleteColIds.Reset();
       
   697 		delete iDelAllRange;
       
   698 		iDelAllRange = NULL;
       
   699 		
       
   700 	    iController.BroadcastNotification( ECalenNotifyMultipleEntriesDeleted );
       
   701         }
       
   702     else
       
   703         {
       
   704         //delete entries in next calendar...
       
   705         iGlobalData->EntryViewL(iDeleteColIds[iToShowDeleteNote])->DeleteL( *iDelAllRange, CalCommon::EIncludeAll, *this );
       
   706         }
       
   707 
       
   708     TRACE_EXIT_POINT;
       
   709     }
       
   710 
       
   711 // ----------------------------------------------------------------------------
       
   712 // CCalenDeleteUi::NotifyProgress
       
   713 // Delete progress notification
       
   714 // (other items were commented in a header).
       
   715 // ----------------------------------------------------------------------------
       
   716 //
       
   717 TBool CCalenDeleteUi::NotifyProgress()
       
   718     {
       
   719     TRACE_ENTRY_POINT;
       
   720     // Tell framework that we are not intrested in Progress notifications.
       
   721     TRACE_EXIT_POINT;
       
   722     return EFalse;
       
   723     }
       
   724 
       
   725 // ----------------------------------------------------------------------------
       
   726 // CCalenDeleteUi::Progress
       
   727 // Delete progress notification
       
   728 // (other items were commented in a header).
       
   729 // ----------------------------------------------------------------------------
       
   730 //
       
   731 void CCalenDeleteUi::Progress( TInt /*aPercentageCompleted*/ )
       
   732     {
       
   733     TRACE_ENTRY_POINT;
       
   734     // do nothing, we are not intrested in Progress notifications
       
   735     TRACE_EXIT_POINT;
       
   736     }
       
   737 
       
   738 // ----------------------------------------------------------------------------
       
   739 // CCalenDeleteUi::DeleteEntriesEndingAtMidnightL
       
   740 // Deletes entries ending at midnight on the given day
       
   741 // (other items were commented in a header).
       
   742 // ----------------------------------------------------------------------------
       
   743 //
       
   744 void CCalenDeleteUi::DeleteEntriesEndingAtMidnightL( TTime aMidnight )
       
   745     {
       
   746     TRACE_ENTRY_POINT;
       
   747 
       
   748     TCalTime start, end;
       
   749     start.SetTimeLocalL( aMidnight - TTimeIntervalMinutes(1) );
       
   750     end.SetTimeLocalL( aMidnight );
       
   751     CalCommon::TCalTimeRange midnightRange( start, end );
       
   752     
       
   753     RArray<TInt> colIdArray;
       
   754     iController.GetActiveCollectionidsL(colIdArray);
       
   755     
       
   756     // 1: Find instances falling on midnight moment
       
   757     RPointerArray< CCalInstance > instances;
       
   758     CleanupResetAndDestroyPushL( instances );
       
   759     iGlobalData->InstanceViewL(colIdArray)->FindInstanceL( instances,
       
   760                                                  CalCommon::EIncludeAll, 
       
   761                                                  midnightRange );
       
   762     
       
   763     colIdArray.Reset();
       
   764 
       
   765     // 2. loop through them and delete those entries that end at midnight
       
   766     for( TInt i=0; i < instances.Count(); ++i )
       
   767         {
       
   768         CCalInstance* item = instances[i];
       
   769         RArray<TInt> colIdArray;
       
   770         colIdArray.AppendL(item->InstanceIdL().iCollectionId);
       
   771         
       
   772         // Checking that if entry ends at midnight, is quite clumsy, but here goes:
       
   773         // EndsAtStartOfDay takes only CCalInstance, but here we mimic EndsAtStartOfDay
       
   774         // for CCalEntry type.
       
   775 
       
   776         // First check that if _instance_ ends at midnight, but starts earlier
       
   777         if( CalenAgendaUtils::EndsAtStartOfDayL( item, aMidnight ) )
       
   778             {
       
   779             // Second, check that _entry's_ endtime is exactly the midnight
       
   780             // This prevents us from destroying repeating entries, that has one
       
   781             // instance falling on given midnight.
       
   782             if( item->Entry().EndTimeL().TimeLocalL() == aMidnight )
       
   783                 {
       
   784                 iGlobalData->InstanceViewL(colIdArray)->DeleteL( item, CalCommon::EThisOnly );
       
   785                 // Ownership was transferred to DeleteL.
       
   786                 // Put null to array to prevent double-deletion
       
   787                 instances[i] = NULL;                
       
   788                 }
       
   789             }
       
   790         colIdArray.Reset();
       
   791         }
       
   792     CleanupStack::PopAndDestroy( &instances );
       
   793 
       
   794     TRACE_EXIT_POINT;
       
   795     }
       
   796 
       
   797 // -----------------------------------------------------------------------------
       
   798 // CCalenDeleteUi::DeleteSingleInstanceL
       
   799 // Delete the given instance. Ask the user whether to delete the series or the instance.
       
   800 // (other items were commented in a header).
       
   801 // -----------------------------------------------------------------------------
       
   802 //
       
   803 TBool CCalenDeleteUi::DeleteSingleInstanceL( CCalInstance* aInstance )
       
   804     {
       
   805     TRACE_ENTRY_POINT;
       
   806     TRACE_EXIT_POINT;
       
   807     return DoDeleteSingleInstanceL( aInstance, EFalse, CalCommon::EThisAndAll );
       
   808     }
       
   809 
       
   810 // -----------------------------------------------------------------------------
       
   811 // CCalenDeleteUi::DeleteSingleInstanceL
       
   812 // Delete the given instance. Delete the entry range given by aRepeatType.
       
   813 // (other items were commented in a header).
       
   814 // -----------------------------------------------------------------------------
       
   815 //
       
   816 TBool CCalenDeleteUi::DeleteSingleInstanceL( CCalInstance* aInstance, 
       
   817                                                             CalCommon::TRecurrenceRange aRepeatType )
       
   818     {
       
   819     TRACE_ENTRY_POINT;
       
   820     TRACE_EXIT_POINT;
       
   821     return DoDeleteSingleInstanceL( aInstance, ETrue, aRepeatType );
       
   822     }
       
   823 
       
   824 // -----------------------------------------------------------------------------
       
   825 // CCalenDeleteUi::DoDeleteSingleInstanceL
       
   826 // Performs the deletion of the instance. If aHasRepeatType is EFalse, the user
       
   827 // is prompted to delete either the instance or the entire series. In this case,
       
   828 // aRepeatType is ignored. If aHasRepeatType is ETrue, aRepeatType determines
       
   829 // whether to delete the instance or the entire series.
       
   830 // (other items were commented in a header).
       
   831 // -----------------------------------------------------------------------------
       
   832 //
       
   833 TBool CCalenDeleteUi::DoDeleteSingleInstanceL( CCalInstance* aInstance,
       
   834                                                            TBool aHasRepeatType,
       
   835                                                            CalCommon::TRecurrenceRange aRepeatType )
       
   836     {
       
   837     TRACE_ENTRY_POINT;
       
   838 
       
   839     CCalEntry& entry = aInstance->Entry();
       
   840     const CCalEntry::TType entryType = entry.EntryTypeL(); 
       
   841     RArray<TInt> colIdArray;
       
   842     colIdArray.AppendL(aInstance->InstanceIdL().iCollectionId);
       
   843     
       
   844 
       
   845     TCalRRule rrule;
       
   846 
       
   847     TBool repeating = entry.GetRRuleL( rrule );
       
   848 
       
   849     if( !repeating )
       
   850         {
       
   851         // Even though there is no RRule, the entry might
       
   852         // have a list of rdates.
       
   853         RArray< TCalTime > rDateArray;
       
   854         CleanupClosePushL( rDateArray );
       
   855         entry.GetRDatesL( rDateArray );
       
   856         repeating = ( rDateArray.Count() > 0 );
       
   857         CleanupStack::PopAndDestroy(); // rDateArray
       
   858         }
       
   859 
       
   860     const TBool child = entry.RecurrenceIdL().TimeUtcL() != Time::NullTTime();
       
   861 
       
   862     if( !aHasRepeatType )
       
   863         {
       
   864         aRepeatType = CalCommon::EThisAndAll;
       
   865         }
       
   866 
       
   867     TBool doDelete( ETrue );
       
   868 
       
   869     if( !aHasRepeatType && ( child || repeating ) && ( entryType != CCalEntry::EAnniv ) )
       
   870         {
       
   871         doDelete = CalenActionUiUtils::ShowRepeatTypeQueryL( aRepeatType,
       
   872                                                            CalenActionUiUtils::EDelete );
       
   873         }
       
   874     else
       
   875         {
       
   876         doDelete = CalenActionUiUtils::ShowDeleteConfirmationQueryL( 
       
   877                                                                    entryType == CCalEntry::ETodo ?
       
   878                                                                    CalenActionUiUtils::EDeleteToDo :
       
   879                                                                    CalenActionUiUtils::EDeleteEntry );
       
   880         }
       
   881         
       
   882     if( doDelete )
       
   883         {
       
   884         if( !TryDeleteWithMrUtilsL( aInstance, aRepeatType ) )
       
   885             {
       
   886             if( !child || aRepeatType == CalCommon::EThisOnly )
       
   887                 {
       
   888                 iGlobalData->InstanceViewL(colIdArray)->DeleteL( aInstance, aRepeatType );
       
   889                 }
       
   890             else if( aRepeatType == CalCommon::EThisAndAll )
       
   891                 {
       
   892                 // Unfortunately we can't pass the existing child instance through to the
       
   893                 // InstanceView DeleteL function because even if we pass in EThisAndAll, it
       
   894                 // only ever deletes the exception. We'll have to fetch the parent then
       
   895                 // delete it via the entry view.
       
   896                 RPointerArray<CCalEntry> entries;
       
   897                 CleanupResetAndDestroyPushL( entries );
       
   898                 iGlobalData->EntryViewL(aInstance->InstanceIdL().iCollectionId)->FetchL( aInstance->Entry().UidL(), entries );
       
   899                 iGlobalData->EntryViewL(aInstance->InstanceIdL().iCollectionId)->DeleteL( *entries[0] );
       
   900                 CleanupStack::PopAndDestroy( &entries );
       
   901                 if( aInstance )
       
   902                     {
       
   903                     delete aInstance;
       
   904                     aInstance = NULL;
       
   905                     }
       
   906                 }
       
   907             else
       
   908                 {
       
   909                 User::Leave( KErrNotSupported );
       
   910                 }
       
   911             }
       
   912         }
       
   913 
       
   914     colIdArray.Reset();
       
   915     TRACE_EXIT_POINT;
       
   916     return doDelete;
       
   917     }
       
   918 
       
   919 // -----------------------------------------------------------------------------
       
   920 // CCalenDeleteUi::DeleteEntryL
       
   921 // Deletes an entry from the database
       
   922 // (other items were commented in a header).
       
   923 // -----------------------------------------------------------------------------
       
   924 //
       
   925 TBool CCalenDeleteUi::DeleteEntryL( CCalEntryView* aEntryView, CCalEntry* aEntry )
       
   926     {
       
   927     TRACE_ENTRY_POINT;
       
   928     const CCalEntry::TType entryType = aEntry->EntryTypeL();
       
   929 
       
   930     TBool doDelete = CalenActionUiUtils::ShowDeleteConfirmationQueryL( 
       
   931                                                                     entryType == CCalEntry::ETodo ?
       
   932                                                                     CalenActionUiUtils::EDeleteToDo :
       
   933                                                                     CalenActionUiUtils::EDeleteEntry );
       
   934     if( doDelete )
       
   935         {
       
   936         aEntryView->DeleteL( *aEntry );
       
   937 
       
   938         if( aEntry )
       
   939             {
       
   940             delete aEntry;
       
   941             aEntry = NULL;
       
   942             }
       
   943         }
       
   944 
       
   945     TRACE_EXIT_POINT;
       
   946     return doDelete;
       
   947     }
       
   948 
       
   949 // -----------------------------------------------------------------------------
       
   950 // CCalenDeleteUi::TryDeleteWithMrUtilsL
       
   951 // Attempt to delete the instance using the Meeting Request utilities,
       
   952 // if MR viewers is enabled.
       
   953 // (other items were commented in a header).
       
   954 // -----------------------------------------------------------------------------
       
   955 //
       
   956 TBool CCalenDeleteUi::TryDeleteWithMrUtilsL( CCalInstance* aInstance, 
       
   957                                                               CalCommon::TRecurrenceRange aRepeatType )
       
   958     {
       
   959     TRACE_ENTRY_POINT;
       
   960     
       
   961     TBool doDelete = ETrue;
       
   962 
       
   963 	if( iGlobalData->InterimUtilsL().MRViewersEnabledL() && 
       
   964         iGlobalData->InterimUtilsL().IsMeetingRequestL(aInstance->Entry()))
       
   965 
       
   966         {
       
   967         CMRMailboxUtils::TMailboxInfo info;
       
   968         if( iGlobalData->AttemptToRetrieveDefaultMailboxL( info ) )
       
   969             {
       
   970             if(aRepeatType == CalCommon::EThisAndAll )
       
   971                 {
       
   972                 iGlobalData->MeetingRequestUtilsL().DeleteWithUiL( aInstance->Entry(),
       
   973                                                                                       info.iEntryId );
       
   974                 if( aInstance )
       
   975                     {
       
   976                     delete aInstance;
       
   977                     aInstance = NULL;
       
   978                     }
       
   979                 }
       
   980             else if( aRepeatType == CalCommon::EThisOnly )
       
   981                 {
       
   982                 iGlobalData->MeetingRequestUtilsL().DeleteWithUiL( aInstance, info.iEntryId );
       
   983                 }
       
   984             else
       
   985                 {
       
   986                 User::Leave( KErrNotSupported );
       
   987                 }
       
   988             }
       
   989         else
       
   990             {
       
   991             doDelete = EFalse;
       
   992             }
       
   993         }
       
   994     else
       
   995         {
       
   996         doDelete = EFalse;
       
   997         }
       
   998 
       
   999     TRACE_EXIT_POINT;
       
  1000     return doDelete;
       
  1001     }
       
  1002 
       
  1003 // -----------------------------------------------------------------------------
       
  1004 // CCalenDeleteUi::ShowMultipleEntriesDeleteQueryL
       
  1005 // For displaying multiple entries deletion confirmation query
       
  1006 // -----------------------------------------------------------------------------
       
  1007 //
       
  1008 TInt CCalenDeleteUi::ShowMultipleEntriesDeleteQueryL(TInt aCount)
       
  1009 	{
       
  1010     TRACE_ENTRY_POINT;
       
  1011 
       
  1012     CAknQueryDialog *dialog = CAknQueryDialog::NewL( );
       
  1013     CleanupStack::PushL( dialog );
       
  1014     TInt resID;
       
  1015     HBufC* prompt;
       
  1016     if( aCount > 1 )
       
  1017         {
       
  1018         resID = R_CALEN_QTN_TODO_QUEST_DELETE_MARKED_NOTES;
       
  1019         prompt = StringLoader::LoadLC( resID, aCount );
       
  1020         }
       
  1021     else if( aCount ==  1 )
       
  1022         {
       
  1023         resID = R_CALEN_QTN_TODO_QUEST_DELETE_MARKED_NOTE;
       
  1024         prompt = StringLoader::LoadLC( resID );
       
  1025         }
       
  1026     else
       
  1027         {
       
  1028         CleanupStack::PopAndDestroy( dialog );
       
  1029         TRACE_EXIT_POINT;
       
  1030         return 0;   //return 0 for other invalid aCount value ( < 0 )
       
  1031         }
       
  1032     dialog->SetPromptL( *prompt );
       
  1033     CleanupStack::PopAndDestroy( prompt );
       
  1034 
       
  1035     CleanupStack::Pop( dialog );
       
  1036 
       
  1037     TRACE_EXIT_POINT;
       
  1038     return dialog->ExecuteLD( R_CALEN_ERASEQUERY_NOTE );
       
  1039 
       
  1040 	}
       
  1041 
       
  1042 // -----------------------------------------------------------------------------
       
  1043 // CCalenDeleteUi::DialogDismissedL
       
  1044 // From MProgressDialogCallback
       
  1045 // Callback method
       
  1046 // called when a dialog is dismissed.
       
  1047 // -----------------------------------------------------------------------------
       
  1048 //
       
  1049 void CCalenDeleteUi::DialogDismissedL( const TInt /*aButtonId*/ )
       
  1050     {
       
  1051     TRACE_ENTRY_POINT;
       
  1052     // dismiss the wait dialog
       
  1053     if(iWaitDialog)
       
  1054         {
       
  1055         iWaitDialog->ProcessFinishedL();
       
  1056         }
       
  1057     
       
  1058     // no more entries to delete
       
  1059     iMoreEntriesToDelete = EFalse;
       
  1060     iDisplayQuery = EFalse;
       
  1061     
       
  1062     // issue notification cancel delete
       
  1063     iController.BroadcastNotification(ECalenNotifyCancelDelete);
       
  1064     TRACE_EXIT_POINT;
       
  1065     }
       
  1066 
       
  1067 // -----------------------------------------------------------------------------
       
  1068 // CCalenDeleteUi::DeleteEntryL
       
  1069 // Delete entry using entry local uid
       
  1070 // -----------------------------------------------------------------------------
       
  1071 //
       
  1072 void CCalenDeleteUi::DeleteEntryL(TCalLocalUid& aEntryLocalUid, TInt aColId)
       
  1073     {
       
  1074     TRACE_ENTRY_POINT;
       
  1075     
       
  1076     // fetch the entry
       
  1077     CCalEntry* entry = iGlobalData->EntryViewL(aColId)->FetchL(aEntryLocalUid);
       
  1078     if( entry )
       
  1079         {
       
  1080         CleanupStack::PushL( entry );
       
  1081         iGlobalData->EntryViewL(aColId)->DeleteL( *entry );
       
  1082         CleanupStack::Pop( entry );
       
  1083         delete entry;
       
  1084         entry = NULL;
       
  1085         }   
       
  1086     
       
  1087     TRACE_EXIT_POINT;
       
  1088     }
       
  1089 
       
  1090 // -----------------------------------------------------------------------------
       
  1091 // CCalenDeleteUi::DisplayWaitDialogL
       
  1092 // Display wait dialog
       
  1093 // -----------------------------------------------------------------------------
       
  1094 //
       
  1095 void CCalenDeleteUi::DisplayWaitDialogL()
       
  1096     {
       
  1097     TRACE_ENTRY_POINT;
       
  1098     
       
  1099     delete iWaitDialog;
       
  1100     iWaitDialog = NULL;
       
  1101     iWaitDialog = new( ELeave )CAknWaitDialog( REINTERPRET_CAST( CEikDialog**, &iWaitDialog ), ETrue );
       
  1102     iWaitDialog->ExecuteLD( R_TODO_VIEW_DELETE_WAIT_NOTE );
       
  1103     iWaitDialog->SetCallback(this);
       
  1104     
       
  1105     TRACE_EXIT_POINT;
       
  1106     }
       
  1107 
       
  1108 // -----------------------------------------------------------------------------
       
  1109 // CCalenDeleteUi::MarkedEntriesDeletedL
       
  1110 // Dismiss wait dialog and show information note
       
  1111 // -----------------------------------------------------------------------------
       
  1112 //
       
  1113 void CCalenDeleteUi::MarkedEntriesDeletedL()
       
  1114     {
       
  1115     TRACE_ENTRY_POINT;
       
  1116     
       
  1117     // dismiss the waitdialog
       
  1118     if(iWaitDialog)
       
  1119         {
       
  1120         iWaitDialog->ProcessFinishedL();
       
  1121         }
       
  1122     
       
  1123     // Show confirmation note
       
  1124     //HBufC* buf = StringLoader::LoadLC( R_QTN_CALE_CONF_ALL_NOTES_DELETED, iEikEnv );
       
  1125     //CAknConfirmationNote* dialog = new( ELeave ) CAknConfirmationNote();
       
  1126     //dialog->ExecuteLD(*buf);
       
  1127     //CleanupStack::PopAndDestroy( buf );
       
  1128 
       
  1129     // notify marked entries deleted
       
  1130     iController.BroadcastNotification( ECalenNotifyMarkedEntryDeleted );
       
  1131     
       
  1132     TRACE_EXIT_POINT;
       
  1133     }
       
  1134 
       
  1135 // -----------------------------------------------------------------------------
       
  1136 // CCalenDeleteUi::HandleDeleteAllEntriesL
       
  1137 // Handles launching of the delete all entries list query
       
  1138 // -----------------------------------------------------------------------------
       
  1139 //
       
  1140 void CCalenDeleteUi::HandleDeleteAllEntriesL()
       
  1141     {
       
  1142     TRACE_ENTRY_POINT;
       
  1143     RPointerArray<CCalCalendarInfo> calendarInfoList;
       
  1144     CleanupClosePushL(calendarInfoList);
       
  1145 	iController.Services().GetAllCalendarInfoL(calendarInfoList);
       
  1146     TInt visibleCalendarsCount(0);
       
  1147     for(TInt index=0;index<calendarInfoList.Count();index++)
       
  1148         {
       
  1149         if(calendarInfoList[index]->Enabled())
       
  1150             {
       
  1151             visibleCalendarsCount++;
       
  1152             }
       
  1153         if(visibleCalendarsCount>1)
       
  1154             {
       
  1155             break;
       
  1156             }
       
  1157         }
       
  1158     CleanupStack::PopAndDestroy();
       
  1159     
       
  1160     TInt headingTextResourceId(0);
       
  1161     if(visibleCalendarsCount==1)
       
  1162         {
       
  1163         headingTextResourceId = R_CALE_SINGLE_CALENDAR_DELETE_ENTRIES;
       
  1164         }
       
  1165     else
       
  1166         {
       
  1167         headingTextResourceId = R_CALE_MULTI_CALENDAR_DELETE_ENTRIES;
       
  1168         }
       
  1169 
       
  1170     TInt selectedIndex(0);
       
  1171     CAknListQueryDialog* deleteEntriesListDialog = new(ELeave) CAknListQueryDialog(&selectedIndex);
       
  1172     deleteEntriesListDialog->PrepareLC(R_DELETE_ENTRIES_LIST_QUERY);
       
  1173     HBufC* buf = StringLoader::LoadLC( headingTextResourceId, iEikEnv );
       
  1174     deleteEntriesListDialog->QueryHeading()->SetTextL(buf->Des());
       
  1175     CleanupStack::PopAndDestroy( buf );
       
  1176     
       
  1177     if(deleteEntriesListDialog->RunLD())
       
  1178         {
       
  1179         if(selectedIndex)
       
  1180             {
       
  1181             DeleteAllEntriesL();
       
  1182             }
       
  1183         else
       
  1184             {
       
  1185             DeleteEntriesBeforeDateL();
       
  1186             }
       
  1187         }
       
  1188     else
       
  1189         {
       
  1190         iController.BroadcastNotification(ECalenNotifyDeleteFailed);
       
  1191         }
       
  1192     
       
  1193     TRACE_EXIT_POINT
       
  1194     }
       
  1195 	
       
  1196 // End of File