calendarui/views/src/caleneventview.cpp
branchRCL_3
changeset 18 d68a4b5d5885
parent 11 0f07cd1b5772
child 20 9c5b1510919f
--- a/calendarui/views/src/caleneventview.cpp	Tue May 11 16:12:24 2010 +0300
+++ b/calendarui/views/src/caleneventview.cpp	Tue May 25 12:41:10 2010 +0300
@@ -25,6 +25,8 @@
 #include <calencommands.hrh>            // Calendar commands
 #include <calencontext.h>
 #include <CalenStatusPaneUtils.h>
+#include <calcalendarinfo.h>
+#include <caleninstanceid.h>
 
 // user includes
 #include "caleneventview.h"
@@ -157,6 +159,7 @@
         	{
         	cnt->CompletePopulationL();
         	RedrawStatusPaneL();
+        	UpdateToolbarButtonsL();
         	nextStep = CCalenView::EDone;
         	}
         	break;
@@ -465,12 +468,23 @@
 	{
     TRACE_ENTRY_POINT;
     CCalenEventViewContainer* cnt = static_cast<CCalenEventViewContainer*>( iContainer );
+    TCalCollectionId colId = iServices.Context().InstanceId().iColId;
+    // get multiple db data from services
+    RPointerArray<CCalCalendarInfo> calendarInfoList;
+    iServices.GetAllCalendarInfoL(calendarInfoList);
+    CleanupClosePushL(calendarInfoList);
+    
+    HBufC* calendarFileName = iServices.GetCalFileNameForCollectionId(colId).AllocLC();
+    TInt index = calendarInfoList.Find( *calendarFileName, 
+            CCalenEventViewContainer::CalendarInfoIdentifierL);
+   CleanupStack::PopAndDestroy(calendarFileName);
     switch(aResourceId)
     	{
 	    case R_CALEN_EVENT_VIEW_MENUPANE:
 	    case R_CALEN_EVENT_VIEW_LONGTAP_MENUPANE:
 	    	{
 	    	CCalenEntryUtil* eventViewData = cnt->GetEventViewData();
+	    	
 	    	if(eventViewData)
 	    	    {
 	    	    if(eventViewData->EntryType() == CCalEntry::ETodo)
@@ -515,6 +529,14 @@
 	            aMenuPane->DeleteMenuItem( ECalenGetLocationAndReplace );
 	            aMenuPane->DeleteMenuItem( ECalenShowLocation );	
 	            }
+		  	if(!(calendarInfoList[index]->Enabled()))
+		  	    {
+                aMenuPane->DeleteMenuItem(ECalenSend);
+                aMenuPane->DeleteMenuItem(ECalenCmdPromptThenEdit);
+                aMenuPane->DeleteMenuItem(ECalenDeleteCurrentEntry);
+		  	    }
+		  	
+		  	 
 		    break;
 		  	}
 		 default:
@@ -523,7 +545,7 @@
 		    }
 			break;
 		}
-    
+    CleanupStack::PopAndDestroy(&calendarInfoList);
     TRACE_EXIT_POINT;	
 	}
 	
@@ -762,5 +784,44 @@
 
     TRACE_EXIT_POINT;
     return button;
-    }    
+    } 
+    
+// ----------------------------------------------------------------------------
+// CCalenEventView::UpdateToolbarButtonsL
+// Updates the toolbar buttons on the existing toolbar for event viewer
+// ----------------------------------------------------------------------------
+//  
+
+void CCalenEventView::UpdateToolbarButtonsL()
+    {
+    // Get the existing toolbar from MCalenservices
+    MCalenToolbar* toolbarImpl = iServices.ToolbarOrNull();
+    CAknToolbar& toolbar = toolbarImpl->Toolbar();
+    TCalCollectionId colId = iServices.Context().InstanceId().iColId;
+      
+    // get multiple db data from services
+    RPointerArray<CCalCalendarInfo> calendarInfoList;
+    iServices.GetAllCalendarInfoL(calendarInfoList);
+    CleanupClosePushL(calendarInfoList);
+    
+    HBufC* calendarFileName = iServices.GetCalFileNameForCollectionId(colId).AllocLC();
+    TInt index = calendarInfoList.Find( *calendarFileName, 
+    CCalenEventViewContainer::CalendarInfoIdentifierL);
+    CleanupStack::PopAndDestroy(calendarFileName);
+    
+    
+    if(!(calendarInfoList[index]->Enabled()))
+        {
+        toolbar.SetItemDimmed( ECalenSend, ETrue, ETrue );
+        toolbar.SetItemDimmed( ECalenDeleteCurrentEntry, ETrue, ETrue );
+        toolbar.SetItemDimmed( ECalenEditCurrentEntry, ETrue, ETrue );
+        }
+    else
+        {
+        toolbar.SetItemDimmed( ECalenSend, EFalse, ETrue );
+        toolbar.SetItemDimmed( ECalenDeleteCurrentEntry, EFalse, ETrue );
+        toolbar.SetItemDimmed( ECalenEditCurrentEntry, EFalse, ETrue );
+        }
+    CleanupStack::PopAndDestroy(&calendarInfoList);
+    }
 //end of file