| 2 |      1 | /*
 | 
|  |      2 | * Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB
 | 
|  |      3 | *
 | 
|  |      4 | * All rights reserved.
 | 
|  |      5 | * This component and the accompanying materials are made available
 | 
|  |      6 | * under the terms of the License "Eclipse Public License v1.0"
 | 
|  |      7 | * which accompanies this distribution, and is available
 | 
|  |      8 | * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 | 
|  |      9 | *
 | 
|  |     10 | * Initial Contributors:
 | 
|  |     11 | * EmbedDev AB - initial contribution.
 | 
|  |     12 | *
 | 
|  |     13 | * Contributors:
 | 
|  |     14 | *
 | 
|  |     15 | * Description:
 | 
|  |     16 | *
 | 
|  |     17 | */
 | 
|  |     18 | 
 | 
|  |     19 | #ifndef PODCASTMODEL_H
 | 
|  |     20 | #define PODCASTMODEL_H
 | 
|  |     21 | #include <e32base.h>
 | 
|  |     22 | #include <eikenv.h>
 | 
|  |     23 | #include <commdb.h>
 | 
|  |     24 | #include <CommDbConnPref.h>
 | 
|  |     25 | #include <es_sock.h>
 | 
|  |     26 | #include <http/rhttpsession.h>
 | 
|  |     27 | #include <cmmanager.h>
 | 
|  |     28 | 
 | 
|  |     29 | #include "FeedInfo.h"
 | 
|  |     30 | #include "ShowInfo.h"
 | 
|  |     31 | #include "debug.h"
 | 
|  |     32 | #include "sqlite3.h"
 | 
|  |     33 | #include "ImageHandler.h"
 | 
|  |     34 | 
 | 
|  |     35 | // SQLite leaks memory when sorting, so to test our own memory leaks we need to disable this
 | 
|  |     36 | //#define DONT_SORT_SQL
 | 
|  |     37 | class RCmManager;
 | 
|  |     38 | class CFeedEngine;
 | 
|  |     39 | class CSoundEngine;
 | 
|  |     40 | class CShowEngine;
 | 
|  |     41 | class CSettingsEngine;
 | 
|  |     42 | class CCommsDatabase;
 | 
|  |     43 | class CConnectionEngine;
 | 
|  |     44 | 
 | 
|  |     45 | class TPodcastIAPItem
 | 
|  |     46 | {
 | 
|  |     47 | public:
 | 
|  |     48 | 	TUint32 iIapId;
 | 
|  |     49 | 	TBuf<KCommsDbSvrMaxFieldLength> iServiceType;
 | 
|  |     50 | 	TBuf<KCommsDbSvrMaxFieldLength> iBearerType;
 | 
|  |     51 | };
 | 
|  |     52 | 
 | 
|  |     53 | /**
 | 
|  |     54 |  * This class handles application storage needs and ownership of audioplayer, resource lists etc.
 | 
|  |     55 |  */
 | 
|  |     56 | class CPodcastModel : public CBase, public MImageHandlerCallback
 | 
