|
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 client side connection to a folder on the FeedsSever. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef FEEDS_SERVER_FOLDER_ITEM_H |
|
20 #define FEEDS_SERVER_FOLDER_ITEM_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <e32std.h> |
|
25 |
|
26 #include <FeedsServerRequestHandler.h> |
|
27 #include "FeedsEntity.h" |
|
28 #include "LeakTracker.h" |
|
29 |
|
30 #include "Transaction.h" |
|
31 |
|
32 // CONSTANTS |
|
33 |
|
34 // MACROS |
|
35 |
|
36 // DATA TYPES |
|
37 |
|
38 // FUNCTION PROTOTYPES |
|
39 |
|
40 // FORWARD DECLARATIONS |
|
41 |
|
42 // CLASS DECLARATION |
|
43 class CItemMini; |
|
44 class CFolderItem; |
|
45 class CPackedFolder; |
|
46 class RFeedsServer; |
|
47 class CFolderItemRequestHandler; |
|
48 class CFolderItemRequestHandler; |
|
49 /** |
|
50 * The RFolderItem observer interface. |
|
51 * |
|
52 * \b Library: FeedsEngine.lib |
|
53 * |
|
54 * @since 3.1 |
|
55 */ |
|
56 class MFolderItemObserver : public MConnectionObserver |
|
57 { |
|
58 public: // New Methods |
|
59 /** |
|
60 * Notifies the observer that the request is completed. |
|
61 * |
|
62 * @since 3.1 |
|
63 * @param aStatus The result code of the request. |
|
64 * @return void. |
|
65 */ |
|
66 virtual void FolderItemRequestCompleted(TInt aStatus, CRequestHandler::TRequestHandlerType aRequestType=CRequestHandler::ENone) = 0; |
|
67 |
|
68 /** |
|
69 * Notifies the observer that the FolderItem has changed. The client |
|
70 * should request an updated copy from the server. |
|
71 * |
|
72 * @since 3.1 |
|
73 * @return void. |
|
74 */ |
|
75 virtual void FolderItemChanged() = 0; |
|
76 }; |
|
77 |
|
78 /** |
|
79 * The client side interface to a server resident FolderItem. |
|
80 * |
|
81 * \b Library: FeedsEngine.lib |
|
82 * |
|
83 * @since 3.1 |
|
84 */ |
|
85 class RFolderItem: public RSubSessionBase, public MRequestHandlerObserver |
|
86 { |
|
87 public: |
|
88 /** |
|
89 * C++ default constructor. |
|
90 */ |
|
91 IMPORT_C RFolderItem( MFolderItemObserver& aObserver, TInt aFolderListId = 0, TBool aItemTitleNeed = EFalse ); |
|
92 |
|
93 |
|
94 public: // From MRequestHandlerObserver |
|
95 |
|
96 virtual void SendAsyncCommand(TInt /*aFunction*/, const TIpcArgs& /*aArgs*/, |
|
97 TRequestStatus& /*aStatus*/) const { } ; |
|
98 |
|
99 /** |
|
100 * Notifies the observer that the request is completed. |
|
101 * |
|
102 * @since 3.1 |
|
103 * @param aRequestHandler The request handler. |
|
104 * @param aStatus The result code of the request. |
|
105 * @return void. |
|
106 */ |
|
107 virtual void RequestHandlerCompleted(CRequestHandler& /*aRequestHandler*/, |
|
108 TInt /*aStatus*/) { } ; |
|
109 |
|
110 /** |
|
111 * |
|
112 */ |
|
113 virtual void CancelAllCommandsL() { } ; |
|
114 |
|
115 /** |
|
116 * Request to create a network connection. |
|
117 * |
|
118 * @since 3.1 |
|
119 * @param aConnectionPtr A pointer to the new connection. If NULL, the |
|
120 * proxy filter will automatically create a network connection. |
|
121 * @param aSockSvrHandle A handle to the socket server. |
|
122 * @param aNewConn A flag if a new connection was created. If the |
|
123 * connection is not new, proxy filter optimization will not |
|
124 * read the proxy again from CommsBd. |
|
125 * @param aBearerType The bearer type of the new connection |
|
126 * @return void |
|
127 */ |
|
128 virtual void NetworkConnectionNeededL(TInt* aConnectionPtr, TInt& aSockSvrHandle, |
|
129 TBool& aNewConn, TApBearerType& aBearerType); |
|
130 |
|
131 public: // New methods |
|
132 |
|
133 /** |
|
134 * Notifies the observer that the request is completed. |
|
135 * |
|
136 * @since 3.1 |
|
137 * @param aRequestHandler The request handler. |
|
138 * @param aStatus The result code of the request. |
|
139 * @return void. |
|
140 */ |
|
141 void RequestHandlerCompletedL(CTransaction& aTrans, |
|
142 TInt aStatus); |
|
143 |
|
144 /** |
|
145 * Opens a session to the root FolderItem on the server. |
|
146 * |
|
147 * @since 3.1 |
|
148 * @param aFeedsServer The shared connection to the feeds server. |
|
149 * @return Error/success code |
|
150 */ |
|
151 IMPORT_C TInt Open(RFeedsServer &aFeedsServer); |
|
152 |
|
153 /** |
|
154 * Closes the session. |
|
155 * |
|
156 * @since 3.1 |
|
157 * @return void |
|
158 */ |
|
159 IMPORT_C void Close(); |
|
160 |
|
161 /** |
|
162 * Fetches the root FolderItem. FetchRootFolderItemCompleted |
|
163 * is called upon completion. |
|
164 * |
|
165 * @since 3.1 |
|
166 * @return void |
|
167 */ |
|
168 IMPORT_C void FetchRootFolderItemL(); |
|
169 |
|
170 /** |
|
171 * Request the feeds server to add a new folder item. |
|
172 * |
|
173 * @since 3.1 |
|
174 * @param aName The name of the item. |
|
175 * @param aUrl The url of the item. |
|
176 * @param aIsFolder True if this is a folder. |
|
177 * @param aParent The parent folder. |
|
178 * @return void |
|
179 */ |
|
180 IMPORT_C void AddFolderItemL(const TDesC& aName, const TDesC& aUrl, |
|
181 TBool aIsFolder, const CFolderItem& aParent); |
|
182 |
|
183 /** |
|
184 * Request the feeds server to change the folder item. If this |
|
185 * is a folder then KNullDesC should be passed to the aUrl argument. |
|
186 * |
|
187 * @since 3.1 |
|
188 * @param aFolderItem The item to update. |
|
189 * @param aTitle The item's title.. |
|
190 * @param aUrl The item's url or KNullDesC. |
|
191 * @return void |
|
192 */ |
|
193 IMPORT_C void ChangeFolderItemL(const CFolderItem& aFolderItem, |
|
194 const TDesC& aTitle, const TDesC& aUrl); |
|
195 |
|
196 /** |
|
197 * Request the feeds server to delete the folder items |
|
198 * |
|
199 * @since 3.1 |
|
200 * @param aFolderItem The folder item that's being deleted. |
|
201 * @return void |
|
202 */ |
|
203 IMPORT_C void DeleteFolderItemsL(RPointerArray<const CFolderItem>& aFolderItems); |
|
204 |
|
205 /** |
|
206 * Request the feeds server to move the folder item to a different |
|
207 * parent. |
|
208 * |
|
209 * @since 3.1 |
|
210 * @param aFolderItem The folder item that's being moved. |
|
211 * @param aParent The folder item's new parent. |
|
212 * @return void |
|
213 */ |
|
214 IMPORT_C void MoveFolderItemsToL(RPointerArray<const CFolderItem>& aFolderItems, |
|
215 const CFolderItem& aParent); |
|
216 |
|
217 /** |
|
218 * Request the feeds server to move the folder item to a different |
|
219 * index. |
|
220 * |
|
221 * @since 3.1 |
|
222 * @param aFolderItem The folder item that's being moved. |
|
223 * @param aIndex The new index of the folder item (within its parent). |
|
224 * @return void |
|
225 */ |
|
226 IMPORT_C void MoveFolderItemsL(RPointerArray<const CFolderItem>& aFolderItems, |
|
227 TInt aIndex); |
|
228 |
|
229 /** |
|
230 * Request the feeds server to update the folder items (refresh them from the web). |
|
231 * |
|
232 * @since 3.1 |
|
233 * @param aFolderItems The folder items being updated, has to be feed, not folder |
|
234 * @return void |
|
235 */ |
|
236 IMPORT_C void UpdateFolderItemsL(const RPointerArray<const CFolderItem>& aFolderItems); |
|
237 |
|
238 /** |
|
239 * Request the feeds server to update all the folder items (refresh them from |
|
240 * the web) in a current folder-list. |
|
241 * |
|
242 * @since 3.1 |
|
243 * @return void |
|
244 */ |
|
245 IMPORT_C void UpdateAllL(); |
|
246 |
|
247 /** |
|
248 * Sets up a notifier to execute when the folder list changes. |
|
249 * |
|
250 * @since 3.1 |
|
251 * @param aFolderListId The folder-list's id. |
|
252 * @return void |
|
253 */ |
|
254 IMPORT_C void WatchFolderListL(); |
|
255 |
|
256 /** |
|
257 * Returns ETrue if it has an available root folder. |
|
258 * |
|
259 * @since 3.1 |
|
260 * @return Returns ETrue if it has an available root folder.. |
|
261 */ |
|
262 IMPORT_C TBool HasRootFolderItem() const; |
|
263 |
|
264 /** |
|
265 * Once fetched, it returns the root CFolderItem. This method panics the |
|
266 * client if it is called before the folder item is available. |
|
267 * |
|
268 * @since 3.1 |
|
269 * @return The root CFolderItem. |
|
270 */ |
|
271 IMPORT_C const CFolderItem& RootFolderItem() const; |
|
272 |
|
273 /** |
|
274 * Import OPML file passed from the client. |
|
275 * |
|
276 * @since 3.2 |
|
277 * @param aPath The OPML file path. |
|
278 * @param aClearFolderList Flag indicating to or not to clear entries under this Folder List before load OPML. |
|
279 * @return void. |
|
280 */ |
|
281 IMPORT_C void ImportOPMLL( const TDesC& aPath, TBool aClearFolderList = EFalse ); |
|
282 |
|
283 |
|
284 /** |
|
285 * Request the feeds server to export the folder items |
|
286 * |
|
287 * @since 3.2 |
|
288 * @param aFolderItem The folder item that's being exported. |
|
289 * @param aExportFileName The OPML file name. |
|
290 * @return void |
|
291 */ |
|
292 IMPORT_C void ExportFolderItemsL(RPointerArray<const CFolderItem>& aFolderItems, const TDesC &aExportFileName); |
|
293 |
|
294 public: |
|
295 friend class RFeedsServer; |
|
296 |
|
297 private: // Data |
|
298 MFolderItemObserver& iObserver; |
|
299 CFolderItem* iFolderItem; |
|
300 RPointerArray<CFolderItemRequestHandler> iActiveRequests; |
|
301 TInt iFolderListId; |
|
302 TBool iItemTitleNeed; |
|
303 RFeedsServer* iFeedsServer; |
|
304 |
|
305 }; |
|
306 |
|
307 |
|
308 /** |
|
309 * FolderItem either contains a list of FolderItems or contains |
|
310 * information about a feed. |
|
311 * |
|
312 * \b Library: FeedsEngine.lib |
|
313 * |
|
314 * @since 3.0 |
|
315 */ |
|
316 class CFolderItem: public CBase |
|
317 { |
|
318 public: // Destructor |
|
319 /** |
|
320 * Destructor. |
|
321 */ |
|
322 IMPORT_C virtual ~CFolderItem(); |
|
323 |
|
324 public: // New methods |
|
325 /** |
|
326 * Returns the folder-list-id associated with this item. |
|
327 * |
|
328 * @since 3.0 |
|
329 * @return the folder-list-id associated with this item. |
|
330 */ |
|
331 IMPORT_C TInt FolderListId(void) const; |
|
332 |
|
333 /** |
|
334 * Returns the parent folder or NULL if this is the root folder. |
|
335 * |
|
336 * @since 3.0 |
|
337 * @return The parent folder. |
|
338 */ |
|
339 IMPORT_C const CFolderItem* Parent(void) const; |
|
340 |
|
341 /** |
|
342 * Returns true if this is a folder. |
|
343 * |
|
344 * @since 3.0 |
|
345 * @return true or false. |
|
346 */ |
|
347 IMPORT_C TBool IsFolder(void) const; |
|
348 |
|
349 /** |
|
350 * Returns the name of the item. |
|
351 * |
|
352 * @since 3.0 |
|
353 * @return The item's name. |
|
354 */ |
|
355 IMPORT_C const TDesC& Name(void) const; |
|
356 |
|
357 /** |
|
358 * Returns the source url of the item. |
|
359 * |
|
360 * @since 3.0 |
|
361 * @return The item's source url. |
|
362 */ |
|
363 IMPORT_C const TDesC& SourceUrl(void) const; |
|
364 |
|
365 /** |
|
366 * Returns the timestamp of the last update. |
|
367 * |
|
368 * @since 3.1 |
|
369 * @return The item's timestamp of the last update. |
|
370 */ |
|
371 IMPORT_C const TTime& Timestamp(void) const; |
|
372 |
|
373 /** |
|
374 * Returns the number of unread topics for this folder-item. |
|
375 * |
|
376 * @since 3.1 |
|
377 * @return The number of unread topics for this folder-item. |
|
378 */ |
|
379 IMPORT_C TInt UnreadCount(void) const; |
|
380 |
|
381 /** |
|
382 * Returns the number of unread feeds for this folder-item. |
|
383 * |
|
384 * @since 5.0 |
|
385 * @return The number of unread feeds (those with > 1 unread topics) for |
|
386 * this folder item and all folders below it recursively |
|
387 */ |
|
388 IMPORT_C TInt UnreadFeedCountRecursive(void) const; |
|
389 |
|
390 /** |
|
391 * Returns the number of unread topics for this folder-item. |
|
392 * |
|
393 * @since 5.0 |
|
394 * @return The number of unread topics within all feeds for |
|
395 * this folder item and all folders below it recursively |
|
396 */ |
|
397 IMPORT_C TInt UnreadTopicCountRecursive(void) const; |
|
398 |
|
399 /** |
|
400 * Returns the unique id for this folder-item. |
|
401 * |
|
402 * @since 3.0 |
|
403 * @return The item's id. |
|
404 */ |
|
405 IMPORT_C TInt Id(void) const; |
|
406 |
|
407 /** |
|
408 * Returns the associated feed id for this folder-item. The |
|
409 * method panics if the folder-item is a folder (rather than a feed). |
|
410 * |
|
411 * @since 3.1 |
|
412 * @return The item's feed id. |
|
413 */ |
|
414 IMPORT_C TInt FeedId(void) const; |
|
415 |
|
416 /** |
|
417 * Returns the folder-item at the given index |
|
418 * |
|
419 * @since 3.0 |
|
420 * @param aIndex The index of the item. |
|
421 * @return Returns the item. |
|
422 */ |
|
423 IMPORT_C const CFolderItem* FolderItemAt(TInt aIndex) const; |
|
424 |
|
425 /** |
|
426 * Returns the index of the given folder-item. |
|
427 * |
|
428 * @since 3.0 |
|
429 * @param aItem The item to find |
|
430 * @return The item's index or KErrNotFound. |
|
431 */ |
|
432 IMPORT_C TInt Index(const CFolderItem& aItem) const; |
|
433 |
|
434 /** |
|
435 * Returns the number of items. |
|
436 * |
|
437 * @since 3.0 |
|
438 * @return The number of items. |
|
439 */ |
|
440 IMPORT_C TInt FolderItemCount(void) const; |
|
441 |
|
442 /** |
|
443 * Searches for a FolderItem with the given name. If "this" |
|
444 * isn't a folder it only checks whether or not it matches |
|
445 * the given name. If "this" is a folder it also checks |
|
446 * all embedded items. |
|
447 * |
|
448 * @since 3.0 |
|
449 * @param aName The name to search for. |
|
450 * @return The matching FolderItem or NULL. |
|
451 */ |
|
452 IMPORT_C const CFolderItem* Search(const TDesC& aName) const; |
|
453 |
|
454 /** |
|
455 * Searches for a FolderItem with the given id. If "this" |
|
456 * isn't a folder it only checks whether or not it matches |
|
457 * the given id. If "this" is a folder it also checks |
|
458 * all embedded items. |
|
459 * |
|
460 * @since 3.1 |
|
461 * @param aFolderItemId The id to search for. |
|
462 * @return The matching FolderItem or NULL. |
|
463 */ |
|
464 IMPORT_C const CFolderItem* Search(TInt aFolderItemId) const; |
|
465 |
|
466 /** |
|
467 * Returns the number of mini items. |
|
468 * |
|
469 * @since 3.2 |
|
470 * @return The number of mini items. |
|
471 */ |
|
472 IMPORT_C TInt MiniItemsCount(void) const; |
|
473 |
|
474 /** |
|
475 * Return The mini item. |
|
476 * |
|
477 * @since 3.2 |
|
478 * @return The array of items title. |
|
479 */ |
|
480 IMPORT_C const CItemMini* MiniItemAt( TInt aIndex ) const; |
|
481 |
|
482 /** |
|
483 * Sets the number of unread topics for this folder-item. |
|
484 * |
|
485 * @since 3.1 |
|
486 * Sets The number of unread topics for this folder-item. |
|
487 */ |
|
488 IMPORT_C void SetUnreadCount(TInt aUnreadCount); |
|
489 |
|
490 /** |
|
491 * Sets the number of unread topics for this folder-item. |
|
492 * |
|
493 * @since 5.0 |
|
494 * Returns the Status of Folder item |
|
495 */ |
|
496 IMPORT_C TInt Status() const; |
|
497 |
|
498 private: // New methods |
|
499 /** |
|
500 * Two-phased constructor. |
|
501 * Only called from RFolderItem. aPackedFolder is adopted by this method. |
|
502 */ |
|
503 static CFolderItem* NewL(TInt aFolderListId, CFeedsEntity* aFeedsEntity); |
|
504 |
|
505 /** |
|
506 * Two-phased constructor. |
|
507 */ |
|
508 static CFolderItem* NewFolderL( TInt aFolderListId, const TDesC& aTitle, TInt aEntryId, TInt aStatusCode); |
|
509 |
|
510 /** |
|
511 * Two-phased constructor. |
|
512 */ |
|
513 static CFolderItem* NewFeedL( TInt aFolderListId, const TDesC& aTitle, const TDesC& aUrl, |
|
514 TInt aEntryId, TInt aFeedId, const TTime& aTimestamp, TInt aStatusCode, const TInt& aUnreadCount=0 ); |
|
515 |
|
516 /** |
|
517 * C++ default constructor. aPackedFolder is adopted by this method. |
|
518 */ |
|
519 CFolderItem(TInt aFolderListId, CFeedsEntity* aFeedsEntity); |
|
520 |
|
521 /** |
|
522 * C++ default constructor. |
|
523 */ |
|
524 CFolderItem( TInt aFolderListId ); |
|
525 |
|
526 /** |
|
527 * By default Symbian 2nd phase constructor is private. |
|
528 */ |
|
529 void ConstructL(); |
|
530 |
|
531 /** |
|
532 * By default Symbian 2nd phase constructor is private. |
|
533 */ |
|
534 void ConstructL(const CFeedsEntity& aFeedsEntity); |
|
535 |
|
536 /** |
|
537 * Adds aItem as a child of this FolderItem. aItem is adopted by this method. |
|
538 * |
|
539 * @since 3.0 |
|
540 * @param aItem The item to append |
|
541 * @return void. |
|
542 */ |
|
543 void AddItemL(CFolderItem* aItem); |
|
544 |
|
545 /** |
|
546 * |
|
547 * |
|
548 * @since 3.2 |
|
549 * Sets |
|
550 */ |
|
551 void AddMiniItem( CItemMini* aMiniItem ); |
|
552 |
|
553 /** |
|
554 * A private function and associated enum (to be used as a flag for this function) |
|
555 * that will be called recursively to gather the count of feeds |
|
556 * |
|
557 * @since 5.0 |
|
558 * @param aFolder pointer to the "Root" of the tree folder item for counting |
|
559 * @param aCountType the type of count to be performed |
|
560 */ |
|
561 |
|
562 enum TCountType { ECountUnreadFeeds, ECountUnreadTopics }; |
|
563 static TInt GetFolderUnreadCount(const CFolderItem* aFolder, TCountType aCountType); |
|
564 |
|
565 public: // Friends |
|
566 friend class CFolderItemRequestHandler; |
|
567 friend class RFolderItem; |
|
568 |
|
569 private: |
|
570 TLeakTracker iLeakTracker; |
|
571 |
|
572 CFeedsEntity* iFeedsEntity; |
|
573 TInt iFolderListId; |
|
574 CPackedFolder* iPackedFolder; |
|
575 TPtrC iTitle; |
|
576 TPtrC iSourceUrl; |
|
577 TInt iEntryId; |
|
578 TInt iFeedId; |
|
579 TTime iTimestamp; |
|
580 TBool iIsFolder; |
|
581 TInt iUnreadCount; // how many unread topics |
|
582 TInt iStatusCode; |
|
583 |
|
584 const CFolderItem* iParent; |
|
585 RPointerArray<CFolderItem> iFolderItems; // children |
|
586 RPointerArray<CItemMini> iMiniItems; // minimum info of articles |
|
587 }; |
|
588 |
|
589 |
|
590 /** |
|
591 * Holds minimum information about a feed's item. |
|
592 * |
|
593 * \b Library: FeedsEngine.lib |
|
594 * |
|
595 * @since 3.0 |
|
596 */ |
|
597 class CItemMini: public CBase |
|
598 { |
|
599 public: // Destructor |
|
600 /** |
|
601 * Destructor. |
|
602 */ |
|
603 IMPORT_C virtual ~CItemMini(); |
|
604 |
|
605 public: // New methods |
|
606 /** |
|
607 * Returns the item's id. |
|
608 * |
|
609 * @since 3.1 |
|
610 * @return The value. |
|
611 */ |
|
612 IMPORT_C TInt Id() const; |
|
613 |
|
614 /** |
|
615 * Returns the item's title. |
|
616 * |
|
617 * @since 3.0 |
|
618 * @return The value. |
|
619 */ |
|
620 IMPORT_C const TDesC& Title() const; |
|
621 |
|
622 private: // New methods |
|
623 /** |
|
624 * Two-phased constructor. |
|
625 * Only called from RFeed. |
|
626 */ |
|
627 static CItemMini* NewL(); |
|
628 |
|
629 /** |
|
630 * C++ default constructor. |
|
631 */ |
|
632 CItemMini(); |
|
633 |
|
634 /** |
|
635 * By default Symbian 2nd phase constructor is private. |
|
636 */ |
|
637 void ConstructL(); |
|
638 |
|
639 /** |
|
640 * Sets an attribute. |
|
641 * |
|
642 * @since 3.1 |
|
643 * @param aAttribute The attribute. |
|
644 * @param aAttributeValue The attribute value. |
|
645 * @return void. |
|
646 */ |
|
647 void SetAttribute(TUint aAttribute, const TPtrC& aAttributeValue); |
|
648 |
|
649 public: // Friends |
|
650 friend class CFolderItem; |
|
651 |
|
652 private: // Data |
|
653 TLeakTracker iLeakTracker; |
|
654 TPtrC iTitle; |
|
655 TInt iId; |
|
656 }; |
|
657 |
|
658 #endif // FEEDS_SERVER_FOLDER_ITEM_H |
|
659 // End of File |