|
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 #include "TIptvRssSearchQuery.h" |
|
22 #include "CIptvEpgCategory.h" |
|
23 #include "CIptvEpgPluginInterface.h" |
|
24 #include "IptvDebug.h" |
|
25 #include "CIptvEpgContent.h" |
|
26 #include "CIptvMediaContent.h" |
|
27 #include <uri8.h> |
|
28 #include <uriutils.h> |
|
29 #include <bautils.h> |
|
30 #include <f32file.h> |
|
31 #include <centralrepository.h> |
|
32 |
|
33 #include "CIptvMyVideosGlobalFileId.h" |
|
34 #include "CIptvService.h" |
|
35 #include "CIptvSearchManager.h" |
|
36 #include "CIptvServer.h" |
|
37 #include "CIptvServiceManager.h" |
|
38 #include "CIptvVodContentContentBriefDetails.h" |
|
39 #include "CIptvVodContentCategoryBriefDetails.h" |
|
40 #include "CIptvVodContentContentFullDetails.h" |
|
41 #include "CIptvEpgVodMsqQueue.h" |
|
42 #include "CIptvContentIdMediaContentItem.h" |
|
43 #include "CIptvEpgSession.h" |
|
44 |
|
45 _LIT( KIptvSearchStringKeyword, "#search#" ); |
|
46 |
|
47 const TInt KParentalRatingOff = 0; |
|
48 |
|
49 // --------------------------------------------------------- |
|
50 // CIptvSearchManager::NewL |
|
51 // |
|
52 // --------------------------------------------------------- |
|
53 CIptvSearchManager* CIptvSearchManager::NewL( CIptvServer& aServer, |
|
54 CIptvEpgSession& aParent, |
|
55 CIptvEpgVodMsqQueue* aVodMsgQueue ) |
|
56 { |
|
57 CIptvSearchManager* self = new (ELeave) CIptvSearchManager( aServer, aParent ); |
|
58 CleanupStack::PushL( self ); |
|
59 self->ConstructL( aVodMsgQueue ); |
|
60 CleanupStack::Pop( self ); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------- |
|
65 // CIptvSearchManager::~CIptvSearchManager |
|
66 // |
|
67 // --------------------------------------------------------- |
|
68 CIptvSearchManager::~CIptvSearchManager() |
|
69 { |
|
70 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::~CIptvSearchManager()"); |
|
71 |
|
72 iUsedContentKeys.Reset(); |
|
73 |
|
74 ClearAllResults(); |
|
75 delete iFileMan; |
|
76 |
|
77 iVodMsgQueues.Reset(); |
|
78 delete iUpdater; |
|
79 delete iSearchCategory; |
|
80 delete iCurrentService; |
|
81 iAllContentFullDetails.ResetAndDestroy(); |
|
82 iMediaContents.ResetAndDestroy(); |
|
83 iFs.Close(); |
|
84 |
|
85 delete iRssPlugin; |
|
86 |
|
87 if ( iCenRepNotifyHandler ) |
|
88 { |
|
89 iCenRepNotifyHandler->StopListening(); |
|
90 delete iCenRepNotifyHandler; |
|
91 } |
|
92 |
|
93 delete iCenRepSession; |
|
94 |
|
95 delete iSearchUrlTemplate; |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------- |
|
99 // CIptvSearchManager::CIptvSearchManager |
|
100 // |
|
101 // --------------------------------------------------------- |
|
102 CIptvSearchManager::CIptvSearchManager( CIptvServer& aServer, |
|
103 CIptvEpgSession& aParent ) : |
|
104 iServer( aServer ), |
|
105 iParent( aParent ), |
|
106 iParentalControl( KParentalRatingOff ) |
|
107 { |
|
108 ResetContentKey(); |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------- |
|
112 // CIptvSearchManager::ConstructL |
|
113 // |
|
114 // --------------------------------------------------------- |
|
115 void CIptvSearchManager::ConstructL( CIptvEpgVodMsqQueue* aVodMsgQueue ) |
|
116 { |
|
117 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::ConstructL()"); |
|
118 |
|
119 User::LeaveIfError( iFs.Connect() ); |
|
120 |
|
121 iFileMan = CFileMan::NewL( iFs ); |
|
122 |
|
123 iVodMsgQueues.InsertInAddressOrder( aVodMsgQueue ); |
|
124 |
|
125 iUpdater = CIptvEpgManagerUpdater::NewL(*this); |
|
126 |
|
127 iSearchCategory = CIptvVodContentCategoryBriefDetails::NewL(); |
|
128 iSearchCategory->iCategoryId = KIptvVodContentCategoryRootId; |
|
129 iSearchCategory->iIsSearchCategory = ETrue; |
|
130 |
|
131 TRAPD( ret, iCenRepSession = CRepository::NewL( KIptvCenRepUid ) ); |
|
132 |
|
133 if ( ret == KErrNone && iCenRepSession ) |
|
134 { |
|
135 // Register CenRep change notifier. |
|
136 iCenRepNotifyHandler = CCenRepNotifyHandler::NewL( |
|
137 *this, |
|
138 *iCenRepSession, |
|
139 CCenRepNotifyHandler::EIntKey, |
|
140 KIptvCenRepParentControlKey ); |
|
141 iCenRepNotifyHandler->StartListeningL(); |
|
142 |
|
143 // Read settings from CenRep. |
|
144 ReadCenRepData(); |
|
145 } |
|
146 |
|
147 // Just to make sure we dont have null pointer available |
|
148 iSearchUrlTemplate = HBufC::NewL( 0 ); |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CIptvSearchManager::ReadCenRepData() |
|
153 // CenRep |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void CIptvSearchManager::ReadCenRepData() |
|
157 { |
|
158 IPTVLOGSTRING_LOW_LEVEL( "Search Mgr ## CIptvSearchManager::ReadCenRepData" ); |
|
159 |
|
160 if ( iCenRepSession ) |
|
161 { |
|
162 TInt age; |
|
163 if ( iCenRepSession->Get( KIptvCenRepParentControlKey, age ) != KErrNone ) |
|
164 { |
|
165 age = KIptvCenRepParentControlKeyDefault; |
|
166 } |
|
167 iParentalControl = age; |
|
168 } |
|
169 IPTVLOGSTRING2_LOW_LEVEL("Search Mgr ## Currently used parental rating = %d", iParentalControl ); |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------- |
|
173 // CIptvSearchManager::HandleNotifyInt |
|
174 // |
|
175 // --------------------------------------------------------- |
|
176 void CIptvSearchManager::HandleNotifyInt( TUint32 aId, TInt aNewValue ) |
|
177 { |
|
178 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::HandleNotifyInt"); |
|
179 if ( aId == KIptvCenRepParentControlKey ) |
|
180 { |
|
181 IPTVLOGSTRING2_LOW_LEVEL( "Search Mgr ## Parental control key changed. New value = %d", aNewValue ); |
|
182 iParentalControl = aNewValue; |
|
183 } |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------- |
|
187 // CIptvSearchManager::AddEpgVodMsgQueue |
|
188 // |
|
189 // --------------------------------------------------------- |
|
190 void CIptvSearchManager::AddEpgVodMsgQueue( CIptvEpgVodMsqQueue* aVodMsgQueue ) |
|
191 { |
|
192 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::UpdateEpgVodMsgQueue()"); |
|
193 |
|
194 if ( aVodMsgQueue ) |
|
195 { |
|
196 iVodMsgQueues.InsertInAddressOrder( aVodMsgQueue ); |
|
197 } |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------- |
|
201 // CIptvSearchManager::RemoveEpgVodMsgQueue |
|
202 // |
|
203 // --------------------------------------------------------- |
|
204 void CIptvSearchManager::RemoveEpgVodMsgQueue( CIptvEpgVodMsqQueue* aVodMsgQueue ) |
|
205 { |
|
206 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::RemoveEpgVodMsgQueue()"); |
|
207 |
|
208 for ( TInt i = 0; i < iVodMsgQueues.Count(); i++ ) |
|
209 { |
|
210 if ( iVodMsgQueues[i] == aVodMsgQueue ) |
|
211 { |
|
212 iVodMsgQueues.Remove( i ); |
|
213 return; |
|
214 } |
|
215 } |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------- |
|
219 // CIptvSearchManager::ParseSearchAddressL |
|
220 // |
|
221 // --------------------------------------------------------- |
|
222 void CIptvSearchManager::ParseSearchAddressL( TIptvRssSearchQuery& aQuery ) |
|
223 { |
|
224 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::ParseSearchAddressL()"); |
|
225 |
|
226 TInt newTotalLength = aQuery.SearchString().Length() + |
|
227 iSearchUrlTemplate->Length(); |
|
228 |
|
229 HBufC* parsedSearchUrl = HBufC::NewL( newTotalLength ); |
|
230 CleanupStack::PushL( parsedSearchUrl ); |
|
231 parsedSearchUrl->Des().Copy( *iSearchUrlTemplate ); |
|
232 |
|
233 // Try searching the 'search=' string from the template |
|
234 TInt queryLocation = parsedSearchUrl->Find( KIptvSearchStringKeyword ); |
|
235 if( queryLocation != KErrNotFound ) |
|
236 { |
|
237 // Replace KIptvSearchStringKeyword with given search string |
|
238 parsedSearchUrl->Des().Replace( queryLocation, |
|
239 KIptvSearchStringKeyword().Length(), |
|
240 aQuery.SearchString() ); |
|
241 } |
|
242 |
|
243 CUri8* inetUri = UriUtils::CreateUriL( *parsedSearchUrl ); |
|
244 CleanupStack::PushL( inetUri ); |
|
245 |
|
246 HBufC8* parameter = HBufC8::NewLC( inetUri->Uri().UriDes().Length() ); |
|
247 _LIT8( KStringFormat, "%S"); |
|
248 parameter->Des().Format( KStringFormat, |
|
249 &inetUri->Uri().UriDes() ); |
|
250 |
|
251 HBufC* actualSearchUrl = HBufC::NewLC( parameter->Length() ); |
|
252 actualSearchUrl->Des().Copy( *parameter ); |
|
253 |
|
254 iCurrentService->SetSearchUrlL( *actualSearchUrl ); |
|
255 CleanupStack::PopAndDestroy( actualSearchUrl ); |
|
256 CleanupStack::PopAndDestroy( parameter ); |
|
257 CleanupStack::PopAndDestroy( inetUri ); |
|
258 CleanupStack::PopAndDestroy( parsedSearchUrl ); |
|
259 } |
|
260 |
|
261 // --------------------------------------------------------- |
|
262 // CIptvSearchManager::UpdateUsedContentIdsListL |
|
263 // |
|
264 // --------------------------------------------------------- |
|
265 void CIptvSearchManager::UpdateUsedContentIdsListL( RArray<TInt>& aUsedIdArray ) |
|
266 { |
|
267 iUsedContentKeys.Reset(); |
|
268 for ( TInt i = 0; i < aUsedIdArray.Count(); i++ ) |
|
269 { |
|
270 IPTVLOGSTRING2_LOW_LEVEL("Search Mgr ## CIptvSearchManager::UpdateUsedContentIdsListL() adding Content ID %d to used list.", aUsedIdArray[i]); |
|
271 |
|
272 iUsedContentKeys.AppendL( aUsedIdArray[i] ); |
|
273 } |
|
274 } |
|
275 |
|
276 // --------------------------------------------------------- |
|
277 // CIptvSearchManager::Search |
|
278 // |
|
279 // --------------------------------------------------------- |
|
280 TInt CIptvSearchManager::Search( TIptvRssSearchQuery& aQuery ) |
|
281 { |
|
282 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::Search()"); |
|
283 |
|
284 TInt retVal = KErrNone; |
|
285 ClearAllResults(); |
|
286 |
|
287 if( IsSearchPossible() && !iPluginIsRunning ) |
|
288 { |
|
289 TInt err = KErrNone; |
|
290 TRAP( err, HandleSearchL( aQuery ) ); |
|
291 retVal = err; |
|
292 } |
|
293 else |
|
294 { |
|
295 retVal = KErrNotReady; |
|
296 } |
|
297 return retVal; |
|
298 } |
|
299 |
|
300 // --------------------------------------------------------- |
|
301 // CIptvSearchManager::CancelSearch |
|
302 // |
|
303 // --------------------------------------------------------- |
|
304 TInt CIptvSearchManager::CancelSearch() |
|
305 { |
|
306 iUpdater->Stop(); |
|
307 iPluginIsRunning = EFalse; |
|
308 delete iRssPlugin; |
|
309 iRssPlugin = NULL; |
|
310 // If vod update aint running, close ecom session |
|
311 if ( ! iParent.IsPluginRunning() ) |
|
312 { |
|
313 REComSession::FinalClose(); |
|
314 } |
|
315 |
|
316 ClearAllResults(); |
|
317 return KErrNone; |
|
318 } |
|
319 |
|
320 // --------------------------------------------------------- |
|
321 // CIptvSearchManager::HandleSearchL |
|
322 // |
|
323 // --------------------------------------------------------- |
|
324 void CIptvSearchManager::HandleSearchL( TIptvRssSearchQuery& aQuery ) |
|
325 { |
|
326 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::HandleSearchL()"); |
|
327 |
|
328 ParseSearchAddressL( aQuery ); |
|
329 if( iRssPlugin ) |
|
330 { |
|
331 delete iRssPlugin; |
|
332 iRssPlugin = NULL; |
|
333 } |
|
334 |
|
335 iUpdater->Start(); |
|
336 |
|
337 iRssPlugin = CIptvEpgPluginInterface::NewL( iCurrentService->iUid ); |
|
338 iRssPlugin->SetVodCallback( this ); |
|
339 iRssPlugin->SetServiceInformation( iCurrentService, ETrue ); |
|
340 iPluginIsRunning = ETrue; |
|
341 iRssPlugin->RunPlugin(); |
|
342 } |
|
343 |
|
344 // --------------------------------------------------------- |
|
345 // CIptvSearchManager::SearchCategoryBriefDetailsL |
|
346 // |
|
347 // --------------------------------------------------------- |
|
348 CIptvVodContentCategoryBriefDetails* CIptvSearchManager::SearchCategoryContentBriefDetailsL() |
|
349 { |
|
350 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::SearchCategoryContentBriefDetailsL()"); |
|
351 |
|
352 CIptvVodContentCategoryBriefDetails* searchCat = NULL; |
|
353 if( IsSearchPossible() ) |
|
354 { |
|
355 searchCat = CIptvVodContentCategoryBriefDetails::NewL(); |
|
356 searchCat->iCategoryId = KIptvRssSearchCategoryId; |
|
357 searchCat->iIsSearchCategory = ETrue; |
|
358 searchCat->iContentCount = iSearchCategory->iContentCount; |
|
359 IPTVLOGSTRING2_LOW_LEVEL( "Content count for search category = %u", searchCat->iContentCount ); |
|
360 } |
|
361 return searchCat; |
|
362 } |
|
363 |
|
364 // --------------------------------------------------------- |
|
365 // CIptvSearchManager::GetSearchContentBriefDetailsL |
|
366 // |
|
367 // --------------------------------------------------------- |
|
368 void CIptvSearchManager::GetSearchContentBriefDetailsL( TIptvCategoryId aContentId, |
|
369 TDesC& /*aSearchString*/, |
|
370 TUint32 /*aFrom*/, |
|
371 TUint32 /*aAmount*/, |
|
372 TUint32& aTotalAmount, |
|
373 RPointerArray<CIptvVodContentContentBriefDetails>& aEcgList ) |
|
374 { |
|
375 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::GetSearchContentBriefDetailsL()"); |
|
376 |
|
377 TInt contentsAdded = 0; |
|
378 if( aContentId == KIptvRssSearchCategoryId ) |
|
379 { |
|
380 for( TInt i = 0; i < iAllContentFullDetails.Count(); i++ ) |
|
381 { |
|
382 CIptvVodContentContentFullDetails* fullDetails = iAllContentFullDetails[i]; // Owned by the array |
|
383 // Check the parental control |
|
384 if( iParentalControl == KParentalRatingOff || |
|
385 fullDetails->iRatingAge < iParentalControl ) |
|
386 { |
|
387 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## Parental rating check passed"); |
|
388 CIptvVodContentContentBriefDetails* bd = CIptvVodContentContentBriefDetails::NewL(); |
|
389 CleanupStack::PushL( bd ); |
|
390 bd->iContentId = fullDetails->iContentId; |
|
391 bd->iName.Copy( fullDetails->iName ); |
|
392 bd->iThumbnailPath.Copy( fullDetails->iThumbnailPath ); |
|
393 bd->iPlaytime = fullDetails->iPlaytime; |
|
394 bd->iSize = fullDetails->iSize; |
|
395 bd->iFileId->iDrive = fullDetails->iFileId->iDrive; |
|
396 bd->iFileId->iFileId = fullDetails->iFileId->iFileId; |
|
397 bd->iPreviewGlobalFileId->iDrive = fullDetails->iPreviewGlobalFileId->iDrive; |
|
398 bd->iPreviewGlobalFileId->iFileId = fullDetails->iPreviewGlobalFileId->iFileId; |
|
399 bd->iPubDate= fullDetails->iPubDate; |
|
400 bd->iLanguage.Copy( fullDetails->iLanguage ); |
|
401 bd->iRatingAge = fullDetails->iRatingAge; |
|
402 bd->SetBrowserUrlL( fullDetails->GetBrowserUrlL() ); |
|
403 aEcgList.AppendL( bd ); |
|
404 CleanupStack::Pop( bd ); |
|
405 contentsAdded++; |
|
406 } |
|
407 else |
|
408 { |
|
409 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## Content skipped. Reason: Parental Rating"); |
|
410 IPTVLOGSTRING2_LOW_LEVEL("Search Mgr ## Device parental rating = %d", iParentalControl ); |
|
411 IPTVLOGSTRING2_LOW_LEVEL("Search Mgr ## Contents parental rating = %d", fullDetails->iRatingAge ); |
|
412 } |
|
413 } |
|
414 } |
|
415 aTotalAmount = contentsAdded; |
|
416 } |
|
417 |
|
418 // --------------------------------------------------------- |
|
419 // CIptvSearchManager::GetParentCategory |
|
420 // |
|
421 // --------------------------------------------------------- |
|
422 TInt CIptvSearchManager::GetParentCategory( TIptvCategoryId aCategoryId, |
|
423 TIptvCategoryId& aParentCategoryId ) |
|
424 { |
|
425 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::GetParentCategory()"); |
|
426 |
|
427 TInt retVal = KErrNotSupported; |
|
428 if( aCategoryId == KIptvRssSearchCategoryId ) |
|
429 { |
|
430 aParentCategoryId = KIptvVodContentCategoryRootId; |
|
431 retVal = KErrNone; |
|
432 } |
|
433 return retVal; |
|
434 } |
|
435 |
|
436 // --------------------------------------------------------- |
|
437 // CIptvSearchManager::SetServiceId |
|
438 // |
|
439 // --------------------------------------------------------- |
|
440 TInt CIptvSearchManager::SetServiceId( TUint32 aServiceId ) |
|
441 { |
|
442 IPTVLOGSTRING2_LOW_LEVEL("Search Mgr ## CIptvSearchManager::SetServiceId(%d)", aServiceId); |
|
443 iServiceId = aServiceId; |
|
444 return KErrNone; |
|
445 } |
|
446 |
|
447 // --------------------------------------------------------- |
|
448 // CIptvSearchManager::SetServiceL |
|
449 // |
|
450 // --------------------------------------------------------- |
|
451 void CIptvSearchManager::SetServiceL( CIptvEpgService* aService ) |
|
452 { |
|
453 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::SetServiceL()"); |
|
454 |
|
455 if( iCurrentService ) |
|
456 { |
|
457 delete iCurrentService; |
|
458 iCurrentService = NULL; |
|
459 } |
|
460 iCurrentService = CIptvEpgService::NewL(); |
|
461 |
|
462 iCurrentService->iAddress.Copy( aService->iAddress); |
|
463 iCurrentService->SetSearchUrlL( aService->SearchUrl() ); |
|
464 iCurrentService->iIap = aService->iIap; |
|
465 iCurrentService->iUserName.Copy( aService->iUserName ); |
|
466 iCurrentService->iPassword.Copy( aService->iPassword ); |
|
467 iCurrentService->iUid = aService->iUid; |
|
468 iCurrentService->iUpdateSet = aService->iUpdateSet; |
|
469 iCurrentService->iServiceType = aService->iServiceType; |
|
470 iCurrentService->iServiceId = aService->iServiceId; |
|
471 iCurrentService->iLastUpdated = aService->iLastUpdated; |
|
472 |
|
473 iServiceId = iCurrentService->iServiceId; |
|
474 |
|
475 if( iSearchUrlTemplate ) |
|
476 { |
|
477 delete iSearchUrlTemplate; |
|
478 iSearchUrlTemplate = NULL; |
|
479 } |
|
480 iSearchUrlTemplate = aService->SearchUrl().AllocL(); |
|
481 |
|
482 ResolveThumbnailDirectory(); |
|
483 } |
|
484 |
|
485 // --------------------------------------------------------- |
|
486 // CIptvSearchManager::ResolveThumbnailDirectory |
|
487 // |
|
488 // --------------------------------------------------------- |
|
489 void CIptvSearchManager::ResolveThumbnailDirectory() |
|
490 { |
|
491 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::ResolveThumbnailDirectory"); |
|
492 iThumbnailDirectory.Zero(); |
|
493 TRAPD( error, CIptvUtil::GetPathL( iFs, |
|
494 EIptvPathRssSearchThumbnail, |
|
495 iServiceId, |
|
496 iThumbnailDirectory, |
|
497 EFalse ) ); |
|
498 if( error != KErrNone ) |
|
499 { |
|
500 IPTVLOGSTRING2_LOW_LEVEL("CIptvUtil::GetPathL failed with error %d", error ); |
|
501 } |
|
502 } |
|
503 |
|
504 // --------------------------------------------------------- |
|
505 // CIptvSearchManager::SetIap |
|
506 // |
|
507 // --------------------------------------------------------- |
|
508 void CIptvSearchManager::SetIap( TUint32 aIap ) |
|
509 { |
|
510 IPTVLOGSTRING2_LOW_LEVEL("Search Mgr ## CIptvSearchManager::SetIap(%d)", aIap); |
|
511 |
|
512 iIap = aIap; |
|
513 } |
|
514 |
|
515 // --------------------------------------------------------- |
|
516 // CIptvSearchManager::StartedL |
|
517 // |
|
518 // --------------------------------------------------------- |
|
519 void CIptvSearchManager::StartedL() |
|
520 { |
|
521 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::StartedL() -- RSS Plugin STARTED!"); |
|
522 } |
|
523 |
|
524 // --------------------------------------------------------- |
|
525 // CIptvSearchManager::ContentUpdateCompletedL |
|
526 // |
|
527 // --------------------------------------------------------- |
|
528 void CIptvSearchManager::ContentUpdateCompletedL() |
|
529 { |
|
530 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::ContentUpdateCompletedL()"); |
|
531 // Service id = 0 because we dont have to bring this information |
|
532 // over IPC. Service ID is already on the client side. |
|
533 for ( TInt i = 0; i < iVodMsgQueues.Count(); i++ ) |
|
534 { |
|
535 if ( iVodMsgQueues[i] ) |
|
536 { |
|
537 iVodMsgQueues[i]->SendMessageToClientL( KIptvRssSearchContentUpdateCompleted, 0 ); |
|
538 } |
|
539 } |
|
540 } |
|
541 |
|
542 // --------------------------------------------------------- |
|
543 // CIptvSearchManager::FinishedL |
|
544 // |
|
545 // --------------------------------------------------------- |
|
546 TInt CIptvSearchManager::FinishedL( TTime& /*aUpdateInterval*/ ) |
|
547 { |
|
548 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::FinishedL() -- RSS Plugin FINISHED!"); |
|
549 |
|
550 iPluginIsRunning = EFalse; |
|
551 |
|
552 return KErrNone; |
|
553 } |
|
554 |
|
555 // --------------------------------------------------------- |
|
556 // CIptvSearchManager::AddCategoryL |
|
557 // |
|
558 // --------------------------------------------------------- |
|
559 TInt CIptvSearchManager::AddCategoryL( CIptvEpgCategory& /*aCategory*/, |
|
560 TUint32& /*aCategoryKey*/ ) |
|
561 { |
|
562 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::AddCategoryL()"); |
|
563 |
|
564 return KErrNone; |
|
565 } |
|
566 |
|
567 // --------------------------------------------------------- |
|
568 // CIptvSearchManager::AddContentL |
|
569 // |
|
570 // --------------------------------------------------------- |
|
571 TInt CIptvSearchManager::AddContentL( CIptvEpgContent& aContent, |
|
572 RPointerArray<CIptvMediaContent> aMediaContents, |
|
573 TUint32& aContentKey ) |
|
574 { |
|
575 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::AddContentL()"); |
|
576 |
|
577 IncrementContentKey(); |
|
578 aContentKey = GetContentKey(); |
|
579 CIptvVodContentContentFullDetails* details = CreateContentFullDetailsFromEpgDataL( aContent ); |
|
580 CleanupStack::PushL( details ); |
|
581 details->iContentId = GetContentKey(); |
|
582 iAllContentFullDetails.AppendL( details ); // Ownership in an array |
|
583 CleanupStack::Pop( details ); |
|
584 |
|
585 CIptvContentIdMediaContentItem* item = CIptvContentIdMediaContentItem::NewL(); |
|
586 CleanupStack::PushL( item ); |
|
587 item->SetContentId( GetContentKey() ); |
|
588 item->SetMediaContentArrayL( aMediaContents ); |
|
589 |
|
590 iMediaContents.AppendL( item ); // item variable's ownership now in iMediaContents |
|
591 CleanupStack::Pop( item ); |
|
592 |
|
593 iSearchCategory->iContentCount++; |
|
594 IPTVLOGSTRING2_LOW_LEVEL( "iSearchCategory->iContentCount = %u", iSearchCategory->iContentCount ); |
|
595 |
|
596 return KErrNone; |
|
597 } |
|
598 |
|
599 // --------------------------------------------------------- |
|
600 // CIptvSearchManager::UpdateServiceThumbnailL |
|
601 // |
|
602 // --------------------------------------------------------- |
|
603 TInt CIptvSearchManager::UpdateServiceThumbnailL( |
|
604 TDesC& /*aIconFilePath*/, |
|
605 const TBool /*aGrouped*/ ) |
|
606 { |
|
607 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::UpdateServiceThumbnailL()"); |
|
608 |
|
609 return KErrNone; |
|
610 } |
|
611 |
|
612 // --------------------------------------------------------- |
|
613 // CIptvSearchManager::AddRelationL |
|
614 // |
|
615 // --------------------------------------------------------- |
|
616 TInt CIptvSearchManager::AddRelationL( TUint32& /*aCategoryKey*/, |
|
617 TUint32& /*aContentKey*/ ) |
|
618 { |
|
619 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::AddRelationL()"); |
|
620 |
|
621 return KErrNone; |
|
622 } |
|
623 |
|
624 // --------------------------------------------------------- |
|
625 // CIptvSearchManager::ErrorL |
|
626 // |
|
627 // --------------------------------------------------------- |
|
628 void CIptvSearchManager::ErrorL(TInt aError, TInt aInfo ) |
|
629 { |
|
630 IPTVLOGSTRING3_LOW_LEVEL("Search Mgr ## CIptvSearchManager::ErrorL(%d, %d)", aError, aInfo); |
|
631 |
|
632 for ( TInt i = 0; i < iVodMsgQueues.Count(); i++ ) |
|
633 { |
|
634 if ( iVodMsgQueues[i] ) |
|
635 { |
|
636 iVodMsgQueues[i]->SendMessageToClientL(aError, aInfo); |
|
637 } |
|
638 } |
|
639 } |
|
640 |
|
641 // --------------------------------------------------------- |
|
642 // CIptvSearchManager::UpdateCategoryIconL |
|
643 // |
|
644 // --------------------------------------------------------- |
|
645 TInt CIptvSearchManager::UpdateCategoryIconL( |
|
646 TUint32& /*aCategoryKey*/, |
|
647 TUint32& /*aIconFileId*/, |
|
648 TDesC& aIconFilePath, |
|
649 TBool aIsUrl ) |
|
650 { |
|
651 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::UpdateCategoryIconL()"); |
|
652 |
|
653 if( !aIsUrl ) |
|
654 { |
|
655 iSearchCategory->iThumbnailPath.Copy( aIconFilePath ); |
|
656 } |
|
657 |
|
658 return KErrNone; |
|
659 } |
|
660 |
|
661 // --------------------------------------------------------- |
|
662 // CIptvSearchManager::UpdateContentIconL |
|
663 // |
|
664 // --------------------------------------------------------- |
|
665 TInt CIptvSearchManager::UpdateContentIconL( |
|
666 TUint32& aContentKey, |
|
667 TUint32& /*aIconFileId*/, |
|
668 TDesC& aIconFilePath, |
|
669 TBool aIsUrl ) |
|
670 { |
|
671 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::UpdateContentIconL()"); |
|
672 |
|
673 if( !aIsUrl ) |
|
674 { |
|
675 // Find the content |
|
676 for( TInt i = 0; i < iAllContentFullDetails.Count(); i++ ) |
|
677 { |
|
678 CIptvVodContentContentFullDetails* fd = iAllContentFullDetails[i]; |
|
679 if( fd->iContentId == aContentKey ) |
|
680 { |
|
681 fd->iThumbnailPath.Copy( aIconFilePath ); |
|
682 } |
|
683 } |
|
684 } |
|
685 |
|
686 return KErrNone; |
|
687 } |
|
688 |
|
689 // --------------------------------------------------------- |
|
690 // CIptvSearchManager::IsSearchPossible |
|
691 // |
|
692 // --------------------------------------------------------- |
|
693 TBool CIptvSearchManager::IsSearchPossible() const |
|
694 { |
|
695 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::IsSearchPossible()"); |
|
696 |
|
697 TBool isPossible = EFalse; |
|
698 // Here we check if there is |
|
699 if( iCurrentService && |
|
700 iSearchUrlTemplate && |
|
701 iSearchUrlTemplate->Length() > 0 ) |
|
702 { |
|
703 IPTVLOGSTRING_LOW_LEVEL("CIptvSearchManager::IsSearchPossible: Search is possible"); |
|
704 isPossible = ETrue; |
|
705 } |
|
706 else |
|
707 { |
|
708 IPTVLOGSTRING_LOW_LEVEL("CIptvSearchManager::IsSearchPossible: Search is NOT possible"); |
|
709 } |
|
710 return isPossible; |
|
711 } |
|
712 |
|
713 // --------------------------------------------------------- |
|
714 // CIptvSearchManager::PrepareForNewSearch |
|
715 // |
|
716 // --------------------------------------------------------- |
|
717 void CIptvSearchManager::ClearAllResults() |
|
718 { |
|
719 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::ClearAllResults()"); |
|
720 |
|
721 iAllContentFullDetails.ResetAndDestroy(); |
|
722 iMediaContents.ResetAndDestroy(); |
|
723 ResetContentKey(); |
|
724 // Remove contents of iThumbnailDirectory |
|
725 if( iThumbnailDirectory.Length() > 0 && |
|
726 BaflUtils::PathExists( iFs, iThumbnailDirectory ) ) |
|
727 { |
|
728 TInt error = iFileMan->Delete( iThumbnailDirectory, CFileMan::ERecurse ); |
|
729 if( error != KErrNone ) |
|
730 { |
|
731 IPTVLOGSTRING2_LOW_LEVEL("Failed to remove directory %S", &iThumbnailDirectory ); |
|
732 } |
|
733 } |
|
734 |
|
735 iSearchCategory->iContentCount = 0; |
|
736 } |
|
737 |
|
738 // --------------------------------------------------------- |
|
739 // CIptvSearchManager::GetContentAccessListL |
|
740 // |
|
741 // --------------------------------------------------------- |
|
742 void CIptvSearchManager::GetContentAccessListL( |
|
743 TUint32 aContentId, |
|
744 RPointerArray<CIptvMediaContent>& aContents ) |
|
745 { |
|
746 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::GetContentAccessListL()"); |
|
747 |
|
748 for( TInt i = 0; i < iMediaContents.Count(); i++ ) |
|
749 { |
|
750 if( iMediaContents[i]->ContentId() == aContentId ) |
|
751 { |
|
752 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::GetContentAccessListL() FOUND MATCH!"); |
|
753 iMediaContents[i]->GetMediaContentsL( aContents ); |
|
754 i = iMediaContents.Count(); // Get out of here. break; would work as well |
|
755 } |
|
756 } |
|
757 } |
|
758 |
|
759 // --------------------------------------------------------- |
|
760 // CIptvSearchManager::GetContentAccessL |
|
761 // |
|
762 // --------------------------------------------------------- |
|
763 CIptvMediaContent* CIptvSearchManager::GetContentAccessL( TUint32 aContentId, TUint32 aIndex ) |
|
764 { |
|
765 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::GetContentAccessL()"); |
|
766 |
|
767 CIptvMediaContent* returnContent = NULL; |
|
768 |
|
769 for( TInt i = 0; i < iMediaContents.Count(); i++ ) |
|
770 { |
|
771 CIptvContentIdMediaContentItem* contentItem = iMediaContents[i]; |
|
772 if( contentItem->ContentId() == aContentId ) |
|
773 { |
|
774 returnContent = contentItem->MediaContentByIndexL( aIndex ); |
|
775 i = iMediaContents.Count(); |
|
776 } |
|
777 } |
|
778 return returnContent; |
|
779 } |
|
780 |
|
781 // --------------------------------------------------------- |
|
782 // CIptvSearchManager::GetContentDetailsL |
|
783 // |
|
784 // --------------------------------------------------------- |
|
785 TInt CIptvSearchManager::GetContentDetailsL( TIptvContentId aContentId, |
|
786 CIptvVodContentContentFullDetails& aContentFullDetails ) |
|
787 { |
|
788 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::GetContentDetailsL()"); |
|
789 |
|
790 for( TInt i = 0; i < iAllContentFullDetails.Count(); i++ ) |
|
791 { |
|
792 CIptvVodContentContentFullDetails* content = iAllContentFullDetails[i]; |
|
793 if( content->iContentId == aContentId ) |
|
794 { |
|
795 aContentFullDetails.iContentId = content->iContentId; |
|
796 aContentFullDetails.iName.Copy( content->iName ); |
|
797 aContentFullDetails.iThumbnailPath.Copy( content->iThumbnailPath ); |
|
798 aContentFullDetails.iPlaytime = content->iPlaytime; |
|
799 aContentFullDetails.iSize = content->iSize; |
|
800 aContentFullDetails.iFileId->iDrive = content->iFileId->iDrive; |
|
801 aContentFullDetails.iFileId->iFileId = content->iFileId->iFileId; |
|
802 aContentFullDetails.iPreviewGlobalFileId->iDrive = content->iPreviewGlobalFileId->iDrive; |
|
803 aContentFullDetails.iPreviewGlobalFileId->iFileId = content->iPreviewGlobalFileId->iFileId; |
|
804 aContentFullDetails.iPubDate = content->iPubDate; |
|
805 aContentFullDetails.iLanguage.Copy( content->iLanguage ); |
|
806 aContentFullDetails.iRatingAge = content->iRatingAge; |
|
807 aContentFullDetails.iDescription.Copy( content->iDescription ); |
|
808 aContentFullDetails.iContentProtection = content->iContentProtection; |
|
809 aContentFullDetails.iAuthor.Copy( content->iAuthor ); |
|
810 aContentFullDetails.iCopyright.Copy( content->iCopyright ); |
|
811 } |
|
812 } |
|
813 return KErrNone; |
|
814 } |
|
815 |
|
816 // ----------------------------------------------------------------------------- |
|
817 // CIptvSearchManager::ResetGlobalId |
|
818 // |
|
819 // ----------------------------------------------------------------------------- |
|
820 TInt CIptvSearchManager::ResetGlobalId( CIptvMyVideosGlobalFileId& aId ) |
|
821 { |
|
822 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::ResetGlobalId()"); |
|
823 |
|
824 TInt error = KErrNone; |
|
825 TUint32 contentIdForMatch = 0; |
|
826 TInt i = 0; |
|
827 for( ; i < iMediaContents.Count(); i++ ) |
|
828 { |
|
829 CIptvContentIdMediaContentItem* contentItem = iMediaContents[i]; |
|
830 error = contentItem->ResetGlobalId( aId ); |
|
831 if( error == KErrNone ) |
|
832 { |
|
833 // Store the content id of the item we found the match to |
|
834 // be used to update parent details as well |
|
835 contentIdForMatch = contentItem->ContentId(); |
|
836 i = iMediaContents.Count(); // break; would've done the same |
|
837 } |
|
838 } |
|
839 |
|
840 // Update the parent's file id details as well |
|
841 if( error == KErrNone ) |
|
842 { |
|
843 for( i = 0; i < iAllContentFullDetails.Count(); i++ ) |
|
844 { |
|
845 CIptvVodContentContentFullDetails* bd = iAllContentFullDetails[i]; |
|
846 if( bd->iContentId == contentIdForMatch ) |
|
847 { |
|
848 bd->iFileId->iFileId = 0; |
|
849 bd->iFileId->iDrive = 0; |
|
850 i = iAllContentFullDetails.Count(); // break; would've done the same |
|
851 } |
|
852 } |
|
853 } |
|
854 return error; |
|
855 } |
|
856 |
|
857 // ----------------------------------------------------------------------------- |
|
858 // CIptvSearchManager::SetGlobalId |
|
859 // |
|
860 // ----------------------------------------------------------------------------- |
|
861 TInt CIptvSearchManager::SetGlobalId( TUint32 aContentKey, |
|
862 CIptvMyVideosGlobalFileId& aId, |
|
863 TUint32 aIndex ) |
|
864 { |
|
865 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::SetGlobalId()"); |
|
866 |
|
867 TInt error = KErrNotFound; |
|
868 TUint32 contentIdForMatch = 0; |
|
869 TInt i = 0; |
|
870 for( ; i < iMediaContents.Count(); i++ ) |
|
871 { |
|
872 CIptvContentIdMediaContentItem* contentItem = iMediaContents[i]; |
|
873 error = contentItem->SetGlobalId( aContentKey, aId, aIndex ); |
|
874 if( error == KErrNone ) |
|
875 { |
|
876 contentIdForMatch = contentItem->ContentId(); |
|
877 i = iMediaContents.Count(); // break; would've done the same thing |
|
878 } |
|
879 } |
|
880 |
|
881 // Update parent's file id details |
|
882 if( error == KErrNone ) |
|
883 { |
|
884 for( i = 0; i < iAllContentFullDetails.Count(); i++ ) |
|
885 { |
|
886 CIptvVodContentContentFullDetails* bd = iAllContentFullDetails[i]; |
|
887 if( bd->iContentId == contentIdForMatch ) |
|
888 { |
|
889 bd->iFileId->iFileId = aId.iFileId; |
|
890 bd->iFileId->iDrive = aId.iDrive; |
|
891 i = iAllContentFullDetails.Count(); // break; would've done the same |
|
892 } |
|
893 } |
|
894 } |
|
895 return error; |
|
896 } |
|
897 |
|
898 // ----------------------------------------------------------------------------- |
|
899 // CIptvSearchManager::CheckIsPluginRunning |
|
900 // |
|
901 // ----------------------------------------------------------------------------- |
|
902 void CIptvSearchManager::CheckIsPluginRunning() |
|
903 { |
|
904 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::CheckIsPluginRunning"); |
|
905 |
|
906 if ( ! iPluginIsRunning ) |
|
907 { |
|
908 iUpdater->Stop(); |
|
909 delete iRssPlugin; |
|
910 iRssPlugin = NULL; |
|
911 if ( ! iParent.IsPluginRunning() ) |
|
912 { |
|
913 REComSession::FinalClose(); |
|
914 } |
|
915 } |
|
916 } |
|
917 |
|
918 // ----------------------------------------------------------------------------- |
|
919 // CIptvSearchManager::CreateContentFullDetailsFromEpgDataL |
|
920 // |
|
921 // ----------------------------------------------------------------------------- |
|
922 CIptvVodContentContentFullDetails* CIptvSearchManager::CreateContentFullDetailsFromEpgDataL( |
|
923 CIptvEpgContent& aContent ) |
|
924 { |
|
925 IPTVLOGSTRING_LOW_LEVEL("Search Mgr ## CIptvSearchManager::CreateContentFullDetailsFromEpgDataL()"); |
|
926 |
|
927 CIptvVodContentContentFullDetails* details = CIptvVodContentContentFullDetails::NewL(); |
|
928 CleanupStack::PushL( details ); |
|
929 details->iContentId = aContent.iKey; |
|
930 details->iName.Copy( aContent.iName ); |
|
931 details->iThumbnailPath.Copy( aContent.iIconFilePath ); |
|
932 details->iPlaytime = aContent.iDuration; |
|
933 details->iSize = aContent.iSize; |
|
934 details->iPubDate = aContent.iPubDate; |
|
935 details->iLanguage.Copy( aContent.iLanguage ); |
|
936 details->iRatingAge = aContent.iRatingAge; |
|
937 details->iDescription.Copy( aContent.iDescription ); |
|
938 details->iContentProtection = aContent.iContentProtection; |
|
939 details->iAuthor.Copy( aContent.iAuthor ); |
|
940 details->iCopyright.Copy( aContent.iCopyright ); |
|
941 details->SetBrowserUrlL( aContent.iBrowserUrl ); |
|
942 CleanupStack::Pop( details ); |
|
943 return details; |
|
944 } |
|
945 |
|
946 // ----------------------------------------------------------------------------- |
|
947 // CIptvSearchManager::ResetContentKey |
|
948 // |
|
949 // ----------------------------------------------------------------------------- |
|
950 void CIptvSearchManager::ResetContentKey() |
|
951 { |
|
952 SetToNextAvailableContentKey( KIptvRssSearchInitialContentId ); |
|
953 |
|
954 IPTVLOGSTRING2_LOW_LEVEL("Search Mgr ## CIptvSearchManager::ResetContentKey() resetted to value %d.", iContentKey); |
|
955 } |
|
956 |
|
957 // ----------------------------------------------------------------------------- |
|
958 // CIptvSearchManager::IncrementContentKey |
|
959 // |
|
960 // ----------------------------------------------------------------------------- |
|
961 void CIptvSearchManager::IncrementContentKey() |
|
962 { |
|
963 SetToNextAvailableContentKey( iContentKey + 1 ); |
|
964 |
|
965 IPTVLOGSTRING2_LOW_LEVEL("Search Mgr ## CIptvSearchManager::IncrementContentKey() incremented to value %d.", iContentKey); |
|
966 } |
|
967 |
|
968 // ----------------------------------------------------------------------------- |
|
969 // CIptvSearchManager::GetContentKey |
|
970 // |
|
971 // ----------------------------------------------------------------------------- |
|
972 TUint32 CIptvSearchManager::GetContentKey() |
|
973 { |
|
974 return iContentKey; |
|
975 } |
|
976 |
|
977 // ----------------------------------------------------------------------------- |
|
978 // CIptvSearchManager::SetToNextAvailableContentKey |
|
979 // |
|
980 // ----------------------------------------------------------------------------- |
|
981 void CIptvSearchManager::SetToNextAvailableContentKey( TUint32 aBase ) |
|
982 { |
|
983 TBool found = EFalse; |
|
984 iContentKey = aBase; |
|
985 |
|
986 while ( ! found ) |
|
987 { |
|
988 found = ETrue; |
|
989 for ( TInt i = 0; i < iUsedContentKeys.Count(); i++ ) |
|
990 { |
|
991 if ( iContentKey == iUsedContentKeys[i] ) |
|
992 { |
|
993 found = EFalse; |
|
994 break; |
|
995 } |
|
996 } |
|
997 |
|
998 if ( ! found ) |
|
999 { |
|
1000 iContentKey++; |
|
1001 } |
|
1002 } |
|
1003 } |
|
1004 |
|
1005 // End of file. |