|
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 the License "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: The feeds server database. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef FEEDS_DATABASE_H |
|
20 #define FEEDS_DATABASE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <d32dbms.h> |
|
24 #include <e32base.h> |
|
25 #include <f32file.h> |
|
26 |
|
27 #include "LeakTracker.h" |
|
28 |
|
29 // CONSTANTS |
|
30 const TInt KUnassignedId = -1; |
|
31 const TInt KMinFreebytes = 1024000; |
|
32 |
|
33 // DATA TYPES |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 class CDbKey; |
|
37 class CDesC16ArraySeg; |
|
38 class CPackedFeed; |
|
39 class CPackedFolder; |
|
40 class CFeedsServer; |
|
41 struct TAttribute; |
|
42 |
|
43 // CLASS DECLARATION |
|
44 |
|
45 |
|
46 /** |
|
47 * The feeds server database. |
|
48 * |
|
49 * \b Library: FeedsEngine.lib |
|
50 * |
|
51 * @since 3.1 |
|
52 */ |
|
53 NONSHARABLE_CLASS(CFeedsDatabase): public CBase |
|
54 { |
|
55 public: // Constructors and destructor |
|
56 /** |
|
57 * Two-phased constructor. |
|
58 * |
|
59 * @since 3.1 |
|
60 * @param aDatabaseCreated To to ETrue by this method if the database |
|
61 * was newly created. |
|
62 * @return A new instance. |
|
63 */ |
|
64 static CFeedsDatabase* NewL(CFeedsServer* aFeedsServer, TBool &aDatabaseCreated); |
|
65 |
|
66 /** |
|
67 * Destructor. |
|
68 */ |
|
69 ~CFeedsDatabase(); |
|
70 |
|
71 |
|
72 public: // New methods |
|
73 /** |
|
74 * Returns the feed if of the feed with the given url. |
|
75 * |
|
76 * @since 3.1 |
|
77 * @param aFeedUrl The feed's url |
|
78 * @param aFeedId The resulting FeedsTable feed id. |
|
79 * @return ETrue if the feed was resolved. |
|
80 */ |
|
81 TBool FeedIdFromUrlL(const TDesC& aFeedUrl, TInt aFolderListId, TInt& aFeedId); |
|
82 |
|
83 /** |
|
84 * Return the folder list ID of the feed with the given feed-id. |
|
85 * |
|
86 * @since 3.2 |
|
87 * @param aFeedId The FeedsTable feed's id |
|
88 * @param aFolderListId The folder list ID of the feed |
|
89 * @return void. |
|
90 */ |
|
91 void FolderListIdFromFeedIdL( TInt aFeedId, TInt& aFolderListId ); |
|
92 |
|
93 /** |
|
94 * Return the feed-id of the given folder-item-id. |
|
95 * |
|
96 * @since 3.1 |
|
97 * @param aFolderItemId The FolderListTable folder item's id |
|
98 * @param aFeedId The feed's id |
|
99 * @return ETrue if the feed was resolved. |
|
100 */ |
|
101 TBool FeedIdFromFolderItemIdL(TInt aFolderItemId, TInt& aFeedId); |
|
102 |
|
103 /** |
|
104 * Gets the folder item properties like IsFolder, Title and FeedURL |
|
105 * |
|
106 * @since 3.2 |
|
107 * @param aFolderItemId The Folder item's id |
|
108 * @param aTitle Title of the folder item will be stored in this |
|
109 * @param aFeedUrl Feed URL of the folder item will be stored in this |
|
110 * @return void |
|
111 */ |
|
112 void FolderItemInfoL(TInt aFolderItemId, TBool &aIsFolder, HBufC*& aTitle, HBufC*& aFeedUrl); |
|
113 |
|
114 /** |
|
115 * Return the url of the feed with the given feed-id. |
|
116 * |
|
117 * @since 3.1 |
|
118 * @param aFeedId The FeedsTable feed's id |
|
119 * @param aFeedUrl The feed's url |
|
120 * @return ETrue if the feed was resolved. |
|
121 */ |
|
122 TBool UrlFromFeedIdL(TInt aFeedId, HBufC*& aFeedUrl); |
|
123 |
|
124 /** |
|
125 * Finds the item with the given item-id-str and returns its id. |
|
126 * |
|
127 * @since 3.1 |
|
128 * @param aFeedId The FeedsTable feed id. |
|
129 * @param aItemIdStr The item's id string. |
|
130 * @param aItemId The resulting ItemsTable item id. |
|
131 * @return ETrue if the feed was resolved. |
|
132 */ |
|
133 TBool FindItemL(TInt aFeedId, const TDesC& aItemIdStr, TInt& aItemId); |
|
134 |
|
135 /** |
|
136 * Finds the folder item with the given name. |
|
137 * |
|
138 * @since 3.1 |
|
139 * @param aFolderListId The folder list id. |
|
140 * @param aName The name. |
|
141 * @param aFolderItemId The resulting folder-item-id, if found. |
|
142 * @return ETrue if a folder item with this name was found. |
|
143 */ |
|
144 TBool CFeedsDatabase::FindFolderItemL(TInt& aFolderListId, const TDesC& aName, |
|
145 TInt& aFolderItemId); |
|
146 |
|
147 /** |
|
148 * Extract all of the feed-ids. |
|
149 * |
|
150 * @since 3.1 |
|
151 * @param aFeedIds The resulting feed ids. |
|
152 * @return Void. |
|
153 */ |
|
154 void AllFeedIdsL( RArray<TInt>& aFeedIds, TInt aFolderListId = -1 ); |
|
155 |
|
156 /** |
|
157 * Determines if the given feed is newly created (not ok to read from the database). |
|
158 * |
|
159 * @since 3.1 |
|
160 * @param aFeedId The resulting feed id. |
|
161 * @return ETrue if the feed is newly created. |
|
162 */ |
|
163 TBool IsNewlyCreatedL(TInt aFeedId); |
|
164 |
|
165 /** |
|
166 * Extracts the feed from the database. |
|
167 * |
|
168 * @since 3.1 |
|
169 * @param aFeedId The feed's id. Call ResolveFeedUrl to get the id. |
|
170 * @param aFeed The resulting packed feed. |
|
171 * @return void |
|
172 */ |
|
173 void ExtractFeedL(TInt aFeedId, CPackedFeed& aFeed); |
|
174 |
|
175 /** |
|
176 * Extracts the folder from the database. |
|
177 * |
|
178 * @since 3.1 |
|
179 * @param aFolderListId The folder list's id. |
|
180 * @param aPackedFolder The resulting packed folder. |
|
181 * @param aItemTitleNeed The flag indicates if the titles of items with new status will be returned. |
|
182 * @return void |
|
183 */ |
|
184 void ExtractRootFolderL( TInt aFolderListId, CPackedFolder& aPackedFolder, TBool aItemTitleNeed = EFalse ); |
|
185 |
|
186 /** |
|
187 * Update the database given the packed feed. |
|
188 * |
|
189 * @since 3.1 |
|
190 * @param aFeed A packed feed. |
|
191 * @param aFeedUrl The feed's url. |
|
192 * @param aPurgeOldItems If ETrue all items in the db that are not in the |
|
193 * packed feed are purged from the database. |
|
194 * @return Void. |
|
195 */ |
|
196 void UpdateFeedL(const CPackedFeed& aPackedFeed, const TDesC& aFeedUrl,TInt aFeedId, TInt aFolderListId, |
|
197 TBool aPurgeOldItems = ETrue); |
|
198 |
|
199 /** |
|
200 * Update the database given the packed folder. |
|
201 * |
|
202 * @since 3.1 |
|
203 * @param aFolderListId The folder list's id. |
|
204 * @param aFeed A packed folder. |
|
205 * @return Void. |
|
206 */ |
|
207 void ImportFolderL(TInt aFolderListId, const CPackedFolder& aPackedFolder); |
|
208 |
|
209 /** |
|
210 * Add a new entry. |
|
211 * |
|
212 * @since 3.1 |
|
213 * @param aFolderListId The folder-list id. |
|
214 * @param aTitle The title. |
|
215 * @param aUrl The url. |
|
216 * @param aIsFolder ETrue if this is a folder. |
|
217 * @param aParentEntryId The entry id of the parent. |
|
218 * @param aFreq auto update frequency |
|
219 * @return The entry-id of the new entry. |
|
220 */ |
|
221 TInt FolderItemAddL(TInt aFolderListId, const TDesC& aTitle, |
|
222 const TDesC& aUrl, TBool aIsFolder, TInt aParentEntryId, TInt aFreq); |
|
223 |
|
224 /** |
|
225 * Update an entry. |
|
226 * |
|
227 * @since 3.1 |
|
228 * @param aFolderItemId The folder-item's id. |
|
229 * @param aTitle The title. |
|
230 * @param aUrl The url. |
|
231 * @param aFreq auto update frequency |
|
232 * @return void |
|
233 */ |
|
234 void FolderItemUpdateL(TInt aFolderItemId, const TDesC& aTitle, |
|
235 const TDesC& aUrl, TInt aFreq); |
|
236 |
|
237 /** |
|
238 * Delete the given folder items. |
|
239 * |
|
240 * @since 3.1 |
|
241 * @param aFolderItemIds The id of the folder items. |
|
242 * @param iSessionCalled This should be true if FeedServerSession calls this function |
|
243 * @return void |
|
244 */ |
|
245 void FolderItemDeleteL(const RArray<TInt>& aFolderItemIds, TBool iSessionCalled = EFalse); |
|
246 |
|
247 /** |
|
248 * Delete anything under the folder list. |
|
249 * |
|
250 * @since 3.2 |
|
251 * @param aFolderListId The folder list ID. |
|
252 * @return void |
|
253 */ |
|
254 void FolderListDeleteL( TInt aFolderListId ); |
|
255 |
|
256 /** |
|
257 * Move the folder items within their parent. |
|
258 * |
|
259 * @since 3.1 |
|
260 * @param aFolderItemIds The id of the folder items. |
|
261 * @param aNewIndex The target index. |
|
262 * @return void. |
|
263 */ |
|
264 void FolderItemMoveL(const RArray<TInt>& aFolderItemIds, |
|
265 TInt aNewIndex); |
|
266 |
|
267 /** |
|
268 * Move the entries to another parent. |
|
269 * |
|
270 * @since 3.1 |
|
271 * @param aFolderItemIds The id of the folder items. |
|
272 * @param aNewParent The id of the new parent. |
|
273 * @return void. |
|
274 */ |
|
275 void FolderItemMoveToL(const RArray<TInt>& aFolderItemIds, |
|
276 TInt aNewParent); |
|
277 |
|
278 /** |
|
279 * Update the status of each of the items in the given feed. |
|
280 * |
|
281 * @since 3.1 |
|
282 * @param aFeedId The feed's id. |
|
283 * @param aItemIds The Id's of the items to update. |
|
284 * @param aItemStatus The corresponding status of items defined in aItemIdStr. |
|
285 * @return void |
|
286 */ |
|
287 void FeedUpdateItemStatusL(TInt aFeedId, const RArray<TInt>& aItemIds, |
|
288 const RArray<TInt>& aItemStatus, TInt aUnreadCount); |
|
289 |
|
290 /** |
|
291 * Deletes the feed if the feedId isn't referenced in the folder-list table. |
|
292 * |
|
293 * @since 3.1 |
|
294 * @param aFeedId The feed's id. |
|
295 * @return void. |
|
296 */ |
|
297 void PurgeFeedIfNotReferencedL(TInt aFeedId); |
|
298 |
|
299 /** |
|
300 * Removes the feed's items also deletes the feed if aDeleteFeed is ETrue. |
|
301 * It is only safe to call this method with aDeleteFeed set to ETrue if |
|
302 * aFeedId is not found in the FolderListTable. |
|
303 * |
|
304 * @since 3.1 |
|
305 * @param aFeedId The feed's id. |
|
306 * @param aDeleteFeed If ETrue the feed is also delete. |
|
307 * @return void. |
|
308 */ |
|
309 void FeedPurgeL(TInt aFeedId, TBool aDeleteFeed = EFalse); |
|
310 |
|
311 /** |
|
312 * Purge all old items in the given feed. |
|
313 * |
|
314 * @since 3.1 |
|
315 * @param aFeedId The feed's id. |
|
316 * @param aTimestamp The timestamp used to remove old items. |
|
317 * @return void. |
|
318 */ |
|
319 void PurgeOldItemsL(TInt aFeedId, const TTime& aTimestamp); |
|
320 |
|
321 /** |
|
322 * Purge the associated enclosures |
|
323 * |
|
324 * @since 3.1 |
|
325 * @param aFeedId The feed's id. |
|
326 * @param aItemId The item's id. |
|
327 * @return void. |
|
328 */ |
|
329 void PurgeEnclosuresL(TInt aFeedId, TInt aItemId); |
|
330 |
|
331 /** |
|
332 * Purge all items not found in the given array. |
|
333 * |
|
334 * @since 3.1 |
|
335 * @param aFeedId The feed's id. |
|
336 * @param aItemIds An array that holds the itemIds of the items to keep. |
|
337 * @return purged unread count. |
|
338 */ |
|
339 TInt PurgeOtherItemsL(TInt aFeedId, const RArray<TInt>& aItemIds); |
|
340 |
|
341 /** |
|
342 * Get the settings from the database. |
|
343 * |
|
344 * @since 3.2 |
|
345 * @param aFolderListIds The array holding folder list Ids in the settings table. |
|
346 * @return void. |
|
347 */ |
|
348 void ExtractFolderListIdInSettingsL( RArray<TInt>& aFolderListIds ); |
|
349 |
|
350 /** |
|
351 * Get the settings from the database. |
|
352 * |
|
353 * @since 3.2 |
|
354 * @param aFolderListId The client to whom the settings belong to. |
|
355 * @param aAutoUpdate ETrue if auto update is enabled. |
|
356 * @param aAutoUpdateFreq The freq of auto updates. |
|
357 * @param aAutoUpdateAP The access point. |
|
358 * @param aAutoUpdateWhileRoaming ETrue if auto update is enabled while roaming. |
|
359 * @return void. |
|
360 */ |
|
361 void ExtractAutoUpdateSettingsL( TInt aFolderListId, TBool& aAutoUpdate, TInt& aAutoUpdateFreq, |
|
362 TUint32& aAutoUpdateAP, TBool &autoUpdateWhileRoaming ); |
|
363 |
|
364 /** |
|
365 * Commit the settings to the database |
|
366 * |
|
367 * @since 3.2 |
|
368 * @param aFolderListId The client to whom the settings belong to. |
|
369 * @param aAutoUpdate ETrue if auto update is enabled. |
|
370 * @param aAutoUpdateFreq The freq of auto updates. |
|
371 * @param aAutoUpdateAP The access point. |
|
372 * @param aAutoUpdateWhileRoaming ETrue if auto update is enabled. |
|
373 * @return Void. |
|
374 */ |
|
375 void CommitAutoUpdateSettingsL( TInt aFolderListId, TBool aAutoUpdate, TInt aAutoUpdateFreq, |
|
376 TUint32 aAutoUpdateAP, TBool aAutoUpdateWhileRoaming ); |
|
377 |
|
378 /** |
|
379 * Get the last auto update settings from the database. |
|
380 * |
|
381 * @since 3.2 |
|
382 * @param aFolderListId The client to whom the settings belong to. |
|
383 * @param aLastAutoUpdate The timestamp of the last auto update. |
|
384 * @return void. |
|
385 */ |
|
386 void ExtractLastAutoUpdateSettingsL(TInt aFolderListId, TTime& aLastAutoUpdate); |
|
387 |
|
388 /** |
|
389 * Commit the last auto update settings to the database |
|
390 * |
|
391 * @since 3.2 |
|
392 * @param aFolderListId The client to whom the settings belong to. |
|
393 * @param aLastAutoUpdate The timestamp of the last auto update. |
|
394 * @return Void. |
|
395 */ |
|
396 void CommitLastAutoUpdateSettingsL(TInt aFolderListId, TTime aLastAutoUpdate); |
|
397 |
|
398 /** |
|
399 * Compacts the database. |
|
400 * |
|
401 * @since 3.1 |
|
402 * @return Void. |
|
403 */ |
|
404 void Compact(); |
|
405 |
|
406 /** |
|
407 * Print the tables from the database. |
|
408 * |
|
409 * @since 3.2 |
|
410 * @return Void. |
|
411 */ |
|
412 void DebugPrintTablesL(); |
|
413 |
|
414 /** |
|
415 * Print the folder list table from the database. |
|
416 * |
|
417 * @since 3.2 |
|
418 * @return Void. |
|
419 */ |
|
420 void DebugPrintFolderListTableL(); |
|
421 |
|
422 /** |
|
423 * Print the item table from the database. |
|
424 * |
|
425 * @since 3.2 |
|
426 * @return Void. |
|
427 */ |
|
428 void DebugPrintItemTableL(); |
|
429 |
|
430 /** |
|
431 * Extract the folder-item-ids of the children of the given parent. |
|
432 * |
|
433 * @since 3.2 |
|
434 * @param aFolderItemId The id of the parent folder item. |
|
435 * @param aChildren The ids of the children. |
|
436 * @return void. |
|
437 */ |
|
438 void FolderItemGetChildrenL(TInt aFolderItemId, RArray<TInt>& aChildren); |
|
439 |
|
440 /** |
|
441 * Check for the duplicate folder names and feed URLs and suggest the next title. |
|
442 * |
|
443 * @since 3.2 |
|
444 * @param aFolderListId The folder list id. |
|
445 * @param aParentEntryId The parent id |
|
446 * @param aTitle Folder/Feed title to be checked for duplicates |
|
447 * @param aIsFolder Flag which indicates folder/feed |
|
448 * @param aNewFeedTitle The new feed/folder title generated |
|
449 * @return TBool - ETrue if new folder/feed title is generated successfully and ready to add to the DB. |
|
450 */ |
|
451 TBool ValidateFeedFolderTitleL(const TInt &aFolderListId, const TInt &aParentEntryId, |
|
452 const TDesC& aTitle, const TBool aIsFolder, TDes& aNewFeedTitle); |
|
453 |
|
454 /** |
|
455 * Update Feed Status |
|
456 * |
|
457 * @since 5.0 |
|
458 * @param aFeedId Feed Id. |
|
459 * @param aFeedStatus Feed status |
|
460 * @return void |
|
461 */ |
|
462 void UpdateFeedStatusL(TInt aFeedId, TInt aFeedStatus); |
|
463 |
|
464 /** |
|
465 * Adds a new column AutoUpdateFreq to FeedTable in the case of versions less than 7.1. |
|
466 * |
|
467 * @since 7.1 |
|
468 * @return void |
|
469 */ |
|
470 void AlterFeedTableWithAutoFequencyL(); |
|
471 |
|
472 /** |
|
473 * Fetchs Freqs for all feeds. |
|
474 * |
|
475 * @since 7.1 |
|
476 * @return bool |
|
477 */ |
|
478 TBool FreqFromFeedIdL(TInt aFeedId, TInt& aFreq); |
|
479 |
|
480 private: // New methods |
|
481 /** |
|
482 * C++ default constructor. |
|
483 */ |
|
484 CFeedsDatabase(CFeedsServer* aFeedsServer); |
|
485 |
|
486 /** |
|
487 * Two-Phase constructor |
|
488 */ |
|
489 void ConstructL(TBool &aDatabaseCreated); |
|
490 |
|
491 /** |
|
492 * Reset the database. |
|
493 * |
|
494 * @since 3.1 |
|
495 * @return void. |
|
496 */ |
|
497 void ResetDatabaseL(); |
|
498 |
|
499 /** |
|
500 * Creates the version table. |
|
501 * |
|
502 * @since 3.1 |
|
503 * @return void. |
|
504 */ |
|
505 void CreateVersionTableL(); |
|
506 |
|
507 /** |
|
508 * Creates the folder-list table. |
|
509 * |
|
510 * @since 3.1 |
|
511 * @return void. |
|
512 */ |
|
513 void CreateFolderListTableL(); |
|
514 |
|
515 /** |
|
516 * Creates the feed table. |
|
517 * |
|
518 * @since 3.1 |
|
519 * @return void. |
|
520 */ |
|
521 void CreateFeedTableL(); |
|
522 |
|
523 /** |
|
524 * Creates the feed-item table. |
|
525 * |
|
526 * @since 3.1 |
|
527 * @return void. |
|
528 */ |
|
529 void CreateFeedItemTableL(); |
|
530 |
|
531 /** |
|
532 * Creates the item-enclosure table. |
|
533 * |
|
534 * @since 3.1 |
|
535 * @return void. |
|
536 */ |
|
537 void CreateItemEnclosureTableL(); |
|
538 |
|
539 /** |
|
540 * Creates the settings table. |
|
541 * |
|
542 * @since 3.1 |
|
543 * @return void. |
|
544 */ |
|
545 void CreateSettingsTableL(); |
|
546 |
|
547 /** |
|
548 * Returns an available folder-item id |
|
549 * |
|
550 * @since 3.1 |
|
551 * @return void. |
|
552 */ |
|
553 TInt NextFolderItemIdL(); |
|
554 |
|
555 /** |
|
556 * Returns an available feed id |
|
557 * |
|
558 * @since 3.1 |
|
559 * @return void. |
|
560 */ |
|
561 TInt NextFeedIdL(); |
|
562 |
|
563 /** |
|
564 * Returns an available item id |
|
565 * |
|
566 * @since 3.1 |
|
567 * @return void. |
|
568 */ |
|
569 TInt NextItemIdL(); |
|
570 |
|
571 /** |
|
572 * Add a new entry. |
|
573 * |
|
574 * @since 3.1 |
|
575 * @param aFolderListId The folder-list id. |
|
576 * @param aTitle The title. |
|
577 * @param aUrl The url. |
|
578 * @param aIsFolder ETrue if this is a folder. |
|
579 * @param aSiblingIndex The sibling index within the given parent. |
|
580 * @param aParentEntryId The entry id of the parent. |
|
581 * @param aOutFolderId The new id generated for the folder added |
|
582 * @param aOutFeedId The new id generated for the feed added |
|
583 * @param aFreq auto update frequency |
|
584 * @return void. |
|
585 */ |
|
586 void FolderItemAddHelperL(TInt aFolderListId, const TDesC& aTitle, |
|
587 const TDesC& aUrl, TBool aIsFolder, TInt aSiblingIndex, TInt aParentEntryId, |
|
588 TInt& aOutFolderId, TInt& aOutFeedId, TInt aFreq); |
|
589 |
|
590 /** |
|
591 * Delete the given folder items and store the feedIds in aFeedIds. aFeedIds |
|
592 * can then be used to delete any newly unreferenced feeds. |
|
593 * |
|
594 * @since 3.1 |
|
595 * @param aFolderItemIds The ids of the folder items to delete. |
|
596 * @param aFeedIds The feed ids of the folder items deleted. |
|
597 * @return void. |
|
598 */ |
|
599 void FolderItemDeleteHelperL(const RArray<TInt>& aFolderItemIds, |
|
600 RArray<TInt>& aFeedIds); |
|
601 |
|
602 /** |
|
603 * Reorders the sibling indexes. |
|
604 * |
|
605 * @since 3.1 |
|
606 * @param aParentId The entry id of the parent. |
|
607 * @return void. |
|
608 */ |
|
609 void AdjustSiblingIndexesL(TInt aParentId); |
|
610 |
|
611 /** |
|
612 * Creates a hole in the sibling index. |
|
613 * |
|
614 * @since 3.1 |
|
615 * @param aParentId The entry id of the parent. |
|
616 * @param aNewIndex Where the hole will be made. |
|
617 * @param aHoleSize The size of the hole. |
|
618 * @return void. |
|
619 */ |
|
620 void CreateSiblingIndexHoleL(TInt aParentId, TInt aNewIndex, TInt aHoleSize); |
|
621 |
|
622 /** |
|
623 * Commit the folder entry to the database. |
|
624 * |
|
625 * @since 3.1 |
|
626 * @param aFolderListId The folder-list-id that this entry is added to. This id |
|
627 * allows multiple lists of feeds and folders to be tracked by the database. |
|
628 * @param aFolderItemId The folder item's id. |
|
629 * @param aParentId The entry's parent folder. |
|
630 * @param aSiblingIndex The sibling order of this entry. |
|
631 * @param aIsFolder ETrue when the entry is an folder. |
|
632 * @param aFeedId The feed's id or KUnassignedId if this is folder. |
|
633 * @param aTitle The title. |
|
634 * @return Void. |
|
635 */ |
|
636 void CommitFolderListL(TInt aFolderListId, TInt aFolderItemId, |
|
637 TInt aParentId, TInt aSiblingIndex, TBool aIsFolder, TInt aFeedId, |
|
638 const TDesC& aTitle); |
|
639 |
|
640 private: |
|
641 /** |
|
642 * Commit the feed to the database. |
|
643 * |
|
644 * @since 3.1 |
|
645 * @param aFolderListId The folder list's id. |
|
646 * @param aIsNewFeed If ETrue a new entry is added to the database, otherwise |
|
647 * the existing entry is updated. |
|
648 * @param aFeedId The feed's id. |
|
649 * @param aAttributes The associated attributes. |
|
650 * @param aDefaultTime The default timestamp if the feed doesn't provide a value. |
|
651 * @param aUnreadCount number of unread articles |
|
652 * @param aFreq auto update frequency |
|
653 * @return Void. |
|
654 */ |
|
655 void CommitFeedL(TInt aFolderListId, TBool aIsNewFeed, TInt aFeedId, |
|
656 const RArray<TAttribute>& aAttributes, const TTime& aDefaultTime, TInt aUnreadCount, TInt aFreq); |
|
657 |
|
658 /** |
|
659 * Commit the feed to the database. |
|
660 * |
|
661 * @since 3.1 |
|
662 * @param aFolderListId The folder list's id. |
|
663 * @param aIsNewFeed If ETrue a new entry is added to the database, otherwise |
|
664 * the existing entry is updated. |
|
665 * @param aFeedId The feed's id. |
|
666 * @param aAttributes The associated attributes. |
|
667 * @param aDefaultTime The default timestamp if the feed doesn't provide a value. |
|
668 * @param aUnreadCount number of unread articles |
|
669 * @return Void. |
|
670 */ |
|
671 void CommitFeedL(TInt aFolderListId, TBool aIsNewFeed, TInt aFeedId, |
|
672 const RArray<TAttribute>& aAttributes, const TTime& aDefaultTime, TInt aUnreadCount); |
|
673 |
|
674 /** |
|
675 * Commit a new feed to the database. |
|
676 * |
|
677 * @since 3.1 |
|
678 * @param aFolderListId The folder list's id. |
|
679 * @param aTitle The title. |
|
680 * @param aUrl The url. |
|
681 * @param aFreq auto update frequency |
|
682 * @return The feed's id. |
|
683 */ |
|
684 TInt CommitFeedL(TInt aFolderListId, const TDesC& aTitle, const TDesC& aUrl, TInt aFreq); |
|
685 |
|
686 /** |
|
687 * Commit the item to the database. The itemIdStr is also appended to aItemIdStrs. |
|
688 * |
|
689 * @since 3.1 |
|
690 * @param aItemId The item's id. |
|
691 * @param aFeedId The feed's id. |
|
692 * @param aAttributes The associated attributes. |
|
693 * @param aItemIds An array that holds the itemId of the items in this feed. |
|
694 * @return ETrue if this item was added to the database (i.e. it wasn't already there). |
|
695 */ |
|
696 TBool CommitItemL(TInt aItemId, TInt aFeedId, |
|
697 const RArray<TAttribute>& aAttributes, RArray<TInt>& aItemIds); |
|
698 |
|
699 /** |
|
700 * Commit the enclosure to the database |
|
701 * |
|
702 * @since 3.1 |
|
703 * @param aEnclosureId The enclosure's id. |
|
704 * @param aItemId The item's id. |
|
705 * @param aFeedId The feed's id. |
|
706 * @param aAttributes The associated attributes. |
|
707 * @return Void. |
|
708 */ |
|
709 void CommitEnclosureL(TInt aEnclosureId, TInt aItemId, TInt aFeedId, |
|
710 const RArray<TAttribute>& aAttributes); |
|
711 |
|
712 /** |
|
713 * Extracts and pack the folder. |
|
714 * |
|
715 * @since 3.1 |
|
716 * @param aFolderListId The folder list's id. |
|
717 * @param aFolderId The id of the folder to be packed. |
|
718 * @param aPackedFolder The resulting packed folder. |
|
719 * @param aItemTitleNeed Need items title or not. |
|
720 * @return void |
|
721 */ |
|
722 void PackFolderL(TInt aFolderListId, TInt aFolderId, CPackedFolder& aPackedFolder, |
|
723 TBool aItemTitleNeed ); |
|
724 |
|
725 /** |
|
726 * Extracts and pack the feed. |
|
727 * |
|
728 * @since 3.1 |
|
729 * @param aFeedId The feed's id |
|
730 * @param aFeed The destination feed. |
|
731 * @return Void. |
|
732 */ |
|
733 void PackFeedL(TInt aFeedId, CPackedFeed& aFeed); |
|
734 |
|
735 /** |
|
736 * Extracts and pack the items. |
|
737 * |
|
738 * @since 3.1 |
|
739 * @param aFeedId The feed's id |
|
740 * @param aFeed The destination feed. |
|
741 * @return Void. |
|
742 */ |
|
743 void PackItemsL(TInt aFeedId, CPackedFeed& aFeed); |
|
744 |
|
745 /** |
|
746 * Extracts and pack the enclosures. |
|
747 * |
|
748 * @since 3.1 |
|
749 * @param aFeedId The feed's id |
|
750 * @param aItemId The item's id |
|
751 * @param aFeed The destination feed. |
|
752 * @return Void. |
|
753 */ |
|
754 void PackEnclosuresL(TInt aFeedId, TInt aItemId, CPackedFeed& aFeed); |
|
755 |
|
756 /** |
|
757 * Extracts and pack the enclosures. |
|
758 * |
|
759 * @since 3.2 |
|
760 * @param aFeedId The feed's id |
|
761 * @param aStatus The desired status of items |
|
762 * @param aPackedFolder The resulting packed folder. |
|
763 * @return Void. |
|
764 */ |
|
765 void SelectMiniItemsL( TInt aFeedId, TInt aStatus, CPackedFolder& aFolder ); |
|
766 |
|
767 /** |
|
768 * Writes "long" text to the database. |
|
769 * |
|
770 * @since 3.1 |
|
771 * @param aTable The table. |
|
772 * @param aColumnIndex The column index to write to. |
|
773 * @param aValue The value. |
|
774 * @return Void. |
|
775 */ |
|
776 void WriteLongTextL(RDbRowSet& aTable, TInt aColumnIndex, |
|
777 const TDesC& aValue); |
|
778 |
|
779 /** |
|
780 * Reads "long" text from the database. |
|
781 * |
|
782 * @since 3.1 |
|
783 * @param aTable The table. |
|
784 * @param aColumnIndex The column index to read from. |
|
785 * @param aValue The resulting value. |
|
786 * @return Void. |
|
787 */ |
|
788 void ReadLongTextL(RDbRowSet& aTable, TInt aColumnIndex, |
|
789 HBufC*& aValue); |
|
790 |
|
791 /** |
|
792 * Pushes the release table function onto cleanup stack |
|
793 * and opens the FolderList table for use. |
|
794 * |
|
795 * @since 3.1 |
|
796 * @param aAccess The access specification for the rowset. |
|
797 * @return Void. |
|
798 */ |
|
799 void UseFolderListTableLC(RDbRowSet::TAccess aAccess); |
|
800 |
|
801 /** |
|
802 * Opens the Folder List table for use. |
|
803 * |
|
804 * @since 3.2 |
|
805 * @param aAccess The access specification for the rowset. |
|
806 * @return Void. |
|
807 */ |
|
808 void OpenFolderListTableL(RDbRowSet::TAccess aAccess); |
|
809 |
|
810 /** |
|
811 * Closes the Folder List table. |
|
812 * |
|
813 * @since 3.1 |
|
814 * @param aPtr Pointer to self. |
|
815 * @return Void. |
|
816 */ |
|
817 static void ReleaseFolderListTable(TAny *aPtr); |
|
818 |
|
819 /** |
|
820 * Pushes the release table function onto cleanup stack |
|
821 * and opens the Feed table for use. |
|
822 * |
|
823 * @since 3.1 |
|
824 * @param aAccess The access specification for the rowset. |
|
825 * @return Void. |
|
826 */ |
|
827 void UseFeedTableLC(RDbRowSet::TAccess aAccess); |
|
828 |
|
829 /** |
|
830 * Opens the feed table for use. |
|
831 * |
|
832 * @since 3.2 |
|
833 * @param aAccess The access specification for the rowset. |
|
834 * @return Void. |
|
835 */ |
|
836 void OpenFeedTableL(RDbRowSet::TAccess aAccess); |
|
837 |
|
838 /** |
|
839 * Closes the feed table. |
|
840 * |
|
841 * @since 3.1 |
|
842 * @return Void. |
|
843 */ |
|
844 static void ReleaseFeedTable(TAny *aPtr); |
|
845 |
|
846 /** |
|
847 * Opens the OPML import related tables (FeedTable and FolderListTable) and starts a transaction |
|
848 * |
|
849 * @since 3.2 |
|
850 * @return Void. |
|
851 */ |
|
852 void PrepareImportTransationsL(); |
|
853 |
|
854 /** |
|
855 * Closes the OPML import related tables (FeedTable and FolderListTable) |
|
856 * |
|
857 * @since 3.2 |
|
858 * @return Void. |
|
859 */ |
|
860 void ReleaseImportTables(); |
|
861 |
|
862 /** |
|
863 * Commits current database transaction |
|
864 * |
|
865 * @since 3.2 |
|
866 * @return Void. |
|
867 */ |
|
868 void CommitImportTransaction(); |
|
869 |
|
870 /** |
|
871 * Cancels/Rollbacks current database transaction |
|
872 * |
|
873 * @since 3.2 |
|
874 * @return Void. |
|
875 */ |
|
876 void CancelImportTransaction(); |
|
877 |
|
878 /** |
|
879 * Deletes records from a FeedTable |
|
880 * |
|
881 * @since 3.2 |
|
882 * @param aFeedIds The array of FeedIds to be deleted |
|
883 * @return Void. |
|
884 */ |
|
885 void DeleteFeedTableRecordsL(RArray<TInt>& aFeedIds); |
|
886 |
|
887 /** |
|
888 * Deletes records from a FolderListTable |
|
889 * |
|
890 * @since 3.2 |
|
891 * @param aFolderItemIds The array of FolderItemIds to be deleted |
|
892 * @return Void. |
|
893 */ |
|
894 void DeleteFolderListTableRecordsL(RArray<TInt>& aFolderItemIds); |
|
895 |
|
896 /** |
|
897 * Deletes records from a given table |
|
898 * |
|
899 * @since 3.2 |
|
900 * @param aTableName The table from which records to be deleted |
|
901 * @param aColumnName The column name whose values have been specified to be deleted |
|
902 * @param aIds The Id valus for the columns to be deleted |
|
903 * @return Void. |
|
904 */ |
|
905 void DeleteRecordsFromTableL(const TDesC& aTableName, const TDesC& aColumnName, RArray<TInt>& aIds); |
|
906 |
|
907 /** |
|
908 * Opens the item table for use. |
|
909 * |
|
910 * @since 3.1 |
|
911 * @param aAccess The access specification for the rowset. |
|
912 * @return Void. |
|
913 */ |
|
914 void UseItemTableLC(RDbRowSet::TAccess aAccess); |
|
915 |
|
916 /** |
|
917 * Closes the Item table. |
|
918 * |
|
919 * @since 3.1 |
|
920 * @param aPtr Pointer to self. |
|
921 * @return Void. |
|
922 */ |
|
923 static void ReleaseItemTable(TAny *aPtr); |
|
924 |
|
925 /** |
|
926 * Opens the Enclosure table for use. |
|
927 * |
|
928 * @since 3.1 |
|
929 * @param aAccess The access specification for the rowset. |
|
930 * @return Void. |
|
931 */ |
|
932 void UseEnclosureTableLC(RDbRowSet::TAccess aAccess); |
|
933 |
|
934 /** |
|
935 * Closes the Enclosure table. |
|
936 * |
|
937 * @since 3.1 |
|
938 * @param aPtr Pointer to self. |
|
939 * @return Void. |
|
940 */ |
|
941 static void ReleaseEnclosureTable(TAny *aPtr); |
|
942 |
|
943 /** |
|
944 * Opens the Settings table for use. |
|
945 * |
|
946 * @since 3.1 |
|
947 * @param aAccess The access specification for the rowset. |
|
948 * @return Void. |
|
949 */ |
|
950 void UseSettingsTableLC(RDbRowSet::TAccess aAccess); |
|
951 |
|
952 /** |
|
953 * Closes the Settings table. |
|
954 * |
|
955 * @since 3.1 |
|
956 * @param aPtr Pointer to self. |
|
957 * @return Void. |
|
958 */ |
|
959 static void ReleaseSettingsTable(TAny *aPtr); |
|
960 |
|
961 /** |
|
962 * Opens the Version table for use. |
|
963 * |
|
964 * @since 3.1 |
|
965 * @param aAccess The access specification for the rowset. |
|
966 * @return Void. |
|
967 */ |
|
968 void UseVersionTableLC(RDbRowSet::TAccess aAccess); |
|
969 |
|
970 /** |
|
971 * Closes the Version table. |
|
972 * |
|
973 * @since 3.1 |
|
974 * @param aPtr Pointer to self. |
|
975 * @return Void. |
|
976 */ |
|
977 static void ReleaseVersionTable(TAny *aPtr); |
|
978 |
|
979 /** |
|
980 * Parses the Folder/Feed name to get the counter for duplicated names (ex Folder, Folder (2), Folder (3) ...) |
|
981 * |
|
982 * @since 3.2 |
|
983 * @param aFolderTitle is the input Folder/Feed title |
|
984 * @param aCounterVal is the output postfix integer value |
|
985 * @return TBool ETrue if its a valid duplicated folder name else EFalse |
|
986 */ |
|
987 TBool GetDuplicateFolderCounter(const TDesC& aFolderToBeAdded, const TDesC& aFolderTitle, TInt &aCounterVal); |
|
988 |
|
989 /** |
|
990 * Checks for the FeedURL's existance |
|
991 * |
|
992 * @since 3.2 |
|
993 * @param aFolderListId is the input folder list id |
|
994 * @param aUrl is the feed-url needs to be checked |
|
995 * @return TBool ETrue if the specified URL exists else EFalse |
|
996 */ |
|
997 TBool ValidateFeedURLL(const TInt &aFolderListId, const TDesC& aUrl); |
|
998 |
|
999 /** |
|
1000 * This will check for the duplicate folder names and suggest a new folder title if duplicated |
|
1001 * |
|
1002 * @since 3.2 |
|
1003 * @param aFolderListId is the input folder list id |
|
1004 * @param aParentEntryId is the parent id |
|
1005 * @param aTitle The Folder/Feed title to be checked for duplicate |
|
1006 * @param aNewFeedTitle The new Folder/Feed title generated |
|
1007 * @return void |
|
1008 */ |
|
1009 void GenerateNewFeedFolderTitleL( |
|
1010 const TInt &aFolderListId, |
|
1011 const TInt &aParentEntryId, |
|
1012 const TDesC& aTitle, |
|
1013 TDes& aNewFeedTitle |
|
1014 ); |
|
1015 |
|
1016 private: // Data |
|
1017 TLeakTracker iLeakTracker; |
|
1018 |
|
1019 RDbs iDBs; ///< DBMS session handle. Own |
|
1020 RDbNamedDatabase iDatabase; ///< Database handle. Own. |
|
1021 TBuf<KMaxFileName> iDatabasePath; |
|
1022 |
|
1023 RDbTable iFolderListTable; |
|
1024 CDbColSet* iFolderListColSet; |
|
1025 TInt iFolderListTableRefCount; |
|
1026 |
|
1027 RDbTable iFeedTable; |
|
1028 CDbColSet* iFeedColSet; |
|
1029 TInt iFeedTableRefCount; |
|
1030 |
|
1031 RDbTable iItemTable; |
|
1032 CDbColSet* iItemColSet; |
|
1033 TInt iItemTableRefCount; |
|
1034 |
|
1035 RDbTable iEnclosureTable; |
|
1036 CDbColSet* iEnclosureColSet; |
|
1037 TInt iEnclosureTableRefCount; |
|
1038 |
|
1039 RDbTable iVersionTable; |
|
1040 CDbColSet* iVersionColSet; |
|
1041 TInt iVersionTableRefCount; |
|
1042 |
|
1043 RDbTable iSettingsTable; |
|
1044 CDbColSet* iSettingsColSet; |
|
1045 TInt iSettingsTableRefCount; |
|
1046 |
|
1047 TInt iNextAvailableFeedId; |
|
1048 |
|
1049 RArray<TInt> iDeleteFolderArray; // This array will be populated when session calls delete |
|
1050 CFeedsServer* iFeedsServer; |
|
1051 |
|
1052 |
|
1053 friend class CImportFeedsTask; |
|
1054 friend class CFeedsServerSession; |
|
1055 }; |
|
1056 |
|
1057 #endif // FEEDS_DATABASE_H |
|
1058 |
|
1059 // End of File |