landmarksui/uicontrols/inc/clmkcentralrepository.h
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2006 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:    LandmarksUi Content File -    This class listens to the changes in the Central Repository
       
    15 *                for specific keys and notifies the observer.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 #ifndef __CLMKCENTRALREPOSITORY_H__
       
    26 #define __CLMKCENTRALREPOSITORY_H__
       
    27 
       
    28 //  System Includes
       
    29 #include <e32base.h>
       
    30 
       
    31 // User Includes
       
    32 #include "mlmkcentralrepositoryobserver.h"
       
    33 
       
    34 // Forward Declarations
       
    35 class CRepository;
       
    36 
       
    37 // Constant Declarations
       
    38 
       
    39 // Class Definition
       
    40 /**
       
    41  * This class listens to the change in value of specified key, in the central repository.
       
    42  * When there is any change, it notifies to the observer.
       
    43  * This class can also be used, without notification, just to get key values from
       
    44  * central repository.
       
    45  * To make it start listening on a specific key value change, create an instance of
       
    46  * this class using the argumented NewL/NewLC functions.
       
    47  * A request can only be cancelled, when the object of this class
       
    48  * is deleted.
       
    49  */
       
    50 NONSHARABLE_CLASS( CLmkCentralRepository ) : public CActive
       
    51 	{
       
    52 	public:
       
    53 		/**
       
    54          * Creates new central repository listener
       
    55          *
       
    56 		 * @return CLmkCentralRepository*	Pointer to self
       
    57          */
       
    58         static CLmkCentralRepository* NewL();
       
    59 
       
    60 
       
    61 		/**
       
    62          * Creates new central repository listener
       
    63          * Leaves the object on the Clean up stack
       
    64    		 *
       
    65 		 * @return CLmkCentralRepository*	Pointer to self
       
    66          */
       
    67         static CLmkCentralRepository* NewLC();
       
    68 
       
    69         /**
       
    70          * Creates new central repository listener
       
    71          *
       
    72          * @param aKey                              Key, on which change is being listened.
       
    73          * @param  aObserver                        Observer, which will be called when
       
    74          *                                          there is any change in the specified key
       
    75          *                                          value.
       
    76 		 * @return CLmkCentralRepository*	Pointer to self
       
    77          */
       
    78         static CLmkCentralRepository* NewL( TUint32 aKey ,
       
    79         					MLmkCentralRepositoryObserver*	aObserver);
       
    80 
       
    81 
       
    82 		/**
       
    83          * Creates new central repository listener
       
    84          * Leaves the object on the Clean up stack
       
    85          *
       
    86          * @param aKey                              Key, on which change is being listened.
       
    87          * @param  aObserver                        Observer, which will be called when
       
    88          *                                          there is any change in the specified key
       
    89          *                                          value.
       
    90 		 * @return CLmkCentralRepository*	Pointer to self
       
    91          */
       
    92         static CLmkCentralRepository* NewLC( TUint32 aKey ,
       
    93         					MLmkCentralRepositoryObserver*	aObserver);
       
    94 
       
    95 
       
    96 		/**
       
    97 		 * Destructor
       
    98 		 */
       
    99 		~CLmkCentralRepository ();
       
   100 
       
   101 	public:
       
   102 
       
   103 		/**
       
   104 		 * Start notification from the Central repository server for any changes in the
       
   105 		 * in the specified key value.
       
   106 		 *
       
   107 		 * @panic             Panics with code KLmkPanicNullMember, when no observer
       
   108 		 *                    is set.
       
   109 		 *                    Panics with code KLmkKeyNotSet, when no key is set.
       
   110 		 *
       
   111 		 * @return TInt       KErrNone if successful, KErrAlreadyExists if there is already
       
   112 		 *                    a notification from this CRepository on this setting, or an
       
   113 		 *                    error from IPC or server side resource allocation failure.
       
   114 		 */
       
   115 		TInt StartNotification();
       
   116 
       
   117 		/**
       
   118 		* Gets the value for the specified key, from central repository.
       
   119 		* @param        aKey    Key for which, value is being fetched.
       
   120 		* @param[out]aValue  Fetched value from central repository.
       
   121 		*/
       
   122 		TInt GetKeyValue(TUint32 aKey, TInt& aValue);
       
   123 
       
   124     protected:
       
   125         /**
       
   126          * Inherited from CActive
       
   127          */
       
   128         void RunL();
       
   129 
       
   130         /**
       
   131          * Inherited from CActive
       
   132          */
       
   133         void DoCancel();
       
   134 
       
   135 	private:
       
   136 		/**
       
   137  		 * Constructor
       
   138 		 */
       
   139 		CLmkCentralRepository( TUint32 aKey ,
       
   140         					   MLmkCentralRepositoryObserver*	aObserver);
       
   141 
       
   142 		/**
       
   143 		 * Second Phase Constructor
       
   144 		 */
       
   145 		void ConstructL();
       
   146 			/**
       
   147 		 * Second Phase Constructor
       
   148 		 */
       
   149 		void Construct2L();
       
   150 
       
   151 
       
   152 	private:
       
   153 
       
   154 		/**
       
   155 	     * Key, which is being observed for any change, in its value.
       
   156 	     */
       
   157 		const TUint32 iKey;
       
   158 	    /**
       
   159 	     * Reference to the Settings observer
       
   160 	     */
       
   161 		MLmkCentralRepositoryObserver*     iObserver;
       
   162 
       
   163 		/**
       
   164 		 * Reference to the Central repository object
       
   165 		 *
       
   166 		 * Owns
       
   167 		 */
       
   168 		CRepository*                    iRepository;
       
   169 	};
       
   170 
       
   171 
       
   172 #endif //__CLMKCENTRALREPOSITORY_H__