contextengine/plugins/calendarplugin/inc/CalendarContextPlugin.h
changeset 0 c53acadfccc6
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2007-2009 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 *
       
    16 */
       
    17 
       
    18 #ifndef __CCALENDARCONTEXTPLUGIN_H__
       
    19 #define __CCALENDARCONTEXTPLUGIN_H__
       
    20 
       
    21 //  INCLUDES 
       
    22 #include <contextplugin.h>
       
    23 #include <calprogresscallback.h>
       
    24 
       
    25 #include <mdesession.h>
       
    26 #include "mdeharvestersession.h"
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CCalInstanceView;
       
    33 class CCalEntry;
       
    34 class CCalSession;
       
    35 
       
    36 const TInt KInitRetryTimeout = 5000000; //5 sec
       
    37 const TInt KMaxRetryCount = 6; // retry for up to 30 sec
       
    38 
       
    39 // CLASS DECLARATION ===========================================================
       
    40 
       
    41 /**
       
    42 *  Main class of the plugin.
       
    43 */
       
    44 class CCalendarContextPlugin : public CContextPlugin,
       
    45                                public MMdESessionObserver,
       
    46                                public MCalProgressCallBack
       
    47       {
       
    48     public:
       
    49     	/** 
       
    50     	* Static constructor
       
    51         * @return           - pointer to the new object
       
    52     	*/
       
    53         static CCalendarContextPlugin* NewL();
       
    54 
       
    55     	/** 
       
    56     	* Destructor
       
    57     	*/
       
    58         virtual ~CCalendarContextPlugin();
       
    59         
       
    60     // CContextPlugin functions
       
    61         void Init( MContextPluginObserver& aObserver );
       
    62         void ContextSnapshot( MContextPluginObserver& aObserver,
       
    63                                CHarvesterData& aHD );
       
    64         void ContextSnapshot( MContextPluginObserver&    aObserver,
       
    65                                RPointerArray<CHarvesterData>& aHDArray );
       
    66                                
       
    67     	void SetMdeSession( CMdESession& aSession );                           
       
    68 
       
    69     // MMdESessionObserver functions, not used
       
    70         virtual void HandleSessionOpened( CMdESession& aSession, TInt aError );
       
    71         virtual void HandleSessionError( CMdESession& aSession, TInt aError );
       
    72         
       
    73     // MCalProgressCallBack functions, not used
       
    74         virtual void Progress( TInt aPercentageCompleted );
       
    75         virtual void Completed( TInt aError );
       
    76         virtual TBool NotifyProgress();
       
    77 
       
    78     private:
       
    79     	/** 
       
    80     	* C++ constructor
       
    81     	*/
       
    82         CCalendarContextPlugin();
       
    83 
       
    84     	/** 
       
    85     	* 2nd phase construction
       
    86     	*/
       
    87         void ConstructL(); // second-phase constructor
       
    88 
       
    89     	/** 
       
    90     	* Adds the calendar metadata to the MdEObject
       
    91     	* @param aMdEObject - the CMdEObject to add the metadata to
       
    92     	*/
       
    93         void AddMetaDataL( CMdEObject& aMdEObject ) const;
       
    94             
       
    95 
       
    96     	/** 
       
    97     	* Gets a time property value from MDS
       
    98     	* @param aNameSpace - reference to the namespace
       
    99     	* @param aProp      - reference to the property name
       
   100     	* @param aMdEObject - reference to the CMdEObject to be examined
       
   101         * @return           - value of the property, leaves if it does not exist
       
   102     	*/
       
   103         TTime GetTimeMdEPropL( const TDesC& aNameSpace,
       
   104                                const TDesC& aProp,
       
   105                                CMdEObject&  aMdEObject ) const;
       
   106 
       
   107     	/** 
       
   108     	* Gets a text property value from MDS
       
   109     	* @param aNameSpace - reference to the namespace
       
   110     	* @param aProp      - reference to the property name
       
   111     	* @param aMdEObject - reference to the CMdEObject to be examined
       
   112         * @return           - value of the property, NULL if it does not exist
       
   113     	*/
       
   114         HBufC* GetTextMdEPropLC( const TDesC& aNameSpace,
       
   115                                  const TDesC& aProp,
       
   116                                  CMdEObject&  aMdEObject ) const;
       
   117 
       
   118         
       
   119         /**
       
   120          * Initialise calendar serve instance
       
   121          *
       
   122          * @since S60 v5.0
       
   123          * @param aRetry - is retry initialisation
       
   124          */
       
   125         void OpenViewL(TBool aRetry = EFalse);
       
   126         
       
   127         /**
       
   128          * Callback for initialisation retry
       
   129          *
       
   130          * @since S60 v5.0
       
   131          */
       
   132         static TInt InitRetryCallback(TAny* aAny);
       
   133         
       
   134 		 /**
       
   135          * Starts initialisation retry
       
   136          *
       
   137          * @since S60 v5.0
       
   138          */
       
   139         void StartRetryL();
       
   140 		
       
   141     private:
       
   142         
       
   143         CCalInstanceView* iCalInstanceView;    ///< owned
       
   144         CMdESession* iMdeSession;            ///< NOT owned
       
   145         CCalSession* iCalSession; ///< owned
       
   146         TBool iCalInstanceViewCompleted;
       
   147         CPeriodic* iInitTimer;
       
   148         TInt iRetryCount;
       
   149     };
       
   150 #endif // __CCALENDARCONTEXTPLUGIN_H__