meetingui/meetingrequestutils/inc/CMRUtilsCalDbBase.h
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2005 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:  
       
    15 *       Class wrapping a calendar db, taking care of initialization etc.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __CMRUTILSCALDBBASE_H__
       
    22 #define __CMRUTILSCALDBBASE_H__
       
    23 
       
    24 //  INCLUDES
       
    25 #include <e32base.h>
       
    26 #include <calprogresscallback.h>
       
    27 #include <calcommon.h>
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CCalEntryView;
       
    31 class CCalInstanceView;
       
    32 class CCalEntry;
       
    33 class CCalInstance;
       
    34 class CMRUtilsCalDbBase;
       
    35 class CCalSession;
       
    36 
       
    37 // CLASS DECLARATION
       
    38 
       
    39 /**
       
    40 * Observer interface for handling calendar database status.
       
    41 */
       
    42 class MMRUtilsCalDbObserver
       
    43     {
       
    44     public: // Data types
       
    45     
       
    46         /**
       
    47         * Enumeration for database status.
       
    48         */
       
    49         enum TDbStatus
       
    50             {
       
    51             EUninitialized       = 0x0000, // nothing done yet
       
    52             EReseting            = 0x0002, // db reset ongoing
       
    53             EInitEntryView       = 0x0004, // init entry view
       
    54             EInitInstanceView    = 0x0008, // init instance view
       
    55             EFinishedOk          = 0x0010, // init succeeded
       
    56             EFinishedError       = 0x0020  // init failed
       
    57             };
       
    58 
       
    59     public: // New functions
       
    60     
       
    61         /**
       
    62         * Callback method for handling database status.
       
    63         * @param aNotifier for identifying the notifying database
       
    64         * @param aStatus new current status of the database
       
    65         */
       
    66         virtual void HandleCalDbStatus( const CMRUtilsCalDbBase* aNotifier,
       
    67                                         TDbStatus aStatus ) = 0;
       
    68                 
       
    69     };
       
    70 
       
    71 /**
       
    72 * Abstract base class representing a calendar database.
       
    73 */
       
    74 class CMRUtilsCalDbBase
       
    75 : public CBase, 
       
    76   public MCalProgressCallBack
       
    77     {
       
    78     public: // Constructors and destructors
       
    79     
       
    80         /**
       
    81         * Destructor.
       
    82         */
       
    83         ~CMRUtilsCalDbBase();
       
    84     
       
    85     public: // New functions
       
    86     
       
    87         /**
       
    88         * Entry view accessor. Ownership not transferred.
       
    89         * @return entry view, may be NULL
       
    90         */
       
    91         const CCalEntryView* EntryView() const;
       
    92         
       
    93         /**
       
    94         * Instance view accessor. Ownership not transferred.
       
    95         * @return instance view, may be NULL        
       
    96         */        
       
    97         const CCalInstanceView* InstanceView() const;
       
    98         
       
    99         /**
       
   100         * Session accessor. Ownership not transferred.
       
   101         * @return session, may be NULL        
       
   102         */        
       
   103         const CCalSession* Session() const;
       
   104         
       
   105         /**
       
   106         * Entry view accessor. Ownership not transferred.
       
   107         * @return entry view, may be NULL
       
   108         */
       
   109         CCalEntryView* EntryView();
       
   110         
       
   111         /**
       
   112         * Instance view accessor. Ownership not transferred.
       
   113         * @return instance view, may be NULL        
       
   114         */        
       
   115         CCalInstanceView* InstanceView();
       
   116 
       
   117         /**
       
   118         * Session accessor. Ownership not transferred.
       
   119         * @return session, may be NULL        
       
   120         */        
       
   121         CCalSession* Session();        
       
   122         
       
   123         /**
       
   124         * Database status getter.
       
   125         * @return current database status
       
   126         */
       
   127         MMRUtilsCalDbObserver::TDbStatus DbStatus();
       
   128 
       
   129         /**
       
   130         * CCalEntryView lacks fetch with time range. This method provides such
       
   131         * functionality. In case of repeating entries the entire sequence must
       
   132         * be within range (but modifying entries are considered separately).
       
   133         * If database doesn't have both instance and entry view then this
       
   134         * method leaves with KErrNotSupported.
       
   135         * @param aCalEntryArray fetched entries, caller owns array items
       
   136         * @param aCalTimeRange time range
       
   137         */
       
   138         void FetchWithRangeL( RPointerArray<CCalEntry>& aCalEntryArray,
       
   139                               const CalCommon::TCalTimeRange& aCalTimeRange,
       
   140                               TBool aFetchFullCopy = ETrue );
       
   141         
       
   142         /**
       
   143         * Reset database, causes asynchronous db initialization
       
   144         * which is notified through MMRUtilsCalDbObserver interface.
       
   145         * Calling this method requires that there are no external
       
   146         * open references for the session.
       
   147         * The default implementation leaves with KErrNotSupported.
       
   148         */        
       
   149         virtual void ResetDbL();
       
   150 
       
   151         /**
       
   152         * Tests whether given entry fits completely within given time range.
       
   153         * @param aEntry entry to test
       
   154         * @param aCalTimeRange criterion
       
   155         * @return ETrue if fits, EFalse if exceeds from either end
       
   156         */
       
   157         static TBool IsCompletelyWithinRangeL(
       
   158             const CCalEntry& aEntry,
       
   159             const CalCommon::TCalTimeRange& aCalTimeRange );
       
   160         
       
   161         /**
       
   162         * Wrapper which traps leaving CompareL(), and in leave situation
       
   163         * returns that objects are equal since that is a safer interpretation
       
   164         * and avoids duplicates in database.
       
   165         * In real life CompareL() is not expected to ever leave.
       
   166         * @param aFirst entry
       
   167         * @param aSecond entry
       
   168         * @return zero if the objects are equal, a negative value if aFirst is
       
   169         *         less than aSecond and a positive value otherwise
       
   170         */
       
   171         static TInt Compare( const CCalEntry& aFirst,
       
   172                              const CCalEntry& aSecond );
       
   173 
       
   174         /**
       
   175         * Helper which allows ordering entries in an array. That is implemented
       
   176         * by evaluating GUID and RECURRENCE-ID of the two entries.
       
   177         * @param aFirst entry
       
   178         * @param aSecond entry
       
   179         * @return zero if the objects are equal, a negative value if aFirst is
       
   180         *         less than aSecond and a positive value otherwise
       
   181         */                             
       
   182         static TInt CompareL( const CCalEntry& aFirst,
       
   183                               const CCalEntry& aSecond );
       
   184         
       
   185     protected: // From MCalProgressCallBack
       
   186     
       
   187     	void Progress( TInt aPercentageCompleted );
       
   188 		
       
   189         TBool NotifyProgress();
       
   190         
       
   191 	    // This method must be implemented by the subclasses:
       
   192         // void Completed( TInt aError );
       
   193         
       
   194     protected: // Constructors and destructors
       
   195     
       
   196        /**
       
   197         * C++ default constructor.
       
   198         * @param aDbObserver database observer reference
       
   199         * @param aCmdObserver asynchronous command observer reference
       
   200         */
       
   201         CMRUtilsCalDbBase( MMRUtilsCalDbObserver& aDbObserver,
       
   202                            MCalProgressCallBack& aCmdObserver );        
       
   203 
       
   204     protected: // data
       
   205     
       
   206         // Current database status
       
   207         MMRUtilsCalDbObserver::TDbStatus iDbStatus;          
       
   208     
       
   209         // This callback is used for notifying about database status
       
   210         MMRUtilsCalDbObserver& iDbObserver;
       
   211         
       
   212         // This callback is used for notifying about asynchronous
       
   213         // command progress, Note: currently not used for anything!
       
   214         MCalProgressCallBack& iCmdObserver;
       
   215 
       
   216         // Managed by the subclass
       
   217         CCalEntryView* iCalEntryView;
       
   218         
       
   219         // Managed by the subclass
       
   220         CCalInstanceView* iCalInstanceView;    
       
   221         
       
   222         // Managed by the subclass
       
   223         CCalSession* iCalSession;            
       
   224     };
       
   225 
       
   226 #endif // __CMRUTILSCALDBBASE_H__
       
   227 
       
   228 // End of File