00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 #ifndef __CALENDAR_API_EXAMPLE_ENGINE_H
00032 #define __CALENDAR_API_EXAMPLE_ENGINE_H
00033 
00034 
00035 #include <e32base.h>    
00036 #include <calsession.h>
00037 #include <calentry.h>
00038 #include <calinstanceview.h>
00039 #include <calentryview.h>
00040 #include <CalProgressCallBack.h>
00041 #include <AknProgressDialog.h>
00042 #include <eikprogi.h>   
00043 #include "CalendarHelperEntry.h" 
00044 
00045 
00046 const TInt KMaxSync = 2;
00047 const TInt KDefaultAlarmHour = 8;
00048 const TInt KUndefinedModifyIndex = -1;
00049 
00050 enum TSearchType
00051     {
00052     EWeek,
00053     EMonth,
00054     ESixMonths,
00055     EYear
00056     };
00057 
00058 
00059 class MCalenderEngineObserverUI
00060     {
00061     public:
00062         virtual void ActivateView(TUid aViewId) = 0;
00063     };
00064 
00065 
00066 class MCalendarEngineCommandsInterface 
00067     {
00068     public:
00069        virtual void DoSearchL(  const TSearchType& aType) = 0;
00070        virtual void DoAddL() = 0;
00071        virtual void DoSaveL() = 0;
00072        virtual void CreateEntryForModificationL(TBool& aModify)=0;
00073        virtual TInt EntryCount() const = 0;
00074        
00075        virtual void DeleteEntryL(const TInt& aIndex) = 0;
00076        virtual void ExecuteDeletionL() = 0;
00077        
00078        virtual CCalHelperEntry& Entry(const TInt& aIndex) = 0;
00079        virtual void SetModifyIndex(const TInt& aIndex) = 0;
00080        virtual TInt ModifyIndex() const = 0;
00081        virtual TBool SetValuesToNewEntry( const TDesC& aName,
00082                         const TDateTime& aDate,
00083                         const TBool& aAlarm,
00084                         const TDateTime& aAlarmTime,
00085                         const TInt& aSynchronizationMethod) = 0; 
00086        virtual void GetValuesToSet(TDes& aName, TTime& aDate,
00087                        TBool& aAlarm, TTime& aAlarmTime,
00088                                 TInt& aSync) = 0 ;
00089     
00090     };
00091 
00092 
00093 
00103 class CCalendarAPIexampleEngine :   public CBase,
00104                                     public MCalProgressCallBack,
00105                                     public MCalendarEngineCommandsInterface
00106 {
00107 public: 
00108 
00112     static CCalendarAPIexampleEngine* NewL(MCalenderEngineObserverUI& aAppUi);
00113 
00117     virtual ~CCalendarAPIexampleEngine();
00118 
00119 public: 
00120     
00127     void AddAnniversaryL(   CCalEntry* aAnniv) ;
00128 
00135     void UpdateAnniversaryL(CCalEntry* aAnniv) ;
00136 
00143     void DeleteAnniversaryL(CCalEntry* aAnniv) ;
00144 
00153     void GetAnniversariesL( const TDateTime& aFrom, 
00154                             const TDateTime& aTo,                           
00155                             RPointerArray<CCalInstance>& aAnniversaries);
00156 
00162     TInt EntryCount() const;
00163 
00170     CCalHelperEntry& Entry(const TInt& aIndex);
00171     
00178     void DoSearchL( const TSearchType& aType);
00179     
00185     void DoAddL();                     
00186     
00192     TInt ModifyIndex() const;
00193     
00201     void SetModifyIndex(const TInt& aIndex);
00202     
00211     void CreateEntryForModificationL(TBool& aModify);
00212     
00219     void SaveL();
00220     
00225     void DoSaveL();
00226     
00233     void DeleteEntryL(const TInt& aIndex);
00234     
00242     TBool SetValuesToNewEntry( const TDesC& aName,
00243                         const TDateTime& aDate,
00244                         const TBool& aAlarm,
00245                         const TDateTime& aAlarmTime,
00246                         const TInt& aSynchronizationMethod);
00247                         
00254     void GetValuesToSet(TDes& aName, TTime& aDate,
00255                    TBool& aAlarm, TTime& aAlarmTime,
00256                             TInt& aSync);   
00257                         
00263     void ExecuteDeletionL();
00264     
00265 private:
00269     CCalendarAPIexampleEngine(MCalenderEngineObserverUI& aAppUi);
00270     void ConstructL();  
00271     
00278     virtual void Progress(TInt aPercentageCompleted);
00279     
00286     virtual void Completed(TInt aError);
00287     
00292     virtual TBool NotifyProgress(); 
00293     
00294 private: 
00295 
00296     CActiveSchedulerWait* iWait;
00297     CCalSession* iCalSession;
00298     CCalEntryView* iEntryView;
00299     CCalInstanceView* iInstanceView;
00300     TBool iCreatingEntryView;
00301     CAknProgressDialog* iProgressDialog;
00302     CEikProgressInfo* iProgressInfo;
00303     
00304     
00305     
00306     RPointerArray<CCalHelperEntry> iEntries;
00307     
00308     TSearchType iCurrentSearchType;
00309     
00310     
00311     CCalHelperEntry* iEntry;
00312     
00313     
00314     TInt iModifyIndex;
00315     
00316     
00317     MCalenderEngineObserverUI& iAppUi;
00318     
00319     };
00320 
00321 #endif