17 */ |
17 */ |
18 |
18 |
19 #include <commdb.h> |
19 #include <commdb.h> |
20 #include "PodcastModel.h" |
20 #include "PodcastModel.h" |
21 #include "FeedEngine.h" |
21 #include "FeedEngine.h" |
22 #include "SoundEngine.h" |
|
23 #include "SettingsEngine.h" |
22 #include "SettingsEngine.h" |
24 #include "ShowEngine.h" |
23 #include "ShowEngine.h" |
25 #include "connectionengine.h" |
24 #include "connectionengine.h" |
26 |
25 |
27 #include <cmdestination.h> |
26 #include <cmdestination.h> |
214 return *iConnectionEngine; |
206 return *iConnectionEngine; |
215 } |
207 } |
216 |
208 |
217 EXPORT_C void CPodcastModel::PlayPausePodcastL(CShowInfo* aPodcast, TBool aPlayOnInit) |
209 EXPORT_C void CPodcastModel::PlayPausePodcastL(CShowInfo* aPodcast, TBool aPlayOnInit) |
218 { |
210 { |
219 |
211 // TODO: interact with MPX |
220 // special treatment if this podcast is already active |
212 } |
221 if (iPlayingPodcast->Uid() == aPodcast->Uid() && SoundEngine().State() > ESoundEngineOpening ) { |
|
222 if (aPodcast->PlayState() == EPlaying) { |
|
223 SoundEngine().Pause(); |
|
224 aPodcast->SetPosition(iSoundEngine->Position()); |
|
225 aPodcast->SetPlayState(EPlayed); |
|
226 aPodcast->SetPlayState(EPlayed); |
|
227 } else { |
|
228 iSoundEngine->Play(); |
|
229 } |
|
230 } else { |
|
231 // switching file, so save position |
|
232 iSoundEngine->Pause(); |
|
233 if (iPlayingPodcast != NULL) { |
|
234 iPlayingPodcast->SetPosition(iSoundEngine->Position()); |
|
235 } |
|
236 |
|
237 iSoundEngine->Stop(EFalse); |
|
238 |
|
239 // we play video podcasts through the external player |
|
240 if(aPodcast != NULL && aPodcast->ShowType() != EVideoPodcast) { |
|
241 DP1("Starting: %S", &(aPodcast->FileName())); |
|
242 TRAPD( error, iSoundEngine->OpenFileL(aPodcast->FileName(), aPlayOnInit) ); |
|
243 if (error != KErrNone) { |
|
244 DP1("Error: %d", error); |
|
245 } else { |
|
246 iSoundEngine->SetPosition(aPodcast->Position().Int64() / 1000000); |
|
247 } |
|
248 } |
|
249 |
|
250 iPlayingPodcast = aPodcast; |
|
251 } |
|
252 } |
|
253 |
213 |
254 EXPORT_C CFeedInfo* CPodcastModel::ActiveFeedInfo() |
214 EXPORT_C CFeedInfo* CPodcastModel::ActiveFeedInfo() |
255 { |
215 { |
256 return iActiveFeed; |
216 return iActiveFeed; |
257 } |
217 } |
277 } |
237 } |
278 } |
238 } |
279 |
239 |
280 sqlite3* CPodcastModel::DB() |
240 sqlite3* CPodcastModel::DB() |
281 { |
241 { |
|
242 DP("CPodcastModel::DB BEGIN"); |
282 if (iDB == NULL) { |
243 if (iDB == NULL) { |
283 TFileName dbFileName; |
244 TFileName dbFileName; |
284 dbFileName.Copy(iSettingsEngine->PrivatePath()); |
245 dbFileName.Copy(iSettingsEngine->PrivatePath()); |
285 //iFsSession.PrivatePath(dbFileName); |
246 //iFsSession.PrivatePath(dbFileName); |
286 dbFileName.Append(KDBFileName); |
247 dbFileName.Append(KDBFileName); |
296 iIsFirstStartup = ETrue; |
257 iIsFirstStartup = ETrue; |
297 } |
258 } |
298 |
259 |
299 TBuf8<KMaxFileName> filename8; |
260 TBuf8<KMaxFileName> filename8; |
300 filename8.Copy(dbFileName); |
261 filename8.Copy(dbFileName); |
301 int rc = rc = sqlite3_open((const char*) filename8.PtrZ(), &iDB); |
262 DP("Before sqlite3_open"); |
|
263 int rc = sqlite3_open((const char*) filename8.PtrZ(), &iDB); |
302 if( rc != SQLITE_OK){ |
264 if( rc != SQLITE_OK){ |
303 DP("Error loading DB"); |
265 DP("Error loading DB"); |
304 User::Panic(_L("Podcatcher"), 10); |
266 User::Panic(_L("Podcatcher"), 10); |
305 } |
267 } |
306 |
268 |
307 |
269 |
308 } |
270 } |
|
271 DP("CPodcastModel::DB END"); |
309 return iDB; |
272 return iDB; |
310 } |
273 } |
311 |
274 |
312 void CPodcastModel::SetProxyUsageIfNeededL(RHTTPSession& aSession) |
275 void CPodcastModel::SetProxyUsageIfNeededL(RHTTPSession& aSession) |
313 { |
276 { |
408 { |
371 { |
409 iActiveShowList.ResetAndDestroy(); |
372 iActiveShowList.ResetAndDestroy(); |
410 iShowEngine->GetShowsByFeedL(iActiveShowList, aFeedUid); |
373 iShowEngine->GetShowsByFeedL(iActiveShowList, aFeedUid); |
411 } |
374 } |
412 |
375 |
413 EXPORT_C void CPodcastModel::MarkSelectionPlayed() |
376 EXPORT_C void CPodcastModel::MarkSelectionPlayedL() |
414 { |
377 { |
415 for (int i=0;i<iActiveShowList.Count();i++) { |
378 for (int i=0;i<iActiveShowList.Count();i++) { |
416 if(iActiveShowList[i]->PlayState() != EPlayed) { |
379 if(iActiveShowList[i]->PlayState() != EPlayed) { |
417 iActiveShowList[i]->SetPlayState(EPlayed); |
380 iActiveShowList[i]->SetPlayState(EPlayed); |
418 iShowEngine->UpdateShow(*iActiveShowList[i]); |
381 iShowEngine->UpdateShowL(*iActiveShowList[i]); |
419 } |
382 } |
420 } |
383 } |
421 } |
384 } |
422 |
385 |
423 TInt CPodcastModel::FindActiveShowByUid(TUint aUid) |
386 TInt CPodcastModel::FindActiveShowByUid(TUint aUid) |