calendarui/views/src/caleneventview.cpp
branchRCL_3
changeset 30 bd7edf625bdd
child 31 97232defd20e
equal deleted inserted replaced
29:12af337248b1 30:bd7edf625bdd
       
     1 /*
       
     2 * Copyright (c) 2008 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:   Event View implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // system includes
       
    21 #include <StringLoader.h>
       
    22 #include <Calendar.rsg>
       
    23 #include <aknbutton.h>
       
    24 #include <akntoolbar.h>
       
    25 #include <calencommands.hrh>            // Calendar commands
       
    26 #include <calencontext.h>
       
    27 #include <CalenStatusPaneUtils.h>
       
    28 #include <calcalendarinfo.h>
       
    29 #include <caleninstanceid.h>
       
    30 
       
    31 // user includes
       
    32 #include "caleneventview.h"
       
    33 #include "calendarui_debug.h"
       
    34 #include "caleneventviewcontainer.h"
       
    35 #include <calenview.h>
       
    36 #include "CalenUid.h"
       
    37 #include "calenlocationutil.h"
       
    38 #include "calenentryutil.h"
       
    39 #include "calendar.hrh"
       
    40 #include <finditem.hrh>
       
    41 #include <finditemmenu.h>
       
    42 #include "calenattachmentmodel.h" 
       
    43 
       
    44 #include <aknappui.h>
       
    45 // Button position of the MSK CBA button
       
    46 const TInt KSK2CBAPosition = 2;
       
    47 
       
    48 // ================= MEMBER FUNCTIONS =========================================
       
    49 
       
    50 // ----------------------------------------------------------------------------
       
    51 // CCalenEventView::NewL
       
    52 // Two-phased constructor.
       
    53 // ----------------------------------------------------------------------------
       
    54 //
       
    55 EXPORT_C CCalenEventView* CCalenEventView::NewL( MCalenServices& aServices )
       
    56 	{
       
    57 	TRACE_ENTRY_POINT;
       
    58 	
       
    59 	CCalenEventView* self = new( ELeave )CCalenEventView( aServices );
       
    60     CleanupStack::PushL( self );
       
    61     self->ConstructL();
       
    62     CleanupStack::Pop( self );
       
    63 
       
    64     TRACE_EXIT_POINT;
       
    65     return self;
       
    66 	}
       
    67 
       
    68 // ----------------------------------------------------------------------------
       
    69 // CCalenEventView::ConstructL
       
    70 // Constructor
       
    71 // ----------------------------------------------------------------------------
       
    72 //
       
    73 void CCalenEventView::ConstructL()
       
    74 	{
       
    75 	TRACE_ENTRY_POINT;
       
    76 	
       
    77 	CommonConstructL( R_CALEN_EVENT_VIEW );
       
    78 	
       
    79 	TRACE_EXIT_POINT;
       
    80 	}
       
    81 
       
    82 // ----------------------------------------------------------------------------
       
    83 // CCalenEventView::CCalenEventView
       
    84 // C++ constructor.
       
    85 // ----------------------------------------------------------------------------
       
    86 //
       
    87 CCalenEventView::CCalenEventView( MCalenServices& aServices )
       
    88     : CCalenNativeView( aServices ),
       
    89     iPopulationStep( ENothingDone )
       
    90     {
       
    91 	TRACE_ENTRY_POINT;
       
    92 	TRACE_EXIT_POINT;
       
    93     }
       
    94  
       
    95 // ----------------------------------------------------------------------------
       
    96 // CCalenEventView::~CCalenEventView
       
    97 // Destructor
       
    98 // ----------------------------------------------------------------------------
       
    99 //
       
   100 CCalenEventView::~CCalenEventView()
       
   101 	{
       
   102 	TRACE_ENTRY_POINT;
       
   103 	TRACE_EXIT_POINT;
       
   104 	}
       
   105 
       
   106 // ----------------------------------------------------------------------------
       
   107 // CCalenEventView::ActiveStepL
       
   108 // From CCalenView
       
   109 // (other items were commented in a header)
       
   110 // ----------------------------------------------------------------------------
       
   111 //
       
   112 CCalenView::TNextPopulationStep CCalenEventView::ActiveStepL()
       
   113     {
       
   114     TRACE_ENTRY_POINT;
       
   115 	
       
   116 	CCalenView::TNextPopulationStep nextStep = CCalenView::EDone;
       
   117 	CCalenEventViewContainer* cnt = static_cast<CCalenEventViewContainer*>( iContainer );
       
   118 	
       
   119     switch( iPopulationStep )
       
   120         {
       
   121         case ENothingDone:
       
   122         	{
       
   123 			iPopulationStep = ERequestInstanceView;
       
   124 			nextStep = CCalenView::EKeepGoing;
       
   125         	}
       
   126         	break;
       
   127         case ERequestInstanceView:
       
   128             {
       
   129             TInt err = cnt->RequestInstanceViewL();
       
   130             if(err != KErrNotFound)
       
   131                 {
       
   132 				iPopulationStep = EBuildTextEditor;
       
   133             	nextStep = CCalenView::EKeepGoing;                
       
   134                 }
       
   135 			else
       
   136 				{
       
   137 				// the intended cal entry is not found in the database.
       
   138                 // it has been deleted by some other app or by synching from server.
       
   139 				nextStep = CCalenView::EDone;
       
   140 				}
       
   141 
       
   142             }
       
   143             break; 	
       
   144         case EBuildTextEditor:
       
   145             {
       
   146             cnt->BuildTextEditorL();
       
   147             iPopulationStep = EAddField;
       
   148             nextStep = CCalenView::EKeepGoing;
       
   149             }
       
   150             break;	
       
   151         case EAddField:
       
   152         	{
       
   153         	cnt->AddFieldsL();
       
   154 			iPopulationStep = EPopulationDone;   
       
   155  			nextStep = CCalenView::EKeepGoing;			     	
       
   156         	}
       
   157         	break;
       
   158         case EPopulationDone: 
       
   159         default:    
       
   160         	{
       
   161         	cnt->CompletePopulationL();
       
   162         	if(!iAvkonAppUi->IsDisplayingMenuOrDialog())
       
   163         	    {
       
   164                 RedrawStatusPaneL();
       
   165                 UpdateToolbarButtonsL();
       
   166         	    }
       
   167         	nextStep = CCalenView::EDone;
       
   168         	}
       
   169         	break;
       
   170         }
       
   171     TRACE_EXIT_POINT;  
       
   172     return nextStep;  
       
   173     }
       
   174 
       
   175 // ----------------------------------------------------------------------------
       
   176 // CCalenEventView::CancelPopulation
       
   177 // From CCalenView
       
   178 // (other items were commented in a header)
       
   179 // ----------------------------------------------------------------------------
       
   180 //
       
   181 void CCalenEventView::CancelPopulation()
       
   182     {
       
   183     TRACE_ENTRY_POINT;
       
   184     
       
   185     iPopulationStep = ENothingDone;
       
   186 
       
   187     TRACE_EXIT_POINT;
       
   188     }
       
   189 
       
   190 // ----------------------------------------------------------------------------
       
   191 // CCalenEventView::LocalisedViewNameL
       
   192 // From CCalenView
       
   193 // (other items were commented in a header)
       
   194 // ----------------------------------------------------------------------------
       
   195 //
       
   196 const TDesC& CCalenEventView::LocalisedViewNameL( CCalenView::TViewName /*aViewName*/ )
       
   197     {
       
   198     TRACE_ENTRY_POINT;
       
   199     TRACE_ENTRY_POINT;
       
   200     
       
   201     _LIT(KEV,"Event View");
       
   202     //HBufC* ret = NULL;
       
   203 
       
   204    /* switch ( aViewName )
       
   205         {
       
   206         case CCalenView::EMenuName:
       
   207             if ( !iMenuName )
       
   208                 {
       
   209                 iMenuName = StringLoader::LoadL( R_CALEN_QTN_EVENT_VIEW, iCoeEnv );
       
   210                 }
       
   211             ret = iMenuName;
       
   212             break;
       
   213         case CCalenView::ESettingsName:
       
   214             if ( !iSettingsName )
       
   215                 {
       
   216                 iSettingsName = StringLoader::LoadL( R_CALEN_QTN_EVENT_VIEW,
       
   217                                                      iCoeEnv );
       
   218                 }
       
   219             ret = iSettingsName;
       
   220             break;
       
   221         default:
       
   222             ASSERT( EFalse );
       
   223             break;
       
   224         }*/
       
   225     TRACE_EXIT_POINT;
       
   226     return KEV;
       
   227     }
       
   228 
       
   229 // ----------------------------------------------------------------------------
       
   230 // CCalenEventView::ViewIcon
       
   231 // From CCalenView
       
   232 // (other items were commented in a header)
       
   233 // ----------------------------------------------------------------------------
       
   234 //
       
   235 CGulIcon* CCalenEventView::ViewIconL() const
       
   236     {
       
   237     TRACE_ENTRY_POINT;
       
   238     TRACE_EXIT_POINT;
       
   239     return NULL;
       
   240     }
       
   241 
       
   242 
       
   243 // ----------------------------------------------------------------------------
       
   244 // CCalenEventView::DoActivateImplL
       
   245 // (other items were commented in a header).
       
   246 // ----------------------------------------------------------------------------
       
   247 //
       
   248 void CCalenEventView::DoActivateImplL( const TVwsViewId& aPrevViewId,
       
   249                                       TUid aCustomMessageId ,
       
   250                                       const TDesC8& /*aCustomMessage */)
       
   251     {
       
   252     TRACE_ENTRY_POINT;
       
   253 	
       
   254     
       
   255     if(aCustomMessageId == KUidCalenShowAlarmCba)
       
   256         {
       
   257         iEventViewCBA = EShowAlarm;
       
   258         }
       
   259 	else if(aCustomMessageId == KUidCalenShowAlarmStopOnlyCba)
       
   260 		{		    	
       
   261 		iEventViewCBA =	EShowAlarmStopOnly;
       
   262 		}
       
   263 	else if(aCustomMessageId == KUidCalenShowCloseCba)
       
   264 		{
       
   265 		iEventViewCBA = EShowClose;	
       
   266 		}
       
   267 	else
       
   268 		{
       
   269 		if( aPrevViewId.iAppUid == KUidCalendar && aPrevViewId.iViewUid != KNullUid)    // switch from internal view
       
   270 	        {
       
   271 	        //Updating RSK CBA button of Event view depending up on from where it is activated
       
   272 	       	iEventViewCBA = EShowBack;	        
       
   273 		    }
       
   274 		}             
       
   275 
       
   276     UpdateCbaL();
       
   277     
       
   278     // Draw event viewer toolbar by adding Edit, Delete and Send buttons
       
   279 	AddToolbarButtonsL();
       
   280 	
       
   281     TRACE_EXIT_POINT;
       
   282     }
       
   283 
       
   284 // ----------------------------------------------------------------------------
       
   285 // CCalenEventView::DoDeactivateImpl
       
   286 // ----------------------------------------------------------------------------
       
   287 //
       
   288 void CCalenEventView::DoDeactivateImpl()
       
   289     {
       
   290     TRACE_ENTRY_POINT;
       
   291     // After forced exit need to Reset CCalenAttachmentModel 
       
   292     //to refresh the model after opening the calender next time
       
   293     if (iServices.GetAttachmentData()->NumberOfItems()) 
       
   294         {
       
   295         iServices.GetAttachmentData()->Reset();
       
   296         }
       
   297     iPreviousViewId.iViewUid = KNullUid;
       
   298     if (!iAvkonAppUi->IsDisplayingMenuOrDialog())
       
   299         {
       
   300         iSPUtils->HideNaviPane();
       
   301         }
       
   302     // Remove the toolbar buttons for event viewer before exiting from event view
       
   303     TRAP_IGNORE(RemoveToolbarButtonsL());
       
   304     
       
   305     TRACE_EXIT_POINT;
       
   306     }
       
   307 
       
   308 // ----------------------------------------------------------------------------
       
   309 // CCalenEventView::OnLocaleChangedL
       
   310 // (other items were commented in a header).
       
   311 // ----------------------------------------------------------------------------
       
   312 //
       
   313 void CCalenEventView::OnLocaleChangedL(TInt aReason)
       
   314     {
       
   315     TRACE_ENTRY_POINT;
       
   316 
       
   317       if(iContainer)
       
   318           {
       
   319           if(IsContainerFocused())
       
   320               {
       
   321               if( (aReason & EChangesLocale) || (aReason & EChangesSystemTime) )
       
   322                   {
       
   323                   CCalenEventViewContainer* cnt = static_cast<CCalenEventViewContainer*>( iContainer );
       
   324                   cnt->HandleLocaleChangedL();
       
   325                   }
       
   326                 }
       
   327           else
       
   328               {
       
   329               iLocChangeReason = EChangesLocale;
       
   330               }
       
   331           }
       
   332      TRACE_EXIT_POINT;
       
   333      }
       
   334     
       
   335 // ----------------------------------------------------------------------------
       
   336 // CCalenEventView::RedrawStatusPaneL
       
   337 // Redraw status pane when Form is closed
       
   338 // (other items were commented in a header)
       
   339 // ----------------------------------------------------------------------------
       
   340 //
       
   341 void CCalenEventView::RedrawStatusPaneL()  
       
   342     {
       
   343     TRACE_ENTRY_POINT;
       
   344 
       
   345     CCalenEventViewContainer* cnt = static_cast<CCalenEventViewContainer*>( iContainer );
       
   346     HBufC* titleText = StringLoader::LoadLC( cnt->GetTitleTextId(), iCoeEnv );
       
   347     iSPUtils->UnderLineTitleText( EFalse );
       
   348     iSPUtils->SetTitleText( titleText );    // ownership passed
       
   349     CleanupStack::Pop( titleText );
       
   350     SetStatusPaneFromActiveContextL();
       
   351     iSPUtils->RefreshStatusPane();
       
   352 
       
   353     TRACE_EXIT_POINT;
       
   354     }
       
   355   
       
   356 // ----------------------------------------------------------------------------
       
   357 // CCalenEventView::HandleCommandL
       
   358 // (other items were commented in a header).
       
   359 // ----------------------------------------------------------------------------
       
   360 //
       
   361 void CCalenEventView::HandleCommandL(TInt aCommand)  
       
   362     {
       
   363     TRACE_ENTRY_POINT;
       
   364 
       
   365     CCalenEventViewContainer* cnt = static_cast<CCalenEventViewContainer*>( iContainer );
       
   366     MCalenToolbar* toolbarImpl = iServices.ToolbarOrNull();
       
   367     switch(aCommand)
       
   368 		{
       
   369 		case ECalenCmdPromptThenEdit:
       
   370 			{
       
   371 			iServices.IssueCommandL(ECalenEditCurrentEntry);
       
   372 			break;	
       
   373 			}
       
   374         case ECalenCompleteTodo:
       
   375         case ECalenRestoreTodo:
       
   376         // TODO: Uncomment this when enabling attachment support
       
   377         case ECalenViewAttachmentList:    
       
   378         	{        
       
   379         	CCalenNativeView::HandleCommandL(aCommand);
       
   380         	}
       
   381             break;
       
   382         case EAknSoftkeyBack:
       
   383 			{
       
   384 			TRAP_IGNORE(RemoveToolbarButtonsL());
       
   385 	        iServices.IssueNotificationL(ECalenNotifyEntryClosed);
       
   386 			break;
       
   387 			}
       
   388 		case  ECalenStopAlarm:
       
   389             {
       
   390             iServices.IssueNotificationL(ECalenNotifyAlarmStopped);
       
   391             iEventViewCBA = EShowBack;
       
   392             UpdateCbaL();
       
   393             
       
   394             //show the toolbar again.
       
   395             if( toolbarImpl ) // If toolbar exists
       
   396                 {
       
   397                 CAknToolbar& toolbar = toolbarImpl->Toolbar();
       
   398                 toolbar.SetItemDimmed( ECalenSend, EFalse, ETrue );
       
   399                 toolbar.SetItemDimmed( ECalenEditCurrentEntry, EFalse, ETrue );
       
   400                 toolbar.SetItemDimmed( ECalenDeleteCurrentEntry, EFalse, ETrue );
       
   401                 }
       
   402             }
       
   403             break;
       
   404         case ECalenSnoozeAlarm:
       
   405             {
       
   406             iServices.IssueNotificationL(ECalenNotifyAlarmSnoozed);
       
   407             }            
       
   408             break;
       
   409             
       
   410         case EAknCmdHideInBackground:
       
   411             {
       
   412             if( IsAlarmActiveInViewer() )
       
   413                 {
       
   414                 iServices.IssueNotificationL(ECalenNotifyAlarmSnoozed);
       
   415                 }
       
   416             else
       
   417                 {
       
   418                 if(cnt->GetFindItemMenu()->CommandIsValidL(aCommand) && toolbarImpl)
       
   419                     {
       
   420                     CAknToolbar& toolbar = toolbarImpl->Toolbar();
       
   421                     toolbar.SetToolbarVisibility( EFalse );
       
   422                     cnt->GetFindItemMenu()->HandleItemFinderCommandL( aCommand );
       
   423                     toolbar.SetToolbarVisibility( ETrue );
       
   424                     return;
       
   425                     }
       
   426                 CCalenNativeView::HandleCommandL(aCommand);
       
   427                 }
       
   428             }
       
   429             break;
       
   430        case EAknSoftkeyEmpty:  // so that it will not crash in stop-snooze case.
       
   431             {
       
   432             // nothing to do
       
   433             }
       
   434             break;
       
   435        case ECalenCmdFindPhoneNum:
       
   436             {
       
   437             cnt->OnCmdFindPhoneNumL();
       
   438             }
       
   439             break;
       
   440        case ECalenCmdFindEmail:
       
   441             {
       
   442             cnt->OnCmdFindEmailL();
       
   443             }
       
   444             break;
       
   445        case ECalenCmdFindURL:
       
   446            {
       
   447            cnt->OnCmdFindUrlL();
       
   448            }
       
   449            break;
       
   450         default:
       
   451             if(cnt->GetFindItemMenu()->CommandIsValidL(aCommand) && toolbarImpl)
       
   452                 {
       
   453                 CAknToolbar& toolbar = toolbarImpl->Toolbar();
       
   454                 toolbar.SetToolbarVisibility( EFalse );
       
   455                 cnt->GetFindItemMenu()->HandleItemFinderCommandL( aCommand );
       
   456                 toolbar.SetToolbarVisibility( ETrue );
       
   457                 return;
       
   458                 }
       
   459             CCalenNativeView::HandleCommandL(aCommand);
       
   460             break;
       
   461         }
       
   462 
       
   463     TRACE_EXIT_POINT;
       
   464     }  
       
   465 
       
   466 // ----------------------------------------------------------------------------
       
   467 // CCalenEventView::IsAlarmActiveInViewer
       
   468 // (other items were commented in a header).
       
   469 // ----------------------------------------------------------------------------
       
   470 //
       
   471 TBool CCalenEventView::IsAlarmActiveInViewer()
       
   472     {
       
   473     TRACE_ENTRY_POINT;
       
   474     
       
   475     if( iEventViewCBA == EShowAlarm || iEventViewCBA == EShowAlarmStopOnly )
       
   476         {    
       
   477            TRACE_EXIT_POINT;
       
   478            
       
   479            return ETrue;
       
   480         }
       
   481     else
       
   482         return EFalse;
       
   483     }
       
   484 
       
   485 // ----------------------------------------------------------------------------
       
   486 // CCalenEventView::DynInitMenuPaneL
       
   487 // (other items were commented in a header).
       
   488 // ----------------------------------------------------------------------------
       
   489 //
       
   490 void CCalenEventView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
       
   491 	{
       
   492     TRACE_ENTRY_POINT;
       
   493     CCalenEventViewContainer* cnt = static_cast<CCalenEventViewContainer*>( iContainer );
       
   494     TCalCollectionId colId = iServices.Context().InstanceId().iColId;
       
   495     // get multiple db data from services
       
   496     RPointerArray<CCalCalendarInfo> calendarInfoList;
       
   497     iServices.GetAllCalendarInfoL(calendarInfoList);
       
   498     CleanupClosePushL(calendarInfoList);
       
   499     
       
   500     HBufC* calendarFileName = iServices.GetCalFileNameForCollectionId(colId).AllocLC();
       
   501     TInt index = calendarInfoList.Find( *calendarFileName, 
       
   502             CCalenEventViewContainer::CalendarInfoIdentifierL);
       
   503    CleanupStack::PopAndDestroy(calendarFileName);
       
   504     switch(aResourceId)
       
   505     	{
       
   506 	    case R_CALEN_EVENT_VIEW_MENUPANE:
       
   507 	    case R_CALEN_EVENT_VIEW_LONGTAP_MENUPANE:
       
   508 	    	{
       
   509 	    	CCalenEntryUtil* eventViewData = cnt->GetEventViewData();
       
   510 	    	if(eventViewData)
       
   511 	    	    {
       
   512 	    	    if(eventViewData->EntryType() == CCalEntry::ETodo)
       
   513 	    	        {
       
   514 	    	        if(eventViewData->Status() == CCalEntry::ETodoCompleted)
       
   515 	    	            {
       
   516 	    	            aMenuPane->DeleteMenuItem(ECalenCompleteTodo);
       
   517 	    	            }
       
   518 	    	        else
       
   519 	    	            {
       
   520 	    	            aMenuPane->DeleteMenuItem(ECalenRestoreTodo);
       
   521 	    	            }
       
   522 	    	        }			  
       
   523 	    	    else
       
   524 	    	        {
       
   525 	    	        aMenuPane->DeleteMenuItem(ECalenCompleteTodo);
       
   526 	    	        aMenuPane->DeleteMenuItem(ECalenRestoreTodo);
       
   527 	    	        }
       
   528 	    	    
       
   529 	    	    // TODO: Uncomment this when enabling attachment support
       
   530 	    	    
       
   531 	    	    if(!eventViewData->AttachmentCount())
       
   532 	    	        {
       
   533 	    	        aMenuPane->DeleteMenuItem(ECalenViewAttachmentList);
       
   534 	    	        }
       
   535 	    	    }
       
   536 	
       
   537 		  	 
       
   538 		  	 if(CCalenLocationUtil::IsMapProviderAvailableL())
       
   539             	{
       
   540 	            if(cnt->IsEventHasMapLocationL() || cnt->IsEventHasNoLocationTextL())
       
   541 		            {
       
   542 		            aMenuPane->DeleteMenuItem( ECalenGetLocationAndReplace );
       
   543 		            }
       
   544 		        if(!cnt->IsEventHasMapLocationL())
       
   545 			        {
       
   546 			        aMenuPane->DeleteMenuItem( ECalenShowLocation );	
       
   547 			        }	
       
   548             	}
       
   549             else // No map provider available, remove both option items
       
   550 	            {
       
   551 	            aMenuPane->DeleteMenuItem( ECalenGetLocationAndReplace );
       
   552 	            aMenuPane->DeleteMenuItem( ECalenShowLocation );	
       
   553 	            }
       
   554 		  	if(!(calendarInfoList[index]->Enabled()))
       
   555 		  	    {
       
   556                 aMenuPane->DeleteMenuItem(ECalenSend);
       
   557                 aMenuPane->DeleteMenuItem(ECalenCmdPromptThenEdit);
       
   558                 aMenuPane->DeleteMenuItem(ECalenDeleteCurrentEntry);
       
   559 		  	    }
       
   560 		  	
       
   561 		  	 
       
   562 		    break;
       
   563 		  	}
       
   564 		 default:
       
   565 		    {
       
   566 		      cnt->GetFindItemMenu()->UpdateItemFinderMenuL(aResourceId,aMenuPane); 
       
   567 		    }
       
   568 			break;
       
   569 		}
       
   570     CleanupStack::PopAndDestroy(&calendarInfoList);
       
   571     TRACE_EXIT_POINT;	
       
   572 	}
       
   573 	
       
   574 // ----------------------------------------------------------------------------
       
   575 // CCalenEventView::Id
       
   576 // (other items were commented in a header).
       
   577 // ----------------------------------------------------------------------------
       
   578 //
       
   579 TUid CCalenEventView::Id() const
       
   580 	{
       
   581     TRACE_ENTRY_POINT;
       
   582     TRACE_EXIT_POINT;	
       
   583     return KUidCalenEventView;
       
   584 	}
       
   585 
       
   586 // ----------------------------------------------------------------------------
       
   587 // CCalenEventView::CreateContainerImplL
       
   588 // (other items were commented in a header).
       
   589 // ----------------------------------------------------------------------------
       
   590 //
       
   591 CCalenContainer* CCalenEventView::CreateContainerImplL() 
       
   592 	{
       
   593     TRACE_ENTRY_POINT;
       
   594     TRACE_EXIT_POINT;	
       
   595     return new( ELeave )CCalenEventViewContainer( this, iServices );
       
   596 	}
       
   597 
       
   598 // ---------------------------------------------------------
       
   599 // CCalenEventView::UpdateCbaL
       
   600 // Set CBA button 
       
   601 // (other items were commented in a header).
       
   602 // ---------------------------------------------------------
       
   603 //
       
   604 void CCalenEventView::UpdateCbaL()
       
   605     {
       
   606     TRACE_ENTRY_POINT;  
       
   607       
       
   608     CEikButtonGroupContainer*  cba = Cba();
       
   609     switch(iEventViewCBA)
       
   610     {
       
   611         
       
   612     	case EShowClose:
       
   613 	    	{
       
   614 	    	 // if launched from soft notification/indicator
       
   615         	cba->SetCommandL( KSK2CBAPosition, R_CALEN_CLOSE_CBA_BUTTON);
       
   616     		cba->DrawNow();		
       
   617 	    	}
       
   618 	    	break;
       
   619     	
       
   620     	case EShowAlarm:
       
   621 	    	{
       
   622 	    	SetCbaL(R_CALEN_EVENT_VIEW_ALARM_CBA);	
       
   623 	    	}
       
   624 	    	break;
       
   625     	
       
   626     	case EShowAlarmStopOnly:
       
   627 	    	{
       
   628 	    	SetCbaL(R_CALEN_EVENT_VIEW_ALARM_STOP_ONLY_CBA);	
       
   629 	    	}
       
   630 	    	break;
       
   631     	
       
   632     	case EShowBack:
       
   633 	    	{
       
   634 	    	SetCbaL(R_CALEN_EVENT_VIEW_FROM_ALARM_CBA/*R_CALEN_BACK_CBA_BUTTON*/);	
       
   635 	    	}
       
   636 	    	break;
       
   637     	
       
   638     	default:
       
   639 	    	{
       
   640 	    	cba->SetCommandL(KSK2CBAPosition,R_CALEN_EXIT_CBA_BUTTON);
       
   641     		cba->DrawNow();	
       
   642 	    	}    	
       
   643     		break;
       
   644     	
       
   645     	
       
   646     }    
       
   647        
       
   648     TRACE_EXIT_POINT;
       
   649     }
       
   650 // ----------------------------------------------------------------------------
       
   651 // CCalenEventView::ClearViewSpecificDataL
       
   652 // (other items were commented in a header).
       
   653 // ----------------------------------------------------------------------------
       
   654 //
       
   655 void CCalenEventView::ClearViewSpecificDataL()
       
   656 	{
       
   657     TRACE_ENTRY_POINT;
       
   658 
       
   659     TRACE_EXIT_POINT;	
       
   660 	}
       
   661 
       
   662 // ----------------------------------------------------------------------------
       
   663 // CCalenEventView::CyclePosition
       
   664 // (other items were commented in a header).
       
   665 // ----------------------------------------------------------------------------
       
   666 //
       
   667 CCalenView::TCyclePosition CCalenEventView::CyclePosition() const
       
   668 	{
       
   669 	TRACE_ENTRY_POINT;
       
   670     TRACE_EXIT_POINT;	
       
   671     return ENoCyclePosition;
       
   672 	}
       
   673 
       
   674 // ----------------------------------------------------------------------------
       
   675 // CCalenEventView::AddToolbarButtonsL
       
   676 // Adds the necessary toolbar buttons on the existing toolbar for event viewer
       
   677 // ----------------------------------------------------------------------------
       
   678 //
       
   679 void CCalenEventView::AddToolbarButtonsL()
       
   680 	{
       
   681 	TRACE_ENTRY_POINT;
       
   682 	
       
   683 	// Get the existing toolbar from MCalenservices
       
   684 	MCalenToolbar* toolbarImpl = iServices.ToolbarOrNull();
       
   685 	
       
   686 	if(toolbarImpl)  // If toolbar exists
       
   687 		{
       
   688 		CAknToolbar& toolbar = toolbarImpl->Toolbar();
       
   689 		
       
   690 		// Create the new buttons for event viewer toolbar
       
   691 		// If layout is mirrored the button order is reversed.
       
   692 	    // For Non mirrored layouts each button is appended to the toolbar
       
   693 	    // For mirrored layouts each button is inserted at index 0.
       
   694 	    TBool mirrored( AknLayoutUtils::LayoutMirrored() );
       
   695 	    
       
   696 	    CAknButton* button = NULL;
       
   697 	    CGulIcon* icon = NULL;
       
   698 	    
       
   699 	    // First button: Send
       
   700 	    icon = iServices.GetIconL( MCalenServices::ECalenViewerSendIcon );
       
   701 	    // put icon onto cleanup stack before its ownership is transferred to CAknButton
       
   702 	    button = CreateButtonL( icon, _L(""), R_CALEN_TB_SEND, toolbar );
       
   703 	    if( mirrored )
       
   704 	        {
       
   705 	        // Insert the button at index 0
       
   706 	        toolbar.AddItemL( button, EAknCtButton, ECalenSend, 0, 0);
       
   707 	        }
       
   708 	    else
       
   709 	        {
       
   710 	        // Append the button
       
   711 	        toolbar.AddItemL( button, EAknCtButton, ECalenSend, 0, 0 );
       
   712 	        }
       
   713 	    
       
   714 	    // Second button: Edit
       
   715 	    icon = iServices.GetIconL( MCalenServices::ECalenViewerEditIcon );
       
   716 	    // put icon onto cleanup stack before its ownership is transferred to CAknButton
       
   717 	    button = CreateButtonL( icon, _L(""), R_CALEN_TB_EDIT, toolbar );
       
   718 	    if( mirrored )
       
   719 	        {
       
   720 	        // Insert the button at index 0
       
   721 	        toolbar.AddItemL( button, EAknCtButton, ECalenEditCurrentEntry, 0, 0 );
       
   722 	        }
       
   723 	    else
       
   724 	        {
       
   725 	        // Append the button
       
   726 	        toolbar.AddItemL( button, EAknCtButton, ECalenEditCurrentEntry, 0, 1 );
       
   727 	        }
       
   728 	    
       
   729 	    // Third button: Delete
       
   730 	    icon = iServices.GetIconL( MCalenServices::ECalenViewerDeleteIcon );
       
   731 	    // put icon onto cleanup stack before its ownership is transferred to CAknButton
       
   732 	    button = CreateButtonL( icon, _L(""), R_CALEN_TB_DELETE, toolbar );
       
   733 	    if( mirrored )
       
   734 	        {
       
   735 	        // Insert the button at index 0
       
   736 	        toolbar.AddItemL( button, EAknCtButton, ECalenDeleteCurrentEntry, 0, 0 );
       
   737 	        }
       
   738 	    else
       
   739 	        {
       
   740 	        // Append the button
       
   741 	        toolbar.AddItemL( button, EAknCtButton, ECalenDeleteCurrentEntry, 0, 2 );
       
   742 	        }
       
   743 	    // dim the tool bar items. 
       
   744 	    if( iEventViewCBA == EShowAlarm || iEventViewCBA == EShowAlarmStopOnly )
       
   745 	        {
       
   746 	        toolbar.SetItemDimmed( ECalenSend, ETrue, ETrue );
       
   747 	        toolbar.SetItemDimmed( ECalenEditCurrentEntry, ETrue, ETrue );
       
   748 	        toolbar.SetItemDimmed( ECalenDeleteCurrentEntry, ETrue, ETrue );
       
   749 	        }
       
   750 		}
       
   751     TRACE_EXIT_POINT;
       
   752 	}
       
   753 
       
   754 // ----------------------------------------------------------------------------
       
   755 // CCalenEventView::RemoveToolbarButtonsL
       
   756 // Removes the event viewer toolbar buttons and unhides the view cycling buttons
       
   757 // ----------------------------------------------------------------------------
       
   758 //
       
   759 void CCalenEventView::RemoveToolbarButtonsL()
       
   760 	{
       
   761 	TRACE_ENTRY_POINT;
       
   762 	
       
   763 	MCalenToolbar* toolbarImpl = iServices.ToolbarOrNull();
       
   764 	if(toolbarImpl) // If toolbar exists
       
   765 		{
       
   766 		CAknToolbar& toolbar = toolbarImpl->Toolbar();
       
   767 		if(&toolbar)
       
   768 		    {
       
   769 		    // Remove the viewer toolbar buttons
       
   770 		    toolbar.RemoveItem(ECalenDeleteCurrentEntry); // Delete button
       
   771 		    toolbar.RemoveItem(ECalenEditCurrentEntry);  // Edit button
       
   772 		    toolbar.RemoveItem(ECalenSend);  // Send button
       
   773 		    }
       
   774 		}
       
   775 	
       
   776 	TRACE_EXIT_POINT;
       
   777 	}
       
   778 	
       
   779 // ----------------------------------------------------------------------------
       
   780 // CCalenEventView::CreateButtonL
       
   781 // Create calendar toolbar buttons
       
   782 // ----------------------------------------------------------------------------
       
   783 CAknButton* CCalenEventView::CreateButtonL( CGulIcon* aIcon, 
       
   784                                             const TDesC& aText,
       
   785                                             TInt aTooltipID,
       
   786                                             CAknToolbar& aToolbar )
       
   787     {
       
   788     TRACE_ENTRY_POINT;
       
   789 
       
   790     TInt flags = 0;
       
   791     CAknButton* button = NULL;
       
   792     
       
   793     CleanupStack::PushL( aIcon );
       
   794     HBufC* tooltipText = StringLoader::LoadLC( aTooltipID );
       
   795     CleanupStack::Pop( tooltipText );
       
   796     // put icon onto cleanup stack before its ownership is transferred to CAknButton
       
   797     CleanupStack::Pop( aIcon );
       
   798     CleanupStack::PushL( tooltipText );
       
   799     button = CAknButton::NewL( aIcon, NULL, NULL, NULL,
       
   800                                             aText, tooltipText->Des(), flags, 0 );
       
   801     CleanupStack::PopAndDestroy( tooltipText );
       
   802 
       
   803     button->SetIconScaleMode( EAspectRatioNotPreserved );
       
   804     button->SetFocusing( EFalse );
       
   805     button->SetBackground( &aToolbar );
       
   806 
       
   807     TRACE_EXIT_POINT;
       
   808     return button;
       
   809     } 
       
   810     
       
   811 // ----------------------------------------------------------------------------
       
   812 // CCalenEventView::UpdateToolbarButtonsL
       
   813 // Updates the toolbar buttons on the existing toolbar for event viewer
       
   814 // ----------------------------------------------------------------------------
       
   815 //  
       
   816 
       
   817 void CCalenEventView::UpdateToolbarButtonsL()
       
   818     {
       
   819     // Get the existing toolbar from MCalenservices
       
   820     MCalenToolbar* toolbarImpl = iServices.ToolbarOrNull();
       
   821     
       
   822     TCalCollectionId colId = iServices.Context().InstanceId().iColId;
       
   823       
       
   824     // get multiple db data from services
       
   825     RPointerArray<CCalCalendarInfo> calendarInfoList;
       
   826     iServices.GetAllCalendarInfoL(calendarInfoList);
       
   827     CleanupClosePushL(calendarInfoList);
       
   828     
       
   829     HBufC* calendarFileName = iServices.GetCalFileNameForCollectionId(colId).AllocLC();
       
   830     TInt index = calendarInfoList.Find( *calendarFileName, 
       
   831     CCalenEventViewContainer::CalendarInfoIdentifierL);
       
   832     CleanupStack::PopAndDestroy(calendarFileName);
       
   833     if(toolbarImpl)
       
   834         {
       
   835         CAknToolbar& toolbar = toolbarImpl->Toolbar();
       
   836         if(!(calendarInfoList[index]->Enabled()))
       
   837             {
       
   838             toolbar.SetItemDimmed( ECalenSend, ETrue, ETrue );
       
   839             toolbar.SetItemDimmed( ECalenDeleteCurrentEntry, ETrue, ETrue );
       
   840             toolbar.SetItemDimmed( ECalenEditCurrentEntry, ETrue, ETrue );
       
   841             }
       
   842         else
       
   843             {
       
   844             toolbar.SetItemDimmed( ECalenSend, EFalse, ETrue );
       
   845             toolbar.SetItemDimmed( ECalenDeleteCurrentEntry, EFalse, ETrue );
       
   846             toolbar.SetItemDimmed( ECalenEditCurrentEntry, EFalse, ETrue );
       
   847             }
       
   848         }
       
   849     CleanupStack::PopAndDestroy(&calendarInfoList);
       
   850     }
       
   851 // ----------------------------------------------------------------------------
       
   852 // CCalenEventView::SetStatusPaneFromActiveContextL
       
   853 // Set the calendar name to status pane
       
   854 // (other items were commented in a header).
       
   855 // ----------------------------------------------------------------------------
       
   856 //
       
   857 void CCalenEventView::SetStatusPaneFromActiveContextL()
       
   858     {
       
   859     TRACE_ENTRY_POINT;
       
   860     
       
   861     RPointerArray<CCalCalendarInfo> calendarInfoList;
       
   862     iServices.GetAllCalendarInfoL(calendarInfoList);
       
   863     CleanupClosePushL(calendarInfoList);
       
   864 
       
   865     TCalCollectionId colId; 
       
   866     colId = iServices.Context().InstanceId().iColId;
       
   867 
       
   868     HBufC* calendarFileName = iServices.GetCalFileNameForCollectionId(colId).AllocLC();
       
   869     TInt calIndex = calendarInfoList.Find( *calendarFileName, 
       
   870             CCalenEventViewContainer::CalendarInfoIdentifierL);
       
   871     CleanupStack::PopAndDestroy(calendarFileName);
       
   872     if(calIndex != KErrNotFound)
       
   873         {
       
   874         HBufC* calendarName = calendarInfoList[calIndex]->NameL().AllocLC();
       
   875         TRgb calendarColor = calendarInfoList[calIndex]->Color();
       
   876         // navi pane
       
   877         CAknNavigationDecorator* naviLabel = iSPUtils->ShowNaviPaneL( *calendarName, calendarColor );
       
   878         CleanupStack::PopAndDestroy(calendarName);
       
   879         }
       
   880     CleanupStack::PopAndDestroy(&calendarInfoList);
       
   881     
       
   882 
       
   883     iSPUtils->RefreshStatusPane();
       
   884     TRACE_EXIT_POINT;
       
   885     }
       
   886 
       
   887 // ----------------------------------------------------------------------------
       
   888 // CCalenEventView::HideNaviPane
       
   889 // Hides the navi pane
       
   890 // (other items were commented in a header).
       
   891 // ----------------------------------------------------------------------------
       
   892 //
       
   893 void CCalenEventView::HideNaviPane()
       
   894     {
       
   895     TRACE_ENTRY_POINT;
       
   896     if (!iAvkonAppUi->IsDisplayingMenuOrDialog())
       
   897         {
       
   898         iSPUtils->HideNaviPane();
       
   899         }
       
   900     TRACE_EXIT_POINT;
       
   901     }
       
   902 
       
   903 //end of file
       
   904