|
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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_NCD_SUBSCRIPTION_GROUP_H |
|
20 #define C_NCD_SUBSCRIPTION_GROUP_H |
|
21 |
|
22 // For streams |
|
23 #include <s32mem.h> |
|
24 #include <badesca.h> |
|
25 |
|
26 #include "catalogscommunicable.h" |
|
27 #include "ncdstoragedataitem.h" |
|
28 #include "ncdnodeclassids.h" |
|
29 #include "ncdprotocoltypes.h" |
|
30 |
|
31 class CNcdSubscription; |
|
32 class MNcdPreminetProtocolSubscription; |
|
33 class CNcdPurchaseOptionImpl; |
|
34 class CNcdNodeIdentifier; |
|
35 |
|
36 |
|
37 /** |
|
38 * Server side subscriptiongroup implementation |
|
39 * |
|
40 * Server side implementation for purchased or old subscriptions |
|
41 * that have been purchased from one certain dataentity. |
|
42 * |
|
43 * @lib ?library |
|
44 * @since S60 ?S60_version *** for example, S60 v3.0 |
|
45 */ |
|
46 class CNcdSubscriptionGroup : public CCatalogsCommunicable, |
|
47 public MNcdStorageDataItem |
|
48 { |
|
49 |
|
50 public: |
|
51 |
|
52 |
|
53 static CNcdSubscriptionGroup* NewL(); |
|
54 |
|
55 static CNcdSubscriptionGroup* NewLC(); |
|
56 |
|
57 virtual ~CNcdSubscriptionGroup(); |
|
58 |
|
59 |
|
60 /** |
|
61 * This function is called when subscription info should be |
|
62 * constructed from a purchase option. If subscription info |
|
63 * of given subscription is already found, it is overwritten. If not, |
|
64 * it is created. |
|
65 * |
|
66 * Notice that this function internalizes only given subscription info |
|
67 * to this object. This means that entityid, namespace, server uri or |
|
68 * other possible subscriptions are not read into this object. |
|
69 * |
|
70 * @param aData Purchase option used to buy the subscription. Info |
|
71 * for the subscription is read from the purchase option. |
|
72 */ |
|
73 void InternalizeSubscriptionL( |
|
74 const CNcdPurchaseOptionImpl& aData ); |
|
75 |
|
76 |
|
77 /** |
|
78 * This function is called when subscription info should be updated |
|
79 * or constructed from a protocol element. If subscription info |
|
80 * of given subscription is already found, it is updated. If not, |
|
81 * it is created. |
|
82 * |
|
83 * Notice that this function internalizes only given subscription info |
|
84 * to this object. This means that entityid, namespace, server uri or |
|
85 * other possible subscriptions are not read into this object. |
|
86 * |
|
87 * @param aSubscription The data is set in the protocol parser and can |
|
88 * be used to update or create subscription info. |
|
89 */ |
|
90 void InternalizeSubscriptionL( |
|
91 MNcdPreminetProtocolSubscription& aSubscription ); |
|
92 |
|
93 |
|
94 |
|
95 /** |
|
96 * This function is called when a subscription in the group should |
|
97 * be removed. |
|
98 * |
|
99 * @param aPurchaseOptionImpl The purchase option that identifies |
|
100 * the subscription. |
|
101 * @exception KErrNotFound If there is no such subscription. |
|
102 */ |
|
103 void RemoveSubscriptionL( const TDesC& aPurchaseOptionId ); |
|
104 |
|
105 /** |
|
106 * This function is called to set internal flag of the subscription |
|
107 * to inform whether the subscription has been recently updated or |
|
108 * not. |
|
109 * |
|
110 * @param aNewState New state for the recently updated flag. |
|
111 * @param aPurchaseOptionId The purchase option id to identify |
|
112 * the desired subscription. |
|
113 * |
|
114 * @exception KErrNotFound If there is no such subscription. |
|
115 */ |
|
116 void SetRecentlyUpdatedL( TBool aNewState, |
|
117 const TDesC& aPurchaseOptionId ); |
|
118 |
|
119 /** |
|
120 * This function returns the information whether the subscription |
|
121 * has been recently updated or not. |
|
122 * |
|
123 * @param aPurchaseOptionId The purchase option id to identify |
|
124 * the desired subscription. |
|
125 * @return aNewState New state for the recently updated flag. |
|
126 * |
|
127 * @exception KErrNotFound If there is no such subscription. |
|
128 */ |
|
129 TBool RecentlyUpdatedL( const TDesC& aPurchaseOptionId ) const; |
|
130 |
|
131 /** |
|
132 * Removes all subscriptions that are not marked as recently updated. |
|
133 * Returns boolean value to indicate if something was removed. |
|
134 * |
|
135 * @return Boolean value to indicate if something was removed. ETrue |
|
136 * means that something was removed. |
|
137 */ |
|
138 TBool RemoveUnmarkedSubscriptionsAndUnmarkL(); |
|
139 |
|
140 /** |
|
141 * When updating/constructing this object after a subscription |
|
142 * purchase this function is used to set info of entity where from |
|
143 * the subscription was bought. |
|
144 * This is not needed when initializing from database. |
|
145 * Notice that icon is left as it was. |
|
146 */ |
|
147 virtual void SetEntityInfoL( const TDesC& aEntityId, |
|
148 const TDesC& aNamespace, |
|
149 const TDesC& aServerUri, |
|
150 const TUid aClientUid ); |
|
151 |
|
152 /** |
|
153 * Gets icon of this group's subscriptions. |
|
154 * |
|
155 * @return Icon of this group |
|
156 */ |
|
157 const TDesC8& Icon(); |
|
158 |
|
159 /** |
|
160 * Sets icon for subscriptions of this group. |
|
161 */ |
|
162 virtual void SetIconL( const TDesC8& aIcon ); |
|
163 |
|
164 |
|
165 // Getters for entity information |
|
166 |
|
167 virtual const TDesC& EntityId() const; |
|
168 |
|
169 virtual const TDesC& Namespace() const; |
|
170 |
|
171 virtual const TDesC& ServerUri() const; |
|
172 |
|
173 CNcdNodeIdentifier& OriginNodeIdentifier() const; |
|
174 |
|
175 /** |
|
176 * Returns the subscription which has the given purchase option id. |
|
177 * |
|
178 * @param aPurchaseOptionId The purchase option id. |
|
179 * @exception KErrNotFound If the subscription does not exist. |
|
180 */ |
|
181 CNcdSubscription& SubscriptionIfExistsL( |
|
182 const TDesC& aPurchaseOptionId ) const; |
|
183 |
|
184 /** |
|
185 * Returns the amount of subscription under the group. |
|
186 * |
|
187 * @return Amount of subscriptions under the group. |
|
188 */ |
|
189 TInt SubscriptionCount() const; |
|
190 |
|
191 /** |
|
192 * Function that checks if this group contains subscriptions |
|
193 * whose data is incomplete. (Name or icon missing) If such |
|
194 * subscriptions are found appends a copy of corresponding |
|
195 * node identifier and purchase option id to the arrays. |
|
196 * |
|
197 * @param aNodeIds Array for node identifier appending. |
|
198 * @param aPurchaseOptionIDs Array for purchase option id appending. |
|
199 */ |
|
200 void AppendIncompleteSubscriptionIDsL( |
|
201 RPointerArray<CNcdNodeIdentifier>& aNodeIds, |
|
202 CDesCArrayFlat& aPurchaseOptionIDs ); |
|
203 |
|
204 public: // MNcdStorageDataItem |
|
205 |
|
206 // These functions are used to get the data from and to insert the data |
|
207 // into the database using by the given stream. |
|
208 |
|
209 /** |
|
210 * @see MNcdStorageDataItem::ExternalizeL |
|
211 */ |
|
212 virtual void ExternalizeL( RWriteStream& aStream ); |
|
213 |
|
214 |
|
215 /** |
|
216 * @see MNcdStorageDataItem::InternalizeL |
|
217 */ |
|
218 virtual void InternalizeL( RReadStream& aStream ); |
|
219 |
|
220 |
|
221 public: // CCatalogsCommunicable |
|
222 |
|
223 /** |
|
224 * @see CCatalogsCommunicable::ReceiveMessage |
|
225 */ |
|
226 virtual void ReceiveMessage( MCatalogsBaseMessage* aMessage, |
|
227 TInt aFunctionNumber ); |
|
228 |
|
229 /** |
|
230 * @see CCatalogsCommunicable::CounterPartLost |
|
231 */ |
|
232 virtual void CounterPartLost( const MCatalogsSession& aSession ); |
|
233 |
|
234 protected: |
|
235 |
|
236 CNcdSubscriptionGroup(); |
|
237 |
|
238 void ConstructL(); |
|
239 |
|
240 /** |
|
241 * This function is called when the proxy wants to get the |
|
242 * purchase option ids of the subscription belonging to this |
|
243 * subscription group. |
|
244 * |
|
245 * @param aMessage Used to send data back to proxy. |
|
246 */ |
|
247 void PurchaseOptionIdsRequestL( MCatalogsBaseMessage& aMessage ) const; |
|
248 |
|
249 /** |
|
250 * This function is called when the proxy wants to get the |
|
251 * data from the serverside. This function calls the |
|
252 * InternalizeDataForRequestL which may be overloaded in the |
|
253 * child classes |
|
254 * @param aMessage Contains data from the proxy and can be used |
|
255 * to send data back to proxy |
|
256 */ |
|
257 void InternalizeRequestL( MCatalogsBaseMessage& aMessage ) const; |
|
258 |
|
259 /** |
|
260 * This function is called when the proxy wants to get the |
|
261 * icon data of the subscriptions belonging to this |
|
262 * subscription group. |
|
263 * |
|
264 * @param aMessage Used to send data back to proxy. |
|
265 */ |
|
266 void CNcdSubscriptionGroup::IconDataRequestL( |
|
267 MCatalogsBaseMessage& aMessage ) const; |
|
268 |
|
269 /** |
|
270 * This function writes the object data to the stream. The given array |
|
271 * contains the purchase option ids of the subscription that are externalized. |
|
272 * The stream content will be sent to the proxy that requested the data. |
|
273 * Child classes should add their own data after this parent data. |
|
274 * @param aStream The data content of this class object will be written |
|
275 * into this stream. |
|
276 */ |
|
277 virtual void ExternalizeDataForRequestL( |
|
278 MCatalogsSession& aSession, |
|
279 const CDesCArray& aPurchaseOptionIds, |
|
280 RWriteStream& aStream ) const; |
|
281 |
|
282 /** |
|
283 * This function is called from the proxy side. When the proxy |
|
284 * is deleted. |
|
285 * @param aMessage Contains data from the proxy and can be used |
|
286 * to send data back to proxy |
|
287 */ |
|
288 void ReleaseRequest( MCatalogsBaseMessage& aMessage ) const; |
|
289 |
|
290 private: |
|
291 |
|
292 // Prevent these two if they are not implemented |
|
293 CNcdSubscriptionGroup( const CNcdSubscriptionGroup& aObject ); |
|
294 CNcdSubscriptionGroup& operator=( const CNcdSubscriptionGroup& aObject ); |
|
295 |
|
296 |
|
297 /** |
|
298 * Function to return index pointing to a subscription |
|
299 * with given purchaseoption id. |
|
300 * |
|
301 * @param aPurchaseOptionId Purchaseoption id to identify subscription. |
|
302 * @return Index of purchaseoption. |
|
303 * @exception Leave KErrNotFound if not found. |
|
304 */ |
|
305 TInt FindSubscriptionL( const TDesC& aPurchaseOptionId ) const; |
|
306 |
|
307 /** |
|
308 * Function to return reference to subscription identified |
|
309 * by purchase option id. |
|
310 * If subscription object is not found it is created. |
|
311 * |
|
312 * @return Reference to found or created subscription. |
|
313 */ |
|
314 CNcdSubscription& SubscriptionL( const TDesC& aPurchaseOptionId ); |
|
315 |
|
316 /** |
|
317 * Deletes all allocated member variables and sets the pointers to NULL. |
|
318 * |
|
319 * @since S60 ?S60_version |
|
320 */ |
|
321 void ResetMemberVariables(); |
|
322 |
|
323 private: |
|
324 |
|
325 |
|
326 // The message is set when ReceiveMessage is called. The message |
|
327 // is used in the CounterPartLost-function that informs the message |
|
328 // if the session has been lost. |
|
329 MCatalogsBaseMessage* iMessage; |
|
330 |
|
331 |
|
332 |
|
333 // Info related to the dataentity where from the subscriptions |
|
334 // contained in this group are bought. |
|
335 |
|
336 /** |
|
337 * NodeIdentifier to identify the node where from the |
|
338 * subscriptions within this group are bought from. |
|
339 * Own. |
|
340 */ |
|
341 CNcdNodeIdentifier* iOriginNodeIdentifier; |
|
342 |
|
343 /** |
|
344 * Icon for subscriptions. |
|
345 * Own. |
|
346 */ |
|
347 HBufC8* iIcon; |
|
348 |
|
349 |
|
350 /** |
|
351 * Array of subscriptions bought from the dataentity |
|
352 */ |
|
353 RPointerArray<CNcdSubscription> iSubscriptions; |
|
354 |
|
355 }; |
|
356 |
|
357 |
|
358 #endif // C_NCD_SUBSCRIPTION_GROUP_H |