1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/featuremgmt/featuremgr/inc/featurenotifier.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,210 @@
1.4 +/*
1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +#ifndef FEATURENOTIFIER_H
1.24 +#define FEATURENOTIFIER_H
1.25 +
1.26 +// INCLUDES
1.27 +#include <e32svr.h>
1.28 +#include <babitflags.h>
1.29 +#include <featmgr/featurecmn.h>
1.30 +
1.31 +// FORWARD DECLARATIONS
1.32 +class RFeatMgrClient;
1.33 +
1.34 +// DEFINES
1.35 +
1.36 +// CLASS DECLARATION
1.37 +
1.38 +// CONSTANTS
1.39 +
1.40 +/**
1.41 + Class provides a callback interface for handling notifification of
1.42 + changes in features. The client derives a class from this interface
1.43 + and implements the HandleNotifyChange-methods that interest it.
1.44 +
1.45 + Feature Notifier API consists of the classes CFeatureNotifier and
1.46 + MFeatureObserver. TFeatureEntry and TFeatureChangeType are defined
1.47 + in featurecmn.h.
1.48 +@publishedPartner
1.49 +@released
1.50 +*/
1.51 +class MFeatureObserver
1.52 + {
1.53 + public:
1.54 + /**
1.55 + This callback method is used to notify the client about
1.56 + the change in a feature.
1.57 +
1.58 + @param aType Type of the change.
1.59 + @param aFeature The changed feature. Note that although aFeature is a
1.60 + TFeatureEntry object, only the iFeatureID field is set by the server.
1.61 +
1.62 + @see TFeatureChangeType
1.63 + @see TFeatureEntry
1.64 + */
1.65 + virtual void HandleNotifyChange( TFeatureChangeType aType, TFeatureEntry aFeature ) = 0;
1.66 +
1.67 + /**
1.68 + This callback method is used to notify the client about errors
1.69 + in the CFeatureNotifier. Any error in the notifier causes the notifier
1.70 + to stop handling of notifications. Handling can be restarted with
1.71 + a call to aNotifier->NotifyRequest(), if the error is non-fatal.
1.72 +
1.73 + @param aError One of the Symbian OS error codes.
1.74 + */
1.75 + virtual void HandleNotifyError( TInt aError ) = 0;
1.76 + };
1.77 +
1.78 +/**
1.79 + Active object for obtaining notification of changes in features.
1.80 + Feature Notifier automatically resubscribes to the notification and
1.81 + fetches the status and data of the changed feature.
1.82 +
1.83 + Feature Notifier API consists of the classes CFeatureNotifier and
1.84 + MFeatureObserver. The array RFeatureUidArray is defined in featurecmn.h.
1.85 + The user of this class needs to implement MFeatureObserver interface
1.86 + methods to receive notifications.
1.87 +
1.88 +@publishedPartner
1.89 +@released
1.90 +*/
1.91 +NONSHARABLE_CLASS(CFeatureNotifier) : public CActive
1.92 + {
1.93 + public:
1.94 + /**
1.95 + This is a two-phase constructor method that is used to create a new
1.96 + instance for listening to the changes in features.
1.97 +
1.98 + @param aObserver A reference to an observer instance.
1.99 + @return A pointer to a new instance of the CFeatureNotifier class.
1.100 +
1.101 + @leave Any One of the Symbian OS system-wide error codes
1.102 + */
1.103 + IMPORT_C static CFeatureNotifier* NewL( MFeatureObserver& aObserver );
1.104 +
1.105 + /**
1.106 + Destructor.
1.107 + */
1.108 + IMPORT_C ~CFeatureNotifier();
1.109 +
1.110 + /**
1.111 + This method is used to request notification for one feature.
1.112 +
1.113 + @param aFeature Feature UID.
1.114 + @return KErrAlreadyExists if a notification has already been requested
1.115 + and is outstanding. Otherwise one of the Symbian OS error
1.116 + codes.
1.117 +
1.118 + @see CActive
1.119 + */
1.120 + IMPORT_C TInt NotifyRequest( TUid aFeature );
1.121 +
1.122 + /**
1.123 + This method is used to request notification for a subset of features.
1.124 +
1.125 + @param aFeatures A reference to a client owned UID-array
1.126 + of requested features.
1.127 + @return KErrAlreadyExists if a notification has already been requested
1.128 + and is outstanding. Otherwise one of the Symbian OS error codes.
1.129 +
1.130 + @see RFeatureUidArray
1.131 + @see CActive
1.132 + */
1.133 + IMPORT_C TInt NotifyRequest( RFeatureUidArray& aFeatures );
1.134 +
1.135 + /**
1.136 + Cancels notification request for one feature.
1.137 +
1.138 + @param aFeatures Feature UID.
1.139 + @return KErrNotFound if the feature does not exist
1.140 + in the list of previously requested features.
1.141 + Otherwise one of the Symbian error codes.
1.142 + */
1.143 + IMPORT_C TInt NotifyCancel( TUid aFeature );
1.144 +
1.145 + /**
1.146 + Cancels notification requests for all features.
1.147 +
1.148 + @return One of the Symbian OS system-wide error codes.
1.149 + */
1.150 + IMPORT_C TInt NotifyCancelAll();
1.151 +
1.152 + private:
1.153 + /**
1.154 + C++ default constructor.
1.155 + */
1.156 + CFeatureNotifier();
1.157 +
1.158 + /**
1.159 + @param aObserver A reference to an observer instance.
1.160 + */
1.161 + CFeatureNotifier( MFeatureObserver& aObserver );
1.162 +
1.163 + /**
1.164 + By default Symbian OS constructor is private.
1.165 + */
1.166 + void ConstructL();
1.167 +
1.168 + protected:
1.169 + /**
1.170 + Implements CActive.
1.171 + */
1.172 + void RunL();
1.173 +
1.174 + /**
1.175 + Implements CActive.
1.176 + @param aError The error returned.
1.177 + @return One of the Symbian OS system-wide error codes.
1.178 + */
1.179 + TInt RunError( TInt aError );
1.180 +
1.181 + /**
1.182 + Implements CActive.
1.183 + */
1.184 + void DoCancel();
1.185 +
1.186 + private:
1.187 + /**
1.188 + A reference to the callback/observer instance.
1.189 + */
1.190 + MFeatureObserver& iObserver;
1.191 +
1.192 + /** Holds UID-array of features being requested. */
1.193 + RFeatureUidArray iFeatures;
1.194 +
1.195 + /** Server sets changed feature before signaling. */
1.196 + TUid iFeatureChanged;
1.197 +
1.198 + // Feature Manager server client
1.199 + RFeatMgrClient* iFeatMgrClient;
1.200 +
1.201 +
1.202 + public: // @internalComponent APIs
1.203 + // These APIs are for internal testing purposes only.
1.204 +
1.205 + IMPORT_C TInt NumberOfNotifyFeatures();
1.206 +
1.207 + IMPORT_C TInt CountAllocCells();
1.208 + };
1.209 +
1.210 +
1.211 +#endif // FEATURENOTIFIER_H
1.212 +
1.213 +// End of File