engine/inc/ShowEngine.h
changeset 60 4d230e702aa3
parent 2 29cda98b007e
child 65 bcd88ba95046
equal deleted inserted replaced
59:9569ea080d5a 60:4d230e702aa3
    25 #include "ShowInfo.h"
    25 #include "ShowInfo.h"
    26 #include "PodcastModel.h"
    26 #include "PodcastModel.h"
    27 #include "HttpClient.h"
    27 #include "HttpClient.h"
    28 #include "ShowEngineObserver.h"
    28 #include "ShowEngineObserver.h"
    29 #include "MetaDataReader.h"
    29 #include "MetaDataReader.h"
    30 #include "sqlite3.h"
    30 #include <sqlite3.h>
    31 
    31 
    32 class CShowEngine : public CBase, public MHttpClientObserver, public MMetaDataReaderObserver
    32 class CShowEngine : public CBase, public MHttpClientObserver, public MMetaDataReaderObserver
    33 {
    33 {
    34 public:
    34 public:
    35 	IMPORT_C static CShowEngine* NewL(CPodcastModel& aPodcastModel);
    35 	IMPORT_C static CShowEngine* NewL(CPodcastModel& aPodcastModel);
    36 	IMPORT_C virtual ~CShowEngine();
    36 	IMPORT_C virtual ~CShowEngine();
    37 	
    37 	
    38 public:
    38 public:
    39 	IMPORT_C void AddDownloadL(CShowInfo& info);
    39 	IMPORT_C void AddDownloadL(CShowInfo& info);
    40 	IMPORT_C TBool RemoveDownloadL(TUint aUid);
    40 	IMPORT_C void RemoveDownloadL(TUint aUid);
    41 	IMPORT_C void RemoveAllDownloads();
    41 	IMPORT_C void RemoveAllDownloadsL();
    42 
    42 
    43 	IMPORT_C void SuspendDownloads();
    43 	IMPORT_C void SuspendDownloads();
    44 	IMPORT_C void ResumeDownloadsL();
    44 	IMPORT_C void ResumeDownloadsL();
    45 
    45 
    46 	IMPORT_C TInt GetNumDownloadingShows();
    46 	IMPORT_C TInt GetNumDownloadingShows();
    54 	IMPORT_C void GetShowsDownloadedL(RShowInfoArray &aArray);
    54 	IMPORT_C void GetShowsDownloadedL(RShowInfoArray &aArray);
    55 	IMPORT_C void GetNewShowsL(RShowInfoArray &aArray);
    55 	IMPORT_C void GetNewShowsL(RShowInfoArray &aArray);
    56 	IMPORT_C void GetShowsDownloadingL(RShowInfoArray &aArray);
    56 	IMPORT_C void GetShowsDownloadingL(RShowInfoArray &aArray);
    57 	IMPORT_C CShowInfo* DBGetShowByFileNameL(TFileName aFileName);
    57 	IMPORT_C CShowInfo* DBGetShowByFileNameL(TFileName aFileName);
    58 	
    58 	
    59 	IMPORT_C TBool AddShowL(const CShowInfo& item);
    59 	IMPORT_C void AddShowL(const CShowInfo& item);
    60 	IMPORT_C void DeletePlayedShows(RShowInfoArray &aShowInfoArray);
    60 	IMPORT_C void DeletePlayedShowsL(RShowInfoArray &aShowInfoArray);
    61 	IMPORT_C void DeleteAllShowsByFeedL(TUint aFeedUid,TBool aDeleteFiles=ETrue);
    61 	IMPORT_C void DeleteAllShowsByFeedL(TUint aFeedUid,TBool aDeleteFiles=ETrue);
    62 	IMPORT_C void DeleteShowL(TUint aShowUid, TBool aRemoveFile=ETrue);
    62 	IMPORT_C void DeleteShowL(TUint aShowUid, TBool aRemoveFile=ETrue);
    63 	IMPORT_C void DeleteOldShowsByFeed(TUint aFeedUid);
    63 	IMPORT_C void DeleteOldShowsByFeedL(TUint aFeedUid);
    64 	
    64 	
    65 	IMPORT_C void AddObserver(MShowEngineObserver *observer);
    65 	IMPORT_C void AddObserver(MShowEngineObserver *observer);
    66 	IMPORT_C void RemoveObserver(MShowEngineObserver *observer);
    66 	IMPORT_C void RemoveObserver(MShowEngineObserver *observer);
    67 
    67 
    68 	IMPORT_C void NotifyShowListUpdatedL();
    68 	IMPORT_C void NotifyShowListUpdatedL();
    69 	IMPORT_C void UpdateShow(CShowInfo& aInfo);
    69 	IMPORT_C void UpdateShowL(CShowInfo& aInfo);
    70 
    70 
    71 	IMPORT_C void GetMimeType(const TDesC& aFileName, TDes& aMimeType);
    71 	IMPORT_C void GetMimeType(const TDesC& aFileName, TDes& aMimeType);
    72 
    72 
       
    73 	IMPORT_C void CheckForDeletedShows(TUint aFeedUid);
    73 	IMPORT_C CMetaDataReader& MetaDataReader();
    74 	IMPORT_C CMetaDataReader& MetaDataReader();
    74 
    75 
    75 private:
    76 private:
    76 	// from HttpClientObserver, dont have to be public
    77 	// from HttpClientObserver, dont have to be public
    77 	void Connected(CHttpClient* aClient);
    78 	void Connected(CHttpClient* aClient);
    79 	void CompleteL(CHttpClient* aClient, TInt aError);
    80 	void CompleteL(CHttpClient* aClient, TInt aError);
    80 	void Progress(CHttpClient* aHttpClient, int aBytes, int aTotalBytes);
    81 	void Progress(CHttpClient* aHttpClient, int aBytes, int aTotalBytes);
    81 	void DownloadInfo(CHttpClient* aClient, int aSize);
    82 	void DownloadInfo(CHttpClient* aClient, int aSize);
    82 	void FileError(TUint aError);
    83 	void FileError(TUint aError);
    83 	// from MetaDataReaderObserver
    84 	// from MetaDataReaderObserver
    84 	void ReadMetaData(CShowInfo& aShowInfo);
    85 	void ReadMetaDataL(CShowInfo& aShowInfo);
    85 	void ReadMetaDataCompleteL();
    86 	void ReadMetaDataCompleteL();
    86 	
    87 	
    87 private:
    88 private:
    88 	CShowEngine(CPodcastModel& aPodcastModel);
    89 	CShowEngine(CPodcastModel& aPodcastModel);
    89 	void ConstructL();
    90 	void ConstructL();
    90 
    91 
    91 	TBool GetShowL(CShowInfo *info);
    92 	void GetShowL(CShowInfo *info);
    92 
    93 
    93 	void NotifyDownloadQueueUpdatedL();
    94 	void NotifyDownloadQueueUpdatedL();
    94 	void NotifyShowDownloadUpdatedL(TInt aBytesOfCurrentDownload, TInt aBytesTotal);
    95 	void NotifyShowDownloadUpdatedL(TInt aBytesOfCurrentDownload, TInt aBytesTotal);
    95 	void NotifyShowFinishedL(TInt aError);
    96 	void NotifyShowFinishedL(TInt aError);
    96 	void DownloadNextShowL();
    97 	void DownloadNextShowL();
   104 
   105 
   105 private:
   106 private:
   106 	// DB methods
   107 	// DB methods
   107 	CShowInfo* DBGetShowByUidL(TUint aUid);
   108 	CShowInfo* DBGetShowByUidL(TUint aUid);
   108 	void DBFillShowInfoFromStmtL(sqlite3_stmt *st, CShowInfo* showInfo);
   109 	void DBFillShowInfoFromStmtL(sqlite3_stmt *st, CShowInfo* showInfo);
   109 	TBool DBAddShow(const CShowInfo& aItem);
   110 	void DBAddShowL(const CShowInfo& aItem);
   110 	TBool DBUpdateShow(CShowInfo& aItem);
   111 	void DBUpdateShowL(CShowInfo& aItem);
   111 	void DBGetShowsByFeedL(RShowInfoArray& aShowArray, TUint aFeedUid);
   112 	void DBGetShowsByFeedL(RShowInfoArray& aShowArray, TUint aFeedUid);
   112 	void DBGetAllShowsL(RShowInfoArray& aShowArray);
   113 	void DBGetAllShowsL(RShowInfoArray& aShowArray);
   113 	void DBGetNewShowsL(RShowInfoArray& aShowArray);
   114 	void DBGetNewShowsL(RShowInfoArray& aShowArray);
   114 	void DBGetDownloadedShowsL(RShowInfoArray& aShowArray);
   115 	void DBGetDownloadedShowsL(RShowInfoArray& aShowArray);
   115 	TBool DBDeleteAllShowsByFeed(TUint aFeedUid);
   116 	void DBDeleteAllShowsByFeedL(TUint aFeedUid);
   116 	void DBDeleteOldShowsByFeed(TUint aFeedUid);
   117 	void DBDeleteOldShowsByFeedL(TUint aFeedUid);
   117 	TBool DBDeleteShow(TUint aUid);
   118 	void DBDeleteShowL(TUint aUid);
   118 	void DBRemoveAllDownloads();
   119 	void DBRemoveAllDownloadsL();
   119 	void DBRemoveDownload(TUint aUid);
   120 	void DBRemoveDownloadL(TUint aUid);
   120 	void DBGetAllDownloadsL(RShowInfoArray& aShowArray);
   121 	void DBGetAllDownloadsL(RShowInfoArray& aShowArray);
   121 	TUint DBGetDownloadsCount();
   122 	TUint DBGetDownloadsCountL();
   122 	void DBAddDownload(TUint aUid);
   123 	void DBAddDownloadL(TUint aUid);
   123 	CShowInfo* DBGetNextDownloadL();
   124 	CShowInfo* DBGetNextDownloadL();
   124 	
   125 	
   125 private:
   126 private:
   126 	CHttpClient* iShowClient;			
   127 	CHttpClient* iShowClient;			
   127 		
   128