|  |     57 | {
 | 
|  |     58 | public:
 | 
|  |     59 | 	IMPORT_C static CPodcastModel* NewL();
 | 
|  |     60 | 	IMPORT_C ~CPodcastModel();
 | 
|  |     61 | 	IMPORT_C CFeedEngine& FeedEngine();
 | 
|  |     62 | 	IMPORT_C CShowEngine& ShowEngine();
 | 
|  |     63 | 	IMPORT_C CSoundEngine& SoundEngine();
 | 
|  |     64 | 	IMPORT_C CSettingsEngine& SettingsEngine();
 | 
|  |     65 | 	IMPORT_C CConnectionEngine& ConnectionEngine();
 | 
|  |     66 | 	IMPORT_C CShowInfo* PlayingPodcast();
 | 
|  |     67 | 	IMPORT_C void SetPlayingPodcast(CShowInfo* aPodcast);
 | 
|  |     68 | 	IMPORT_C void PlayPausePodcastL(CShowInfo * aPodcast, TBool aPlayOnInit = EFalse);
 | 
|  |     69 | 	IMPORT_C CFeedInfo* ActiveFeedInfo();
 | 
|  |     70 | 	IMPORT_C void SetActiveFeedInfo(CFeedInfo* aFeedInfo);
 | 
|  |     71 | 	
 | 
|  |     72 | 	RFs& FsSession();
 | 
|  |     73 | 	
 | 
|  |     74 | 	IMPORT_C RShowInfoArray& ActiveShowList();
 | 
|  |     75 | 	
 | 
|  |     76 | 	void SetActiveShowList(RShowInfoArray& aShowArray);
 | 
|  |     77 | 	
 | 
|  |     78 | 	IMPORT_C void UpdateIAPListL();
 | 
|  |     79 | 	IMPORT_C void UpdateSNAPListL();
 | 
|  |     80 | 	IMPORT_C CDesCArrayFlat* IAPNames();
 | 
|  |     81 | 	IMPORT_C RArray<TPodcastIAPItem>& IAPIds();
 | 
|  |     82 | 	IMPORT_C CDesCArrayFlat* SNAPNames();
 | 
|  |     83 | 	IMPORT_C RArray<TPodcastIAPItem>& SNAPIds();
 | 
|  |     84 | 
 | 
|  |     85 | 	void SetProxyUsageIfNeededL(RHTTPSession& aSession);
 | 
|  |     86 | 	void GetProxyInformationForConnectionL(TBool& aIsUsed, HBufC*& aServerName, TUint32& aPort);
 | 
|  |     87 | 	TInt GetIapId();
 | 
|  |     88 | 	
 | 
|  |     89 | 	sqlite3* DB();
 | 
|  |     90 | 	
 | 
|  |     91 | 	IMPORT_C void GetAllShows();
 | 
|  |     92 | 	IMPORT_C void GetNewShows();
 | 
|  |     93 | 	IMPORT_C void GetShowsDownloaded();
 | 
|  |     94 | 	IMPORT_C void GetShowsDownloading();
 | 
|  |     95 | 	IMPORT_C void GetShowsByFeed(TUint aFeedUid);
 | 
|  |     96 | 	IMPORT_C void MarkSelectionPlayed();
 | 
|  |     97 | 	
 | 
|  |     98 | 	TInt FindActiveShowByUid(TUint aUid);
 | 
|  |     99 | 	IMPORT_C TBool IsFirstStartup();
 | 
|  |    100 | 	IMPORT_C CImageHandler& ImageHandler();
 | 
|  |    101 | protected:
 | 
|  |    102 | 	CPodcastModel();
 | 
|  |    103 | 	void ConstructL();
 | 
|  |    104 | 	// From ImageHandler
 | 
|  |    105 | 	void ImageOperationCompleteL(TInt aError);
 | 
|  |    106 | private:	
 | 
|  |    107 |    CShowInfo* iPlayingPodcast;
 | 
|  |    108 |    
 | 
|  |    109 |    CFeedEngine* iFeedEngine;
 | 
|  |    110 |    CShowEngine* iShowEngine;
 | 
|  |    111 |    CSoundEngine* iSoundEngine;
 | 
|  |    112 |    CSettingsEngine *iSettingsEngine;
 | 
|  |    113 |    CConnectionEngine* iConnectionEngine;
 | 
|  |    114 |    RShowInfoArray iActiveShowList;
 | 
|  |    115 |    CFeedInfo *iActiveFeed;   
 | 
|  |    116 |    
 | 
|  |    117 |    RFs iFsSession;
 | 
|  |    118 |    RArray<TPodcastIAPItem> iIapIdArray;
 | 
|  |    119 |    CDesCArrayFlat* iIapNameArray;
 | 
|  |    120 |    
 | 
|  |    121 |    RArray<TPodcastIAPItem> iSNAPIdArray;
 | 
|  |    122 |    CDesCArrayFlat* iSNAPNameArray;
 | 
|  |    123 |    CCommsDatabase* iCommDB;  
 | 
|  |    124 |    
 | 
|  |    125 |    sqlite3* iDB;
 | 
|  |    126 |    RCmManager iCmManager;
 | 
|  |    127 |    TBool iIsFirstStartup;
 | 
|  |    128 |    CImageHandler* iImageHandler;
 | 
|  |    129 | };
 | 
|  |    130 | 
 | 
|  |    131 | #endif // PODCASTMODEL_H
 |