|
1 /* |
|
2 * Copyright (c) 2007 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CIPTVSEARCHMANAGER_H |
|
22 #define CIPTVSEARCHMANAGER_H |
|
23 |
|
24 // System includes |
|
25 #include <e32base.h> |
|
26 #include "MIptvEpgVodCallback.h" |
|
27 #include "MIptvEpgManagerUpdateObserver.h" |
|
28 #include "CIptvUtil.h" |
|
29 #include <cenrepnotifyhandler.h> |
|
30 #include "CIptvEpgManagerUpdater.h" |
|
31 |
|
32 // Forward declarations |
|
33 class TIptvRssSearchQuery; |
|
34 class CIptvVodContentContentFullDetails; |
|
35 class CIptvVodContentContentBriefDetails; |
|
36 class CIptvVodContentCategoryBriefDetails; |
|
37 class CIptvService; |
|
38 class CIptvServer; |
|
39 class CIptvEpgPluginInterface; |
|
40 class CIptvEpgVodMsqQueue; |
|
41 class CIptvContentIdMediaContentItem; |
|
42 class CIptvEpgSession; |
|
43 class CIptvEpgService; |
|
44 class CRepository; |
|
45 |
|
46 /** |
|
47 * CIptvSearchManager is the class to receive search requests from the client, |
|
48 * passes them to the RSS plugin and receives content information from the plugin |
|
49 * when it reports about downloaded and parsed categories and contents. This |
|
50 * class stores the found search results in RAM; results are not stored to any |
|
51 * database. |
|
52 * When new search is performed old search results will be deleted. |
|
53 */ |
|
54 class CIptvSearchManager : public CBase, |
|
55 public MIptvEpgVodCallback, |
|
56 public MIptvEpgManagerUpdateObserver, |
|
57 public MCenRepNotifyHandlerCallback |
|
58 { |
|
59 public: |
|
60 |
|
61 /** |
|
62 * Symbian two phase constructor |
|
63 * @param None |
|
64 * @return Pointer to a newly created CIptvSearchManager object |
|
65 */ |
|
66 static CIptvSearchManager* NewL( CIptvServer& aServer, |
|
67 CIptvEpgSession& aParent, |
|
68 CIptvEpgVodMsqQueue* aVodMsgQueue ); |
|
69 |
|
70 /** |
|
71 * Destructor |
|
72 */ |
|
73 ~CIptvSearchManager(); |
|
74 |
|
75 public: // New methods |
|
76 |
|
77 /** |
|
78 * Method to perform search |
|
79 */ |
|
80 TInt Search( TIptvRssSearchQuery& aQuery ); |
|
81 |
|
82 /** |
|
83 * Method to cancel current search. This causes the cleanup for |
|
84 * search results and RSS plugin to be stopped |
|
85 * @param None |
|
86 * @return None |
|
87 */ |
|
88 TInt CancelSearch(); |
|
89 |
|
90 /** |
|
91 * Getter for brief details of the search category. |
|
92 * @param None |
|
93 * @return Pointer to the brief details object that descvribes the search |
|
94 * category. If search is not possible we return NULL here. Ownership |
|
95 * of the returned object is transferred. |
|
96 */ |
|
97 CIptvVodContentCategoryBriefDetails* SearchCategoryContentBriefDetailsL(); |
|
98 |
|
99 /** |
|
100 * Getter method for the brief details of the specified content. |
|
101 * @param aContentId Id of the content that's details are requested |
|
102 * @param aSearchString Not used in search operations |
|
103 * @param aFrom Not used in search operations |
|
104 * @param aAmount Not used in search operations |
|
105 * @param aTotalAmount Number of details found for the given content id |
|
106 * @param aEcgList On return contains the list of the details object |
|
107 * that are matching the given content id |
|
108 */ |
|
109 void GetSearchContentBriefDetailsL( TIptvCategoryId aContentId, |
|
110 TDesC& aSearchString, |
|
111 TUint32 aFrom, |
|
112 TUint32 aAmount, |
|
113 TUint32& aTotalAmount, |
|
114 RPointerArray<CIptvVodContentContentBriefDetails>& aEcgList ); |
|
115 |
|
116 /** |
|
117 * Getter for the parent category for the given category. In this method |
|
118 * aCategoryId is compared with KIptvRssSearchCategoryId |
|
119 * @param aCategoryId Used to identify if parent category for the search |
|
120 * is asked (compared with KIptvRssSearchCategoryId) |
|
121 * @param aParentCategoryId On return contains KIptvVodContentCategoryRootId if |
|
122 * aCategoryId == KIptvRssSearchCategoryId) |
|
123 * @return KErrNone if aCategoryId == KIptvRssSearchCategoryId, otherwise KErrNotSupported |
|
124 */ |
|
125 TInt GetParentCategory( TIptvCategoryId aCategoryId, TIptvCategoryId& aParentCategoryId ); |
|
126 |
|
127 /** |
|
128 * Setter for service id. This method must be called before starting the |
|
129 * update. |
|
130 * @param aServiceId Value for current service's id |
|
131 * @return None |
|
132 */ |
|
133 TInt SetServiceId( TUint32 aServiceId ); |
|
134 |
|
135 /** |
|
136 * Sets the iap to be used for search operation. This variable is |
|
137 * passed to RSS plugin so it knows what iap user has selected. |
|
138 * @param aIap Iap to be used for search operations |
|
139 * @return None |
|
140 */ |
|
141 void SetIap( TUint32 aIap ); |
|
142 |
|
143 /** |
|
144 * Returns the boolean value if current service supports search |
|
145 * functionality |
|
146 * @param None |
|
147 * @return ETrue if search is possible, otherwise EFalse |
|
148 */ |
|
149 TBool IsSearchPossible() const; |
|
150 |
|
151 /** |
|
152 * Setter for the service information to be used for the search operations. |
|
153 * Given service defines if the search operations are allowed for the service |
|
154 * and as well as the url for the search operations. Contents of the aService |
|
155 * are stored into the iCurrentService member variable. |
|
156 * @param aService Pointer to the service object that describes currently |
|
157 * active service. |
|
158 */ |
|
159 void SetServiceL( CIptvEpgService* aService ); |
|
160 |
|
161 /** |
|
162 * Method to retrieve a list of media content access definitions for |
|
163 * the specified content id. There might be different locations for same content |
|
164 * where bitrate, mime type and so on can vary. Higher level implementations |
|
165 * can select the proper content from the list to be downloaded. |
|
166 * @param aContentId Content id which media contents are to be retrieved |
|
167 * @param aContents On return contains the list of different sets of |
|
168 * media contents available for specified content. |
|
169 */ |
|
170 void GetContentAccessListL( TUint32 aContentId, RPointerArray<CIptvMediaContent>& aContents ); |
|
171 |
|
172 /** |
|
173 * Method to retrieve the proper media content based on the content id |
|
174 * and an index inside the array of media contents of aContentId. |
|
175 * @param aContentId ContentId which content access is to be |
|
176 * retrieved |
|
177 * @param aIndex Index of the media content client is willing to retrieve. |
|
178 * @return On return contains the item from iMediaContents array that has |
|
179 * matching content id. |
|
180 */ |
|
181 CIptvMediaContent* GetContentAccessL( TUint32 aContentId, TUint32 aIndex ); |
|
182 |
|
183 /** |
|
184 * Getter for more specified data for the specified content. |
|
185 * @param aContentId Content id which details is to be retrieved |
|
186 * @param aContentFullDetails On return contains the full details of the |
|
187 * specified content. |
|
188 * @return KErrNone if successful, otherwise Symbian error code. |
|
189 */ |
|
190 TInt GetContentDetailsL( TIptvContentId aContentId, |
|
191 CIptvVodContentContentFullDetails& aContentFullDetails ); |
|
192 |
|
193 /** |
|
194 * Method to add a message queue for the local array. |
|
195 * @param aVodMsgQueue Message queue pointer to be inserted to the |
|
196 * local array. |
|
197 * @return None |
|
198 */ |
|
199 void AddEpgVodMsgQueue( CIptvEpgVodMsqQueue* aVodMsgQueue ); |
|
200 |
|
201 /** |
|
202 * Method to remove specified message queue object from the local array. |
|
203 * @param aVodMsgQueue Message queue pointer to be removed from |
|
204 * the array |
|
205 * @return None |
|
206 */ |
|
207 void RemoveEpgVodMsgQueue( CIptvEpgVodMsqQueue* aVodMsgQueue ); |
|
208 |
|
209 /** |
|
210 * Clears all the results and returns the search manager to initiate |
|
211 * state. This method call takes care of freeing all the memory in |
|
212 * the arrays inside this class as well as deleting thumbnails |
|
213 * downloaded for search result located in iThumbnailDirectory. |
|
214 * @param None |
|
215 * @return None |
|
216 */ |
|
217 void ClearAllResults(); |
|
218 |
|
219 /** |
|
220 * Updates Search Manager's list of Content ID numbers that have been |
|
221 * used by downloads from previous search results. This method should |
|
222 * be called before starting a new search. Call is external, because |
|
223 * Search Manager does not have all the necessary dependencies to generate |
|
224 * the list. |
|
225 * |
|
226 * @param aUsedIdArray New array of used Content ID numbers. |
|
227 */ |
|
228 void UpdateUsedContentIdsListL( RArray<TInt>& aUsedIdArray ); |
|
229 |
|
230 public: // Methods to satisfy MIptvEpgVodCallback inheritance |
|
231 |
|
232 /** |
|
233 * Method called by the plugin to tell that plugin has started doing |
|
234 * it's job. |
|
235 * @param None |
|
236 * @return None |
|
237 */ |
|
238 void StartedL(); |
|
239 |
|
240 /** |
|
241 * ECG content update from XML completed. Thumbnails are not downloaded yet. |
|
242 * @param None |
|
243 * @return None |
|
244 */ |
|
245 void ContentUpdateCompletedL(); |
|
246 |
|
247 /** |
|
248 * Method to used to signalize that plugin has finished it's job |
|
249 * @param aUpdateInterval Update interval defines how long EPG data |
|
250 * is valid. |
|
251 * @return KErrNone if successful, otherwise some of the Symbian wide |
|
252 * error codes |
|
253 */ |
|
254 TInt FinishedL( TTime& aUpdateInterval ); |
|
255 |
|
256 /** |
|
257 * Adds new category to be added to the result array |
|
258 * |
|
259 * @param aCategory Reference to CIptvEpgCategory object. |
|
260 * @param aCategoryKey New category key value is inserted to |
|
261 * aCategoryKey |
|
262 * @return KErrNone if successful, otherwise another |
|
263 * of the system-wide error codes. |
|
264 */ |
|
265 TInt AddCategoryL( CIptvEpgCategory& aCategory, TUint32& aCategoryKey ); |
|
266 |
|
267 /** |
|
268 * Adds new content to added to the result array |
|
269 * @param aContent Reference to CIptvEpgContent object. |
|
270 * @param aMediaContents Pointer array containing media content objects. |
|
271 * There can be n media content's for one content. |
|
272 * @param aContentKey New content key value is inserted to aContentKey |
|
273 * @return KErrNone if successful, otherwise another of the system-wide |
|
274 error codes. |
|
275 */ |
|
276 TInt AddContentL( CIptvEpgContent& aContent, |
|
277 RPointerArray<CIptvMediaContent> aMediaContents, |
|
278 TUint32& aContentKey ); |
|
279 |
|
280 /** |
|
281 * Updates the thumbnail path for the service. |
|
282 * @param aIconFilePath Full path to service thumbnail in local filesystem. |
|
283 * @param aGrouped if true updates also grouped item, otherwise not. |
|
284 * @return KErrNone if successful, otherwise another of the system-wide |
|
285 * error codes. |
|
286 */ |
|
287 TInt UpdateServiceThumbnailL( TDesC& aIconFilePath, const TBool aGrouped ); |
|
288 |
|
289 /** |
|
290 * Add content to specified category. Value is updated to the result array |
|
291 * @param aCategoryKey Category key. |
|
292 * @param aContentKey Content key. |
|
293 * @return KErrNone on success, otherwise one of the system-wide error codes |
|
294 */ |
|
295 TInt AddRelationL( TUint32& aCategoryKey, TUint32& aContentKey ); |
|
296 |
|
297 /** |
|
298 * Error that has occured during the parsing |
|
299 * @param aError Error code describing the occured error |
|
300 * @return None |
|
301 */ |
|
302 void ErrorL(TInt aError, TInt aInfo); |
|
303 |
|
304 /** |
|
305 * Method to update icon for a category |
|
306 * @param aCategoryKey Category key. |
|
307 * @param aIconFileId Icon file id to search from the database. |
|
308 * @param aIconFilePath Full path to icon file or URL + filename. |
|
309 * @param aIsUrl If aIconFilePath is URL aIsUrl == ETrue, |
|
310 * if aIconFilePath is path to local filesystem |
|
311 * aIsUrl == EFalse. |
|
312 * @return KErrNone if successful, otherwise another of the system-wide error codes. |
|
313 */ |
|
314 TInt UpdateCategoryIconL( TUint32& aCategoryKey, |
|
315 TUint32& aIconFileId, |
|
316 TDesC& aIconFilePath, |
|
317 TBool aIsUrl); |
|
318 |
|
319 /** |
|
320 * Method to update icon for content |
|
321 * @param aCategoryKey Content key. |
|
322 * @param aIconFileId Icon file id to search from the database. |
|
323 * @param aIconFilePath Full path to icon file or URL + filename. |
|
324 * @param aIsUrl If aIconFilePath is URL aIsUrl == ETrue, |
|
325 * if aIconFilePath is path to local filesystem |
|
326 * aIsUrl == EFalse. |
|
327 * @return KErrNone if successful, otherwise another of the system-wide error codes. |
|
328 */ |
|
329 TInt UpdateContentIconL( TUint32& aContentKey, |
|
330 TUint32& aIconFileId, |
|
331 TDesC& aIconFilePath, |
|
332 TBool aIsUrl); |
|
333 |
|
334 /** |
|
335 * Resets the global file id values for both media access array and |
|
336 * parent details as well |
|
337 * @param aId Id defining the global file id's to be reseted |
|
338 * @return KErrNone if successful, otherwise a Symbian error code |
|
339 */ |
|
340 TInt ResetGlobalId( CIptvMyVideosGlobalFileId& aId ); |
|
341 |
|
342 /** |
|
343 * Sets the global file id values for media content specified by content id |
|
344 * @param aContentKey Key to describe content id of the media content |
|
345 * @param aId Id defining the global file id's to be reseted |
|
346 * @param aIndex Index of media content array which details is updated |
|
347 * @return KErrNone if successful, otherwise a Symbian error code |
|
348 */ |
|
349 TInt SetGlobalId( TUint32 aContentKey, |
|
350 CIptvMyVideosGlobalFileId& aId, |
|
351 TUint32 aIndex ); |
|
352 |
|
353 public: // From MIptvEpgManagerUpdateObserver |
|
354 |
|
355 /** |
|
356 * Check if plugin is running, and closes everything down if plugin has |
|
357 * completed. |
|
358 */ |
|
359 void CheckIsPluginRunning(); |
|
360 |
|
361 /** |
|
362 * Returns ETrue if plugin is running. |
|
363 */ |
|
364 TBool IsPluginRunning() { return iPluginIsRunning; } |
|
365 |
|
366 public: // from MCenRepNotifyHandlerCallback |
|
367 /** |
|
368 * Receive notification about changed int value in central repository |
|
369 * @param aId Id of the key that is changed in the central |
|
370 * repository |
|
371 * @param aNewValue New value of aId in the central repository |
|
372 * @return None |
|
373 */ |
|
374 void HandleNotifyInt( TUint32 aId, TInt aNewValue ); |
|
375 |
|
376 |
|
377 private: // Private methods |
|
378 |
|
379 /** |
|
380 * Default constructor |
|
381 */ |
|
382 CIptvSearchManager( CIptvServer& aServer, CIptvEpgSession& aParent ); |
|
383 |
|
384 /** |
|
385 * Symbian second phase constructor for initialization code that might |
|
386 * leave |
|
387 * @param None |
|
388 * @return None |
|
389 */ |
|
390 void ConstructL( CIptvEpgVodMsqQueue* aVodMsgQueue ); |
|
391 |
|
392 /** |
|
393 * Method to take care of inserting search parameters to the search |
|
394 * http url. Search parameters are delivered to this class when |
|
395 * CIptvSearchManager::Search( TSearchQuery ) is called. Values found |
|
396 * from TSearchQuery is inserted into the search http address found |
|
397 * from CIptvService object's iSearchUrl. |
|
398 * @param None |
|
399 * @return None |
|
400 */ |
|
401 void ParseSearchAddressL( TIptvRssSearchQuery& aQuery ); |
|
402 |
|
403 /** |
|
404 * Handler method for search operation. This is the method that |
|
405 * actually creates the plugin instance and sets all the necessary |
|
406 * information for it in order to make metadata download and parsing |
|
407 * possible |
|
408 * @param aQuery Class that contains the search query parameters |
|
409 * @return None |
|
410 */ |
|
411 void HandleSearchL( TIptvRssSearchQuery& aQuery ); |
|
412 |
|
413 /** |
|
414 * Creates a full details item of plugin provided epg content object |
|
415 * @param aContent Content that contains the details to be stored |
|
416 * @return On return contains new full details object with details |
|
417 * provided by aContent |
|
418 */ |
|
419 CIptvVodContentContentFullDetails* |
|
420 CreateContentFullDetailsFromEpgDataL( CIptvEpgContent& aContent ); |
|
421 |
|
422 /** |
|
423 * Directory is parsed when search manager receives the information |
|
424 * about used service. Retrieved thumbnaildirectory path is stored to |
|
425 * iThumbnailDirectory member variable. |
|
426 * @param None |
|
427 * @return None |
|
428 */ |
|
429 void ResolveThumbnailDirectory(); |
|
430 |
|
431 /** |
|
432 * Reads the central repository values that are needed by the search |
|
433 * manager. |
|
434 * @param None |
|
435 * @return None |
|
436 */ |
|
437 void ReadCenRepData(); |
|
438 |
|
439 /** |
|
440 * Resets base Content key to first available value. |
|
441 */ |
|
442 void ResetContentKey(); |
|
443 |
|
444 /** |
|
445 * Increments base Content key to next available value. |
|
446 */ |
|
447 void IncrementContentKey(); |
|
448 |
|
449 /** |
|
450 * Return current value of base Content key. Call IncrementContentKey() |
|
451 * separately to increment the key to next value. |
|
452 * |
|
453 * @return Current value of base Content key. |
|
454 */ |
|
455 TUint32 GetContentKey(); |
|
456 |
|
457 /** |
|
458 * Sets base Content key to first available value starting from given base |
|
459 * value. Should not be called directly, as this is helper for other Content |
|
460 * key methods. |
|
461 * |
|
462 * @param aBase Base value for Content key's new value. |
|
463 */ |
|
464 void SetToNextAvailableContentKey( TUint32 aBase ); |
|
465 |
|
466 private: // Instance variables |
|
467 |
|
468 /** |
|
469 * This is the category that represents the 'Search' to be displayed at the UI |
|
470 */ |
|
471 CIptvVodContentCategoryBriefDetails* iSearchCategory; |
|
472 |
|
473 /** |
|
474 * Pointer array containing the parsed content from the search url. |
|
475 */ |
|
476 RPointerArray<CIptvVodContentContentFullDetails> iAllContentFullDetails; |
|
477 |
|
478 |
|
479 /** |
|
480 * Id for the service we are currently handling |
|
481 */ |
|
482 TUint32 iServiceId; |
|
483 |
|
484 /** |
|
485 * Locally stored object that has the details of the currently |
|
486 * active service. |
|
487 */ |
|
488 CIptvEpgService* iCurrentService; |
|
489 |
|
490 /** |
|
491 * Reference to the server object |
|
492 */ |
|
493 CIptvServer& iServer; |
|
494 |
|
495 /** |
|
496 * Epg session handle to check if vod update is run by RSS plugin |
|
497 */ |
|
498 CIptvEpgSession& iParent; |
|
499 |
|
500 /** |
|
501 * Array of vod message queues. |
|
502 */ |
|
503 RPointerArray<CIptvEpgVodMsqQueue> iVodMsgQueues; |
|
504 |
|
505 /** |
|
506 * Pointer to the RSS plugin. This plugin is used to perform the |
|
507 * search operation (download, parsing and content detail sending |
|
508 * to search manager) |
|
509 */ |
|
510 CIptvEpgPluginInterface* iRssPlugin; |
|
511 |
|
512 /** |
|
513 * Iap to be used for the search http transactions. |
|
514 */ |
|
515 TUint32 iIap; |
|
516 |
|
517 /** |
|
518 * Boolean to define if this instance of the search manager is |
|
519 * running a RSS plugin for the search. |
|
520 */ |
|
521 TBool iPluginIsRunning; |
|
522 |
|
523 /** |
|
524 * Array that contains the media content items for all the |
|
525 * found search results |
|
526 */ |
|
527 RPointerArray<CIptvContentIdMediaContentItem> iMediaContents; |
|
528 |
|
529 /** |
|
530 * Auto-increment value that is used as content id for the |
|
531 * CIptvVodContentContentFullDetails objects stored in |
|
532 * iAllContentFullDetails array. This value is set |
|
533 */ |
|
534 TUint32 iContentKey; |
|
535 |
|
536 /** |
|
537 * Array of Content ID numbers that have been used by downloads of previous |
|
538 * searches. Array is stored so we don't re-use same key for two downloads. |
|
539 */ |
|
540 RArray<TUint32> iUsedContentKeys; |
|
541 |
|
542 /** |
|
543 * Buf to contain the search url template that is used for search |
|
544 * This template contains the copy of search url value of the |
|
545 * iCurrentService |
|
546 */ |
|
547 HBufC* iSearchUrlTemplate; |
|
548 |
|
549 /** |
|
550 * Updater object that monitors the update progress |
|
551 */ |
|
552 CIptvEpgManagerUpdater* iUpdater; |
|
553 |
|
554 /** |
|
555 * Directory path pointing to directory where search thumbnails |
|
556 * are stored. |
|
557 */ |
|
558 TBuf<KIptvMaxPath> iThumbnailDirectory; |
|
559 |
|
560 /** |
|
561 * Fileserver session instance |
|
562 */ |
|
563 RFs iFs; |
|
564 |
|
565 /** |
|
566 * File manager instance used to delete directory that contains |
|
567 * thumbnails when this class get's deleted or we are about to |
|
568 * start new search |
|
569 */ |
|
570 CFileMan* iFileMan; |
|
571 |
|
572 /** |
|
573 * Central repository handle to read parental rating data |
|
574 */ |
|
575 CRepository* iCenRepSession; |
|
576 |
|
577 /** |
|
578 * Notify handler to receive notifications about changed value(s) |
|
579 * in central repository |
|
580 */ |
|
581 CCenRepNotifyHandler* iCenRepNotifyHandler; |
|
582 |
|
583 /** |
|
584 * Currently used parental rating value. This value is initialised |
|
585 * to 0 (KParentalRatingOff constant defined in .cpp file). Set value |
|
586 * is read from the central repository and this value can be updated |
|
587 * from central repository observer method HandleNotifyInt. |
|
588 */ |
|
589 TInt iParentalControl; |
|
590 }; |
|
591 |
|
592 #endif // CIPTVSEARCHMANAGER_H |
|
593 |
|
594 // End of file. |