calendarui/organizerplugin/aiagendapluginengine/inc/AIAgendaPluginEngineImpl.h
changeset 0 f979ecb2b13e
child 13 1984aceb8774
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2002 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:  This class contains the actual implementation of the engine.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CAIAGENDAPLUGINENGINEIMPL_H
       
    20 #define CAIAGENDAPLUGINENGINEIMPL_H
       
    21 
       
    22 // INCLUDES
       
    23 #include "CalEngineCallback.h"
       
    24 #include "CalenEngine.h"
       
    25 #include "CalSvrClient.h"
       
    26 #include "PropertyObserver.h"
       
    27 
       
    28 #include <calfilechangenotification.h>
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class CEnvironmentChangeNotifier;
       
    32 class CEventExpirationTimer;
       
    33 class CCalInstance;
       
    34 class MPluginDataChangeObserver;
       
    35 class CCalSession;
       
    36 
       
    37 // CLASS DECLARATION
       
    38 NONSHARABLE_CLASS( CAIAgendaPluginEngineImpl ) : public CBase,
       
    39                                                  public MCalenEngineListener,
       
    40                                                  public MCalSvrAgendaUpdateListener,
       
    41                                                  public MPropertyChangeHandler,
       
    42                                                  public MCalFileChangeObserver
       
    43                                                  
       
    44 {
       
    45     // Allow CAIAgendaPluginEngine to access the SafeRefresh()
       
    46     friend class CAIAgendaPluginEngine;
       
    47 
       
    48  public:
       
    49     /**
       
    50      * Two-phased constructor.
       
    51      * @since Series 60 2.6
       
    52      * @param ?arg1 ?description
       
    53      **/
       
    54     static CAIAgendaPluginEngineImpl* NewL(MPluginDataChangeObserver& aDataChangeObserver, TObserverType aObserverType);
       
    55 
       
    56     /**
       
    57      * ?member_description.
       
    58      * @since Series 60 2.6
       
    59      **/
       
    60     void ConstructL(void);
       
    61 
       
    62     /**
       
    63      * Destructor.
       
    64      * @since Series 60 2.6
       
    65      **/
       
    66     virtual ~CAIAgendaPluginEngineImpl(void);
       
    67 
       
    68  private:
       
    69     /**
       
    70      * Hide default constructor.
       
    71      * @since Series 60 2.6
       
    72      **/
       
    73     CAIAgendaPluginEngineImpl(MPluginDataChangeObserver& aDataChangeObserver, TObserverType aObserverType);
       
    74 
       
    75  public:  // From MCalenEngineListener
       
    76     /**
       
    77      * ?member_description.
       
    78      * @since Series 60 2.6
       
    79      **/
       
    80     void OpenDatabaseCompleted(void);
       
    81 
       
    82     /**
       
    83      * ?member_description.
       
    84      * @since Series 60 2.6
       
    85      **/
       
    86     void GetEntriesCompleted(void);
       
    87 
       
    88     /**
       
    89      * ?member_description.
       
    90      * @since Series 60 2.6
       
    91      **/
       
    92     void DoGetEntriesCompletedL(void);
       
    93 
       
    94     /**
       
    95      * ?member_description.
       
    96      * @since Series 60 2.6
       
    97      **/
       
    98     void GetTodosCompleted(void);
       
    99 
       
   100     /**
       
   101      * ?member_description.
       
   102      * @since Series 60 2.6
       
   103      **/
       
   104     void GetFutureEventCompleted(void);
       
   105 
       
   106     /**
       
   107      * ?member_description.
       
   108      * @since S60 3.1
       
   109      **/
       
   110     void GetCalendarDataCompleted(void);
       
   111 
       
   112     /**
       
   113      * ?member_description.
       
   114      * @since S60 3.0
       
   115      **/
       
   116     void HandleError(TInt aError);
       
   117 
       
   118  public:  // From MCalSvrAgendaUpdateListener
       
   119     /**
       
   120      * ?member_description.
       
   121      * @since Series 60 2.6
       
   122      **/
       
   123     void CalendarServerInitialized(void);
       
   124 
       
   125 public:  // From MPropertyChangeHandler
       
   126     /**
       
   127      * ?member_description.
       
   128      * @since Series 60 3.0
       
   129      **/
       
   130     void HandlePropertyChange(const TUid& /*aCategory*/, const TUint& /*aKey*/, const TInt& /*aValue*/);
       
   131     
       
   132  private: //from MCalFileChangeObserver
       
   133      /*
       
   134       * The callback that will recieve 1 or more file change notifications
       
   135       * @param aCalendarInfoChangeEntries Array of CCalFileChangeInfo
       
   136       */
       
   137     void CalendarInfoChangeNotificationL(RPointerArray<CCalFileChangeInfo>& aCalendarInfoChangeEntries);
       
   138 
       
   139  private:  // New functions
       
   140    
       
   141     /**
       
   142      * ?member_description.
       
   143      * @since S60 3.1
       
   144      **/
       
   145     void DoGetCalendarDataCompletedL(void);
       
   146    
       
   147     /**
       
   148      * ?member_description.
       
   149      * @since Series 60 2.6
       
   150      **/
       
   151     void OpenDataBase(void);
       
   152 
       
   153     /**
       
   154      * ?member_description.
       
   155      * @since Series 60 2.6
       
   156      **/
       
   157     void DoOpenDataBaseL(void);
       
   158 
       
   159     /**
       
   160      * ?member_description.
       
   161      * @since Series 60 2.6
       
   162      **/
       
   163     void GetTodayData(void);
       
   164 
       
   165     /**
       
   166      * ?member_description.
       
   167      * @since Series 60 2.6
       
   168      **/
       
   169     void DoGetTodayDataL(void);
       
   170 
       
   171     /**
       
   172      * ?member_description.
       
   173      * @since Series 60 2.6
       
   174      **/
       
   175     void GetFutureData(void);
       
   176 
       
   177     /**
       
   178      * ?member_description.
       
   179      * @since Series 60 2.6
       
   180      **/
       
   181     void DoGetFutureDataL(void);
       
   182 
       
   183     /**
       
   184      * ?member_description.
       
   185      * @since Series 60 2.6
       
   186      * @return ?description
       
   187      **/
       
   188     TBool HasEventsForTodayL(void);
       
   189 
       
   190     /**
       
   191      * ?member_description.
       
   192      * @since Series 60 2.6
       
   193      **/
       
   194     void NotifyObserverAndCloseDB(void);
       
   195 
       
   196     /**
       
   197      * ?member_description.
       
   198      * @since Series 60 2.6
       
   199      * @param ?arg1 ?description
       
   200      * @return ?description
       
   201      **/
       
   202     static TInt EnvironmentChangeCallBack(TAny* aPtr);
       
   203 
       
   204     /**
       
   205      * ?member_description.
       
   206      * @since Series 60 2.6
       
   207      **/
       
   208     void CloseCalendarEngine(void);
       
   209 
       
   210     /**
       
   211      * ?member_description.
       
   212      * @since Series 60 2.6
       
   213      **/
       
   214     void RemoveExpiredEntries(void);
       
   215 
       
   216     /**
       
   217      * ?member_description.
       
   218      * @since Series 60 2.6
       
   219      **/
       
   220     void DoRemoveExpiredEntriesL(void);
       
   221 
       
   222     /**
       
   223      * ?member_description.
       
   224      * @since Series 60 2.6
       
   225      **/
       
   226     void SetTimerForNextExpiringEventL(void);
       
   227 
       
   228     /** 
       
   229      * Find the difference (in minutes) between meeting in aIndex and next meeting (if exist) with different start time.
       
   230      * @since S60 3.1
       
   231      * @param aIndex  Index of the current meeting.
       
   232      * @param aDifference Reference to the result.
       
   233      **/
       
   234     void DiffToNextEventL(const TInt aIndex, TTimeIntervalMinutes& aDifference);
       
   235 
       
   236     /**
       
   237      * ?member_description.
       
   238      * @since Series 60 2.6
       
   239      * @param ?arg1 ?description
       
   240      **/
       
   241     void StateMachine(void);
       
   242 
       
   243  protected: // for CAIAgendaPluginEngine
       
   244     /**
       
   245      * ?member_description.
       
   246      * @since S60 3.0
       
   247      **/
       
   248     void SafeRefresh(void);
       
   249 
       
   250  private:  // From MEventExpirationObserver
       
   251     /**
       
   252      * Callback for iEventExpirationTimer.
       
   253      * @since Series 60 2.6
       
   254      **/
       
   255     static TInt EventExpiredCallBack(TAny* aPtr);
       
   256 
       
   257     /**
       
   258      * Callback for iRefreshTimer.
       
   259      * @since Series 60 3.0
       
   260      **/
       
   261     static TInt RefreshTimerCallBack(TAny* aPtr);
       
   262 
       
   263  private:  // Data members
       
   264     // Calendar agenda engine
       
   265     CCalenEngine* iCalendarEngine;
       
   266 
       
   267     // ?one_line_short_description_of_data
       
   268     RPointerArray<CCalInstance> iInstanceArray;
       
   269 
       
   270     // Calendar server session
       
   271     RCalSvrSession iSession;
       
   272 
       
   273     // ?one_line_short_description_of_data
       
   274     MPluginDataChangeObserver& iDataChangeObserver;
       
   275 
       
   276     // ?one_line_short_description_of_data
       
   277     TObserverType iObserverType;
       
   278 
       
   279     // ?one_line_short_description_of_data
       
   280     CEnvironmentChangeNotifier* iEnvironmentChangeNotifier;
       
   281 
       
   282     // ?one_line_short_description_of_data
       
   283     enum TDBState
       
   284     {
       
   285         EDBOffline,
       
   286         EDBInitializing,
       
   287         EDBInitialized,
       
   288         EDBOpening,
       
   289         EDBOpen,
       
   290         EDBReading
       
   291     };
       
   292 
       
   293     // ?one_line_short_description_of_data
       
   294     enum TFetchState
       
   295     {
       
   296         EFetchNormal,
       
   297         EFetchFuture
       
   298     };
       
   299 
       
   300     // ?one_line_short_description_of_data
       
   301     TDBState iDBState;
       
   302 
       
   303     // ?one_line_short_description_of_data
       
   304     TFetchState iFetchState;
       
   305 
       
   306     // ?one_line_short_description_of_data
       
   307     TBool iNeedsUpdate;
       
   308 
       
   309     // ?one_line_short_description_of_data
       
   310     TBool iHadEvents;
       
   311 
       
   312     // Timer for event expirations
       
   313     CEventExpirationTimer* iExpirationTimer;
       
   314 
       
   315     // timer for SafeRefresh
       
   316     CEventExpirationTimer* iRefreshTimer;
       
   317 
       
   318     // ?one_line_short_description_of_data
       
   319     CPropertyObserver* iEventChangeObserver;
       
   320 
       
   321     // ?one_line_short_description_of_data
       
   322     CPropertyObserver* iTodoChangeObserver;
       
   323 
       
   324     // Counter for SafeRefresh calls
       
   325     TUint iRefreshCounter;
       
   326     
       
   327     // Calendar session for receving notification
       
   328     CCalSession* iCalendarSession;
       
   329 
       
   330 };
       
   331 
       
   332 #endif  // CAIAGENDAPLUGINENGINEIMPL_H
       
   333 
       
   334 
       
   335 // End of File