00001 /* 00002 * Copyright © 2008 Nokia Corporation. 00003 */ 00004 00005 00006 #ifndef __CALENDAR_API_EXAMPLE_ENGINE_H 00007 #define __CALENDAR_API_EXAMPLE_ENGINE_H 00008 00009 // INCLUDES 00010 #include <e32base.h> //CBase 00011 #include <calsession.h> 00012 #include <calentry.h> 00013 #include <calinstanceview.h> 00014 #include <calentryview.h> 00015 #include <CalProgressCallBack.h> 00016 #include <AknProgressDialog.h> 00017 #include <eikprogi.h> //CEikProgressInfo 00018 #include "CalendarHelperEntry.h" //CCalHelperEntry 00019 00020 // CONSTANTS 00021 const TInt KMaxSync = 2; 00022 const TInt KDefaultAlarmHour = 8; 00023 const TInt KUndefinedModifyIndex = -1; 00024 00025 enum TSearchType 00026 { 00027 EWeek, 00028 EMonth, 00029 ESixMonths, 00030 EYear 00031 }; 00032 00033 //commands to observer 00034 class MCalenderEngineObserverUI 00035 { 00036 public: 00037 virtual void ActivateView(TUid aViewId) = 0; 00038 }; 00039 00040 //Commands called from views: 00041 class MCalendarEngineCommandsInterface 00042 { 00043 public: 00044 virtual void DoSearchL( const TSearchType& aType) = 0; 00045 virtual void DoAddL() = 0; 00046 virtual void DoSaveL() = 0; 00047 virtual void CreateEntryForModificationL(TBool& aModify)=0; 00048 virtual TInt EntryCount() const = 0; 00049 00050 virtual void DeleteEntryL(const TInt& aIndex) = 0; 00051 virtual void ExecuteDeletionL() = 0; 00052 00053 virtual CCalHelperEntry& Entry(const TInt& aIndex) = 0; 00054 virtual void SetModifyIndex(const TInt& aIndex) = 0; 00055 virtual TInt ModifyIndex() const = 0; 00056 virtual TBool SetValuesToNewEntry( const TDesC& aName, 00057 const TDateTime& aDate, 00058 const TBool& aAlarm, 00059 const TDateTime& aAlarmTime, 00060 const TInt& aSynchronizationMethod) = 0; 00061 virtual void GetValuesToSet(TDes& aName, TTime& aDate, 00062 TBool& aAlarm, TTime& aAlarmTime, 00063 TInt& aSync) = 0 ; 00064 00065 }; 00066 00067 // CLASS DECLARATION 00068 00078 class CCalendarAPIexampleEngine : public CBase, 00079 public MCalProgressCallBack, 00080 public MCalendarEngineCommandsInterface 00081 { 00082 public: // Constructors and destructor 00083 00087 static CCalendarAPIexampleEngine* NewL(MCalenderEngineObserverUI& aAppUi); 00088 00092 virtual ~CCalendarAPIexampleEngine(); 00093 00094 public: // Other functions 00095 00102 void AddAnniversaryL( CCalEntry* aAnniv) ; 00103 00110 void UpdateAnniversaryL(CCalEntry* aAnniv) ; 00111 00118 void DeleteAnniversaryL(CCalEntry* aAnniv) ; 00119 00128 void GetAnniversariesL( const TDateTime& aFrom, 00129 const TDateTime& aTo, 00130 RPointerArray<CCalInstance>& aAnniversaries); 00131 00137 TInt EntryCount() const; 00138 00145 CCalHelperEntry& Entry(const TInt& aIndex); 00146 00153 void DoSearchL( const TSearchType& aType); 00154 00160 void DoAddL(); 00161 00167 TInt ModifyIndex() const; 00168 00176 void SetModifyIndex(const TInt& aIndex); 00177 00186 void CreateEntryForModificationL(TBool& aModify); 00187 00194 void SaveL(); 00195 00200 void DoSaveL(); 00201 00208 void DeleteEntryL(const TInt& aIndex); 00209 00217 TBool SetValuesToNewEntry( const TDesC& aName, 00218 const TDateTime& aDate, 00219 const TBool& aAlarm, 00220 const TDateTime& aAlarmTime, 00221 const TInt& aSynchronizationMethod); 00222 00229 void GetValuesToSet(TDes& aName, TTime& aDate, 00230 TBool& aAlarm, TTime& aAlarmTime, 00231 TInt& aSync); 00232 00238 void ExecuteDeletionL(); 00239 00240 private: 00244 CCalendarAPIexampleEngine(MCalenderEngineObserverUI& aAppUi); 00245 void ConstructL(); 00246 00253 virtual void Progress(TInt aPercentageCompleted); 00254 00261 virtual void Completed(TInt aError); 00262 00267 virtual TBool NotifyProgress(); 00268 00269 private: // Data members 00270 00271 CActiveSchedulerWait* iWait; 00272 CCalSession* iCalSession; 00273 CCalEntryView* iEntryView; 00274 CCalInstanceView* iInstanceView; 00275 TBool iCreatingEntryView; 00276 CAknProgressDialog* iProgressDialog; 00277 CEikProgressInfo* iProgressInfo; 00278 00279 // Here are all CCalEntrys hold inside CCalHelperEntry 00280 // the results are put here in DoSearchL 00281 RPointerArray<CCalHelperEntry> iEntries; 00282 00283 TSearchType iCurrentSearchType; 00284 00285 //Used in creating new entries. Created in CreateEntryForModificationL 00286 CCalHelperEntry* iEntry; 00287 00288 //Used in knowing which CCalEntry we're modifying 00289 TInt iModifyIndex; 00290 00291 //A reference to appui, used in updating views. 00292 MCalenderEngineObserverUI& iAppUi; 00293 00294 }; 00295 00296 #endif
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.