examples/ForumNokia/CalendarExample/inc/CalendarAPIexampleEngine.h

00001 /*
00002  * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003  *    
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are met:
00006  *    
00007  *  * Redistributions of source code must retain the above copyright notice, this
00008  *    list of conditions and the following disclaimer.
00009  *  * Redistributions in binary form must reproduce the above copyright notice,
00010  *    this list of conditions and the following disclaimer in the documentation
00011  *    and/or other materials provided with the distribution.
00012  *  * Neither the name of Nokia Corporation nor the names of its contributors
00013  *    may be used to endorse or promote products derived from this software
00014  *    without specific prior written permission.
00015  *    
00016  *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017  *    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018  *    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019  *    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020  *    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021  *    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022  *    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023  *    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024  *    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025  *    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026  *    
00027  *    Description:  
00028  */
00029 
00030 
00031 #ifndef __CALENDAR_API_EXAMPLE_ENGINE_H
00032 #define __CALENDAR_API_EXAMPLE_ENGINE_H
00033 
00034 // INCLUDES
00035 #include <e32base.h>    //CBase
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>   //CEikProgressInfo
00043 #include "CalendarHelperEntry.h" //CCalHelperEntry
00044 
00045 // CONSTANTS
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 //commands to observer
00059 class MCalenderEngineObserverUI
00060     {
00061     public:
00062         virtual void ActivateView(TUid aViewId) = 0;
00063     };
00064 
00065 //Commands called from views:
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 // CLASS DECLARATION
00093 
00103 class CCalendarAPIexampleEngine :   public CBase,
00104                                     public MCalProgressCallBack,
00105                                     public MCalendarEngineCommandsInterface
00106 {
00107 public: // Constructors and destructor
00108 
00112     static CCalendarAPIexampleEngine* NewL(MCalenderEngineObserverUI& aAppUi);
00113 
00117     virtual ~CCalendarAPIexampleEngine();
00118 
00119 public: // Other functions
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: // Data members
00295 
00296     CActiveSchedulerWait* iWait;
00297     CCalSession* iCalSession;
00298     CCalEntryView* iEntryView;
00299     CCalInstanceView* iInstanceView;
00300     TBool iCreatingEntryView;
00301     CAknProgressDialog* iProgressDialog;
00302     CEikProgressInfo* iProgressInfo;
00303     
00304     // Here are all CCalEntrys hold inside CCalHelperEntry
00305     // the results are put here in DoSearchL
00306     RPointerArray<CCalHelperEntry> iEntries;
00307     
00308     TSearchType iCurrentSearchType;
00309     
00310     //Used in creating new entries. Created in CreateEntryForModificationL
00311     CCalHelperEntry* iEntry;
00312     
00313     //Used in knowing which CCalEntry we're modifying
00314     TInt iModifyIndex;
00315     
00316     //A reference to appui, used in updating views.
00317     MCalenderEngineObserverUI& iAppUi;
00318     
00319     };
00320 
00321 #endif

Generated by  doxygen 1.6.2