phoneapp/phoneuiutils/inc/cphonecenrepproxy.h
changeset 0 5f000ab63145
child 21 92ab7f8d0eab
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     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:  Proxy for the connection to central repository.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __CPHONECENREPPROXY_H
       
    20 #define __CPHONECENREPPROXY_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <coemain.h>
       
    24 #include <e32base.h>
       
    25 #include <centralrepository.h>
       
    26 #include <cenrepnotifyhandler.h>
       
    27 
       
    28 // CONSTANTS
       
    29 class MPhoneCenRepObserver;
       
    30 class CPhoneCenRepEventHandler;
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class TPhoneCmdParamAppInfo;
       
    34 
       
    35 /**
       
    36 *  CPhoneCenRepProxy is an API used as proxy for phone application to get/set
       
    37 *  and observe central repository settings.
       
    38 *
       
    39 *  How to get some setting?
       
    40 *  ---------------------------
       
    41 *  example code:
       
    42 *  TBuf<100> value;
       
    43 *  CPhoneCenRepProxy::Instance()->GetString( uid, key, value ); 
       
    44 *  
       
    45 *  uid and key should be retrieved from <Module Name>InternalCRKeys.h
       
    46 *  
       
    47 *  How to set any settings
       
    48 *  --------------------------------------
       
    49 *  example code:
       
    50 *  TInt value = 10;
       
    51 *  CPhoneCenRepProxy::Instance()->SetInt( uid, key, value );
       
    52 *
       
    53 *  How to observe any settings
       
    54 *  --------------------------------------
       
    55 *  example code:
       
    56 * 
       
    57 *  class CPhoneSomeManager : private MPhoneCenRepObserver
       
    58 *      {
       
    59 *      ...
       
    60 *      virtual void HandleCenRepChangeL( 
       
    61 *          const TUid& aUid, 
       
    62 *          const TUint aId );
       
    63 *      ....
       
    64 *      }
       
    65 *
       
    66 *  CPhoneSomeManager::SomeFunctionL
       
    67 *      {
       
    68 *      CPhoneCenRepProxy::Instance()->NotifyChangeL( uid1, id1, this );
       
    69 *
       
    70 *      CPhoneCenRepProxy::Instance()->NotifyChangeL( uid2, id2, this );
       
    71 *      }
       
    72 *  
       
    73 *  CPhoneSomeManager::HandleCenRepChangeL( 
       
    74 *      const TUid& aUid,
       
    75 *      const TUint aId )
       
    76 *      {
       
    77 *      switch( aId )
       
    78 *          {
       
    79 *          case ESetting1:
       
    80 *              .... //do something
       
    81 *          case ESetting2:
       
    82 *              .... //do something
       
    83 *          default:
       
    84 *              .... //panic in debug
       
    85 *          }
       
    86 *      }
       
    87 *
       
    88 *  //The CancelAllNotifies() should be always called before destroy the object
       
    89 *  CPhoneSomeManager::~CPhoneSomeManager()
       
    90 *      {
       
    91 *      CPhoneCenRepProxy::Instance()->CancelAllNotifies( this );
       
    92 *      }
       
    93 *
       
    94 */
       
    95 
       
    96 
       
    97 // CLASS DECLARATION
       
    98 
       
    99 class CPhoneCenRepProxy : 
       
   100     public CCoeStatic 
       
   101     {
       
   102     public:  // Constructors and destructor
       
   103         
       
   104         /**
       
   105         * First call initializes the singleton object. Subsequent calls return
       
   106         * created instance.
       
   107         * @return the created instance.
       
   108         */
       
   109         IMPORT_C static CPhoneCenRepProxy* Instance();
       
   110 
       
   111         /**
       
   112         * Destructor.
       
   113         */
       
   114         IMPORT_C virtual ~CPhoneCenRepProxy();
       
   115 
       
   116     public: // New Functions
       
   117 
       
   118         /**
       
   119         * Cancel all requests by the observer. This function should always be 
       
   120         * call before an object is destroyed. During shutdown, this singleton
       
   121         * may be deleted before the classes that observe it. If this happens, the
       
   122         * routine will just return since of requests have already been cancelled.
       
   123         * @param aObserver
       
   124         */
       
   125         IMPORT_C static void CancelAllNotifies( 
       
   126             MPhoneCenRepObserver* aObserver );
       
   127         
       
   128         /**
       
   129         * Set integer value of setting
       
   130         * @param aUid identifing the central repository UID.
       
   131         * @param aId central repository ID.
       
   132         * @param aValue the value associated with the central repository ID
       
   133         */
       
   134         IMPORT_C TInt SetInt( 
       
   135             const TUid& aUid, 
       
   136             const TUint aId,
       
   137             const TInt aValue );
       
   138         
       
   139         /**
       
   140         * Set string value of setting
       
   141         * @param aUid identifing the central repository UID.
       
   142         * @param aId central repository ID.
       
   143         * @param aValue the value associated with the central repository ID
       
   144         * @return refer to SharedDataClient.h for detail explanation
       
   145         */
       
   146         IMPORT_C TInt SetString( 
       
   147             const TUid& aUid, 
       
   148             const TUint aId,
       
   149             const TDesC& aValue );
       
   150             
       
   151         /**
       
   152         * Set real value of setting
       
   153         * @param aUid identifing the central repository UID.
       
   154         * @param aId central repository ID.
       
   155         * @param aValue the value associated with the central repository ID
       
   156         */
       
   157         IMPORT_C TInt SetReal( 
       
   158             const TUid& aUid, 
       
   159             const TUint aId,
       
   160             const TReal aValue );
       
   161         
       
   162         /**
       
   163         * Get integer value of setting
       
   164         * @param aUid identifing the central repository UID.
       
   165         * @param aId central repository ID.
       
   166         * @param aValue the value associated with the central repository ID
       
   167         */
       
   168         IMPORT_C TInt GetInt( 
       
   169             const TUid& aUid, 
       
   170             const TUint aId, 
       
   171             TInt& aValue ) const;
       
   172 
       
   173         /**
       
   174         * Get string value of setting
       
   175         * @param aUid identifing the central repository UID.
       
   176         * @param aId central repository ID.
       
   177         * @param aValue the value associated with the central repository ID
       
   178         */
       
   179         IMPORT_C TInt GetString( 
       
   180             const TUid& aUid, 
       
   181             const TUint aId, 
       
   182             TDes& aValue ) const;
       
   183             
       
   184         /**
       
   185         * Get real value of setting
       
   186         * @param aUid identifing the central repository UID.
       
   187         * @param aId central repository ID.
       
   188         * @param aValue the value associated with the central repository ID
       
   189         */
       
   190         IMPORT_C TInt GetReal( 
       
   191             const TUid& aUid, 
       
   192             const TUint aId, 
       
   193             TReal& aValue ) const;
       
   194             
       
   195         /**
       
   196         * Notify the change of the setting
       
   197         * @param aUid identifing the central repository UID.
       
   198         * @param aId central repository ID.
       
   199         * @param aObserver The pointer to the observer to handle the change 
       
   200         *     notification
       
   201         */
       
   202         IMPORT_C void NotifyChangeL( 
       
   203             const TUid& aUid, 
       
   204             const TUint aId, 
       
   205             MPhoneCenRepObserver* aObserver );
       
   206 
       
   207         /**
       
   208         * Cancel request. If you don't want to receive notification of the 
       
   209         * setting you issued before, call this function.
       
   210         * @param aObserver The observer that have issued request before
       
   211         * @param aId The setting which is to be canceled
       
   212         */
       
   213         IMPORT_C void CancelNotify( 
       
   214             MPhoneCenRepObserver* aObserver,
       
   215             const TUint aId );
       
   216         
       
   217         /**
       
   218         * Return boolean value that states whether or not 
       
   219         * the indicated feature is supported.
       
   220         * @param aFeatureId the feature that is inspected (see values from 
       
   221         *        TelephonyVariant.hrh)
       
   222         * @return whether or not the feature is supported.
       
   223         */
       
   224         IMPORT_C TBool IsTelephonyFeatureSupported( const TInt aFeatureId );
       
   225 
       
   226         /**
       
   227         * Return boolean value that states whether or not 
       
   228         * the indicated feature is supported.
       
   229         * @param aFeatureId the feature that is inspected (see values from 
       
   230         *        PhoneUIVariant.hrh)
       
   231         * @return whether or not the feature is supported.
       
   232         */
       
   233         IMPORT_C TBool IsPhoneUIFeatureSupported( const TInt aFeatureId );
       
   234         
       
   235         /**
       
   236          * Get keys from given value range
       
   237          * @param aUid identifing the central repository UID.
       
   238          * @param aPartial partial key to be found
       
   239          * @param aMask mask for partial key
       
   240          * @param aValues reference to array object for found keys
       
   241          * @return KErrNone if successful, system wide error code otherwise.
       
   242          */
       
   243         IMPORT_C TInt Find(
       
   244         		const TUid& aUid,
       
   245         	    const TUint32 aPartial, 
       
   246         	    const TUint32 aMask,
       
   247         	    RArray<TUint32>& aValues ) const;
       
   248         
       
   249         /**
       
   250         * Fetches values from central repository
       
   251         * @param aAppInfo reference to object containing info for 
       
   252         * application launching
       
   253         * @param aCode ascii value of the pressed key
       
   254         * @param aAppParam application parameter
       
   255         * @param aValuesFetched ETrue if values fetched ok
       
   256         */
       
   257         IMPORT_C void FetchValuesFromCenRepL( TPhoneCmdParamAppInfo& aAppInfo, 
       
   258        		 							TKeyCode aCode,
       
   259        		 							HBufC8* aAppParam, TBool& aValuesFetched );
       
   260 
       
   261 
       
   262     public: // New methods
       
   263 
       
   264         /**
       
   265         * Handle notifications from central repository observers
       
   266         * @param aUid identifing the central repository UID.
       
   267         * @param aId central repository ID.
       
   268         */
       
   269         void HandleNotify( 
       
   270             const TUid& aUid, 
       
   271             const TUint aId );
       
   272 
       
   273     private:
       
   274 
       
   275         /**
       
   276         * Two-phased constructor.
       
   277         * @return new instance.
       
   278         */
       
   279         static CPhoneCenRepProxy* NewL();
       
   280         
       
   281         /**
       
   282         * C++ default constructor.
       
   283         */
       
   284         CPhoneCenRepProxy();
       
   285 
       
   286         /**
       
   287         * By default Symbian OS constructor is private.
       
   288         */
       
   289         void ConstructL();
       
   290 
       
   291     private:
       
   292 
       
   293         /**
       
   294         * Find the observer for specific setting on aUid and aId
       
   295         * @param aUid identifing the central repository UID.
       
   296         * @param aId central repository ID.
       
   297         * @param aFromIndex find next observer interested in this setting after 
       
   298         *               aIndex
       
   299         * @return The index of the observer if it's found and KErrNotFound if 
       
   300         *         not
       
   301         */
       
   302         TInt FindByUidId( 
       
   303             const TUid& aUid, 
       
   304             const TUint aId, 
       
   305             TInt aFromIndex = 0 );
       
   306         
       
   307         /**
       
   308         * Find the specific Observer
       
   309         * @param aObserver The pointer of the observer
       
   310         * @param aId central repository ID.
       
   311         * @return The index in iObserverArray. KErrNotFound if can't find the 
       
   312                   specific observer
       
   313         */
       
   314         TInt FindByObserverId( 
       
   315             const MPhoneCenRepObserver* aObserver,
       
   316             const TUint aId );
       
   317 
       
   318         /**
       
   319         * Finds observer by uid, key and observer.
       
   320         * @param aUid identifing the central repository UID.
       
   321         * @param aId central repository ID.
       
   322         * @param aObserver The pointer of the observer
       
   323         */
       
   324         TInt FindByUidIdObserver( 
       
   325             const TUid& aUid, 
       
   326             const TUint aId, 
       
   327             MPhoneCenRepObserver* aObserver );
       
   328             
       
   329         /**
       
   330         * Returns Telephony variant read-only data.
       
   331         * @return error code.
       
   332         */
       
   333         TInt GetTelephonyVariantData();  
       
   334 
       
   335         /**
       
   336         * Returns PhoneUI variant read-only data.
       
   337         * @return error code.
       
   338         */
       
   339         TInt GetPhoneUIVariantData();  
       
   340 
       
   341         /**
       
   342         * Cancel all request by the observer. 
       
   343         * @param aObserver
       
   344         */
       
   345         void CancelAllObserverNotifies( MPhoneCenRepObserver* aObserver );
       
   346         
       
   347         /**
       
   348         * Cancel all requests from all observers.
       
   349         */
       
   350         void CancelAllNotifies();
       
   351         
       
   352     private:    // Data
       
   353 
       
   354         // Defines information of one observer.
       
   355         class TCenRepObserverTag
       
   356             {
       
   357             public:
       
   358                 TUid iUid;
       
   359                 TUint iId;
       
   360                 MPhoneCenRepObserver* iObserver;
       
   361             };
       
   362 
       
   363         // Owned array of observers.
       
   364         CArrayFixFlat<TCenRepObserverTag>* iObserverArray;
       
   365 
       
   366         // Central Repository event handlers.
       
   367         CPhoneCenRepEventHandler* iCenRepAccessoryEventHandler;
       
   368         CPhoneCenRepEventHandler* iCenRepNetworkEventHandler;
       
   369         CPhoneCenRepEventHandler* iCenRepThemesEventHandler;
       
   370         CPhoneCenRepEventHandler* iCenRepLanguageEventHandler;
       
   371         CPhoneCenRepEventHandler* iCenRepQwertyEventHandler;
       
   372         CPhoneCenRepEventHandler* iCenRepKDRMHelperEventHandler;
       
   373 
       
   374         //Local Telephony variant read-only data.
       
   375         TInt iTelephonyVariantReadOnlyValues;
       
   376 
       
   377         //Local PhoneUI variant read-only data.
       
   378         TInt iPhoneUIVariantReadOnlyValues;
       
   379     };
       
   380 
       
   381 #endif      // __CPHONECENREPPROXY_H
       
   382             
       
   383 // End of File