|
1 /* |
|
2 * Copyright (c) 2002-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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CFCONTEXTSUBSCRIPTIONIMPL_H |
|
20 #define C_CFCONTEXTSUBSCRIPTIONIMPL_H |
|
21 |
|
22 #include "cfcontextsubscription.h" |
|
23 |
|
24 // FORWARD DECLARATIONS |
|
25 |
|
26 class MCFContextSubscriptionListener; |
|
27 class CCFContextQueryImpl; |
|
28 class CCFContextObject; |
|
29 class CCFContextDataObject; |
|
30 class RWriteStream; |
|
31 |
|
32 /** |
|
33 * Subscription for observing context value changes for certain |
|
34 * context type or a subtree of context types coming from certain |
|
35 * source or all sources. |
|
36 * |
|
37 * Information about context changes will be sent to object implementing |
|
38 * <code>MCFListener</code>-interface. |
|
39 * |
|
40 * @since S60 5.0 |
|
41 * @lib cfservices.lib |
|
42 */ |
|
43 NONSHARABLE_CLASS( CCFContextSubscriptionImpl ): public CCFContextSubscription |
|
44 { |
|
45 public: |
|
46 |
|
47 /** |
|
48 * Two phased construction. |
|
49 * |
|
50 * @since S60 5.0 |
|
51 * @param None. |
|
52 * @return CCFContextSubscriptionImpl* |
|
53 */ |
|
54 IMPORT_C static CCFContextSubscriptionImpl* NewL(); |
|
55 IMPORT_C static CCFContextSubscriptionImpl* NewLC(); |
|
56 |
|
57 /** |
|
58 * Two phased construction with parameters. |
|
59 * |
|
60 * @since S60 5.0 |
|
61 * @param aStream Stream where to initialize. |
|
62 * @return CCFContextSubscriptionImpl* |
|
63 */ |
|
64 IMPORT_C static CCFContextSubscriptionImpl* NewL ( |
|
65 RReadStream& aStream); |
|
66 IMPORT_C static CCFContextSubscriptionImpl* NewLC ( |
|
67 RReadStream& aStream); |
|
68 |
|
69 // Destructor. |
|
70 ~CCFContextSubscriptionImpl(); |
|
71 |
|
72 public: // From base classes |
|
73 |
|
74 // @see CCFContextSubscription |
|
75 void SetContextTypeL( const TDesC& aContextType ); |
|
76 |
|
77 // @see CCFContextSubscription |
|
78 const TDesC& ContextType() const; |
|
79 |
|
80 // @see CCFContextSubscription |
|
81 void SetContextSourceL( const TDesC& aSource ); |
|
82 |
|
83 // @see CCFContextSubscription |
|
84 const TDesC& ContextSource() const; |
|
85 |
|
86 // @see CCFContextSubscription |
|
87 TBool SubTypeMatch() const; |
|
88 |
|
89 // @see CCFContextSubscription |
|
90 void SetSubTypeMatch( TBool aMatchSubTypes ); |
|
91 |
|
92 // @see CCFContextSubscription |
|
93 TBool OnlyChangesIndicated() const; |
|
94 |
|
95 // @see CCFContextSubscription |
|
96 void SetOnlyChangesIndicated( TBool aIndicateChangesOnly ); |
|
97 |
|
98 // @see CCFContextSubscription |
|
99 void SetDataObjectEnabled( TBool aEnabled ); |
|
100 |
|
101 // @see CCFContextSubscription |
|
102 TBool DataObjectEnabled() const; |
|
103 |
|
104 public: // New methods |
|
105 |
|
106 /** |
|
107 * Internalizes object. |
|
108 * |
|
109 * @since S60 5.0 |
|
110 * @param aStream Stream from which to internalize. |
|
111 * @return None. |
|
112 */ |
|
113 IMPORT_C void InternalizeL( RReadStream& aStream ); |
|
114 |
|
115 /** |
|
116 * Externalizes object. |
|
117 * |
|
118 * @since S60 5.0 |
|
119 * @param aStream Stream where to externalize. |
|
120 * @return None |
|
121 */ |
|
122 IMPORT_C void ExternalizeL( RWriteStream& aStream ); |
|
123 |
|
124 /** |
|
125 * Gets object size in bytes. |
|
126 * |
|
127 * @since S60 5.0 |
|
128 * @param None |
|
129 * @return TInt |
|
130 */ |
|
131 IMPORT_C TInt Size() const; |
|
132 |
|
133 /** |
|
134 * Returns subscriber of this subscription. |
|
135 * |
|
136 * @since S60 5.0 |
|
137 * @param None. |
|
138 * @return MCFContextSubscriptionListener& |
|
139 */ |
|
140 IMPORT_C MCFContextSubscriptionListener& SubscriptionListener() const; |
|
141 |
|
142 /** |
|
143 * Sets a subscriber for this subscription. |
|
144 * |
|
145 * @since S60 5.0 |
|
146 * @param aListener Call back to subscriber. |
|
147 * @return None. |
|
148 */ |
|
149 IMPORT_C void SetSubscriptionListener( |
|
150 MCFContextSubscriptionListener& aListener ); |
|
151 |
|
152 /** |
|
153 * Evaluates context change event coming from data manager and sends |
|
154 * indication to the subscriber if it matches this subscription. |
|
155 * |
|
156 * @since S60 5.0 |
|
157 * @param aOldContext Previous context. |
|
158 * @param aNewContext Current context. |
|
159 * @return |
|
160 */ |
|
161 IMPORT_C void EvaluateContextChangeL( |
|
162 const CCFContextObject& aNewContext, |
|
163 const CCFContextObject& aOldContext, TBool aValueChanged ) const; |
|
164 |
|
165 /** |
|
166 * Tells whether this instance is the same as the argument. |
|
167 * Comparison is made based on client session, subscribed context source |
|
168 * and type. |
|
169 * |
|
170 * @return ETrue if this instance equals the argument. Otherwise, EFalse. |
|
171 */ |
|
172 IMPORT_C TBool IsSame( |
|
173 const CCFContextSubscriptionImpl& aSubscription) const; |
|
174 |
|
175 /** |
|
176 * Checks if a context type matches with this subscription. |
|
177 * |
|
178 * @since S60 5.0 |
|
179 * @param aContextType Context type to match. |
|
180 * @return ETrue if a match. |
|
181 */ |
|
182 IMPORT_C TBool Matches( const TDesC& aContextType ) const; |
|
183 |
|
184 /** |
|
185 * Checks if a context source and a context type matches |
|
186 * this subscription. |
|
187 * |
|
188 * @since S60 5.0 |
|
189 * @param aContextType Context type to match. |
|
190 * @param aContextSource Context source to match. |
|
191 * @return ETrue if a match. |
|
192 */ |
|
193 IMPORT_C TBool Matches( const TDesC& aContextType, |
|
194 const TDesC& aContextSource ) const; |
|
195 |
|
196 /** |
|
197 * Evaluates context change event coming from data manager and sends |
|
198 * indication to the subscriber if it matches this subscription. |
|
199 * |
|
200 * @since S60 5.0 |
|
201 * @param aNewContext Current context. |
|
202 * @param aData Data object associated with the context. |
|
203 * @param aValueChanged Value changed. |
|
204 * @return |
|
205 */ |
|
206 IMPORT_C void EvaluateContextChangeL( |
|
207 const CCFContextObject& aNewContext, |
|
208 CCFContextDataObject& aData, |
|
209 TBool aValueChanged ) const; |
|
210 |
|
211 private: |
|
212 |
|
213 // Check if a context notification is needed. |
|
214 TBool NotificationNeeded( const CCFContextObject& aNewContext, |
|
215 TBool aValueChanged ) const; |
|
216 |
|
217 private: |
|
218 |
|
219 // C++ constructor |
|
220 CCFContextSubscriptionImpl(); |
|
221 |
|
222 // 2nd phase constructors |
|
223 void ConstructL(); |
|
224 void ConstructL( RReadStream& aStream ); |
|
225 |
|
226 private: |
|
227 |
|
228 /** Context query related to subscription */ |
|
229 CCFContextQueryImpl* iContextQuery; |
|
230 |
|
231 /** A call back interface to the subscriber */ |
|
232 MCFContextSubscriptionListener* iSubscriptionListener; |
|
233 |
|
234 /** Flag indicating whether only changes in context value are indicated */ |
|
235 TBool iOnlyChangesIndicated; |
|
236 |
|
237 /** Flag indicating that subscriber wants also data objects */ |
|
238 TBool iDataObjectEnabled; |
|
239 }; |
|
240 |
|
241 #endif |