bluetoothengine/bthid/common/inc/bthidcenrepwatcher.h
changeset 0 f63038272f30
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     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: 
       
    15  *       This class handles CenRep notifications
       
    16  *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef BTHIDCENREPWATCHER_H
       
    21 #define BTHIDCENREPWATCHER_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32std.h>
       
    25 #include <cenrepnotifyhandler.h>
       
    26 
       
    27 // CLASS DECLARATION
       
    28 
       
    29 class MBtHidCenRepObserver
       
    30     {
       
    31 public:
       
    32     virtual void CenRepDataChanged(TUid& aUid, TUint32 aKey) = 0;
       
    33     };
       
    34 
       
    35 class CRepository;
       
    36 class CTimeOutTimer;
       
    37 
       
    38 /**
       
    39  * The class to handle CenRep notifications
       
    40  */
       
    41 NONSHARABLE_CLASS(CBtHidCenRepWatcher) : public CBase,
       
    42         public MCenRepNotifyHandlerCallback
       
    43     {
       
    44 public:
       
    45     // Constructors and destructor
       
    46 
       
    47     /**
       
    48      * Two-phased constructor.
       
    49      * @param aUid The Uid of the repository we want to use.
       
    50      * @param aObserver The parent who is interested in relevant CenRep changes
       
    51      */
       
    52     static CBtHidCenRepWatcher* NewL(TUid aUid,
       
    53             MBtHidCenRepObserver& aObserver);
       
    54 
       
    55     /**
       
    56      * Destructor.
       
    57      */
       
    58     virtual ~CBtHidCenRepWatcher();
       
    59 
       
    60 protected:
       
    61     // From MCenRepNotifyHandlerCallback
       
    62 
       
    63     /**
       
    64      * This callback method is used to notify the client about
       
    65      * changes in keys when the whole repository is listened for.
       
    66      *
       
    67      * Note: It is not guaranteed that a notification will be received
       
    68      *       for all keys, if multiple keys are changed in rapid succession
       
    69      *       by multiple threads or when the whole repository is reset,
       
    70      *       therefore only listen for whole repository if this is not an issue.
       
    71      *
       
    72      * @param aId Id of the key that has changed. If multiple keys were changed by
       
    73      *            whole repository reset, value will be KInvalidNotificationId.
       
    74      */
       
    75     void HandleNotifyGeneric(TUint32 aId);
       
    76 
       
    77     /**
       
    78      * This callback method is used to notify the client about errors
       
    79      * in the handler. Any error in handling causes the handler to stop
       
    80      * handling any more notifications. Handling can be restarted with
       
    81      * a call to aHandler->StartListeningL(), if the error is non-fatal.
       
    82      * However, be careful to trap any errors from this call if this is done.
       
    83      *
       
    84      * @param aId Id of the key this instance listens for or if notifications for
       
    85      *            whole repository are listened, could also be KInvalidNotificationId.
       
    86      * @param aError Error code.
       
    87      * @param aHandler Pointer to the handler instance. 
       
    88      *                 This pointer can be used to identify the handler or restart the listening.
       
    89      */
       
    90     void HandleNotifyError(TUint32 aId, TInt aError,
       
    91             CCenRepNotifyHandler* aHandler);
       
    92 
       
    93 public:
       
    94     // New functions
       
    95 
       
    96     /**
       
    97      * Disable notifications
       
    98      */
       
    99     void DisableNotifications();
       
   100 
       
   101     /**
       
   102      * Enable notifications
       
   103      */
       
   104     void EnableNotifications();
       
   105 
       
   106 private:
       
   107 
       
   108     /**
       
   109      * Constructor
       
   110      * @param aUid The Uid of the repository.
       
   111      * @param aObserver The instance which receives interested CenRep changes
       
   112      */
       
   113     CBtHidCenRepWatcher(TUid aUid, MBtHidCenRepObserver& aObserver);
       
   114 
       
   115     /**
       
   116      * 2nd phase constructor
       
   117      * @param aUid The Uid of the repository.
       
   118      */
       
   119     void ConstructL();
       
   120 
       
   121 private:
       
   122     // DATA
       
   123     CCenRepNotifyHandler* iNotifier;
       
   124     CRepository* iSession;
       
   125     TUid iUid;
       
   126     MBtHidCenRepObserver& iObserver;
       
   127     TBool iNotificationsEnabled;
       
   128     };
       
   129 
       
   130 #endif      // BTHIDCENREPWATCHER_H
       
   131 // End of File