internetradio2.0/irisdsclient/inc/isdsclientdll.h
changeset 14 896e9dbc5f19
equal deleted inserted replaced
12:608f67c22514 14:896e9dbc5f19
       
     1 /*
       
     2 * Copyright (c) 2009 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 "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:  The implementation for presentation elements.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef ISDSCLIENTDLL_H
       
    20 #define ISDSCLIENTDLL_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 #include "ircacheobserver.h"
       
    25 #include "irdataproviderobserver.h"
       
    26 #include "irlanguagemapper.h"
       
    27 #include "irparserobserver.h"
       
    28 
       
    29 class CIRCacheMgmt;
       
    30 class CIRDataProvider;
       
    31 class CIRHttpRequestData;
       
    32 class CIRIsdsPreset;
       
    33 class CIRReportGenerator;
       
    34 class CIRSettings;
       
    35 class CIRXMLContentHandler;
       
    36 class MIsdsResponseObserver;
       
    37 
       
    38 /** 
       
    39  * This class is the one which acts as a interface between UI and network
       
    40  * component which interacts with the isds server.It provides the data to 
       
    41  * be diplayed to the UI either from cache or fetches it from the ISDS 
       
    42  * server.
       
    43  * 
       
    44  *
       
    45  * @code
       
    46  * creates the instance of isdsclient 
       
    47  * iISDSClient = CIRIsdsClient::NewL(*this , iIRSettings->GetISDSBaseUrlL());
       
    48  * iISDSClient->IRIsdsClientIntefaceL(EGenre); //requests for genre data
       
    49  * //requests for selected channel
       
    50  * iISDSClient->IRIsdsClientIntefaceL(iIndex, CIRIsdsClient::EChannels);
       
    51  * //cancels any previous requests
       
    52  * iISDSClient->IRISDSCancelRequest();
       
    53  * //gets irid
       
    54  * iISDSClient->IRGetIRIDL();
       
    55  * iISDSClient->GetOtaStatusL(forceUpdate);//gets ota update status
       
    56  * iISDSClient->IRISDSSearchL(aIsdsSearchString);
       
    57  * iISDSClient->IRISDSPostL(pathtopost);
       
    58  * SyncPresetL(iUi->iFavPresets->iFavPresetList->At(aUrlIndex)->GetId(),
       
    59  * iUi->iFavPresets->iFavPresetList->At(aUrlIndex)->GetLastModifiedTime());
       
    60  * iISDSClient->ReleaseResources();
       
    61  * @endcode
       
    62  *
       
    63  */
       
    64 
       
    65 NONSHARABLE_CLASS( CIRIsdsClient ) : public CBase ,
       
    66                                      public MIRDataProviderObserver,
       
    67                                      public MIRParserObserver,
       
    68                                      public MIRCacheObserver
       
    69     {
       
    70 
       
    71 public: //public data
       
    72 
       
    73     /**
       
    74      * These Enums correspond to a particular UI event which 
       
    75      * requires request to be made to isds.
       
    76     */
       
    77     enum TIRIsdsclientInterfaceIDs
       
    78         {
       
    79         EGenre,
       
    80         ELanguages,
       
    81         ECountries,
       
    82         Ehotpicks
       
    83         };
       
    84     
       
    85     enum TIRIsdsClientInterfaces
       
    86         {
       
    87         ECatagory,
       
    88         EChannels,
       
    89         EPresets,
       
    90         EOtaInfo
       
    91         }; 
       
    92     
       
    93     /**
       
    94     *type of data recieved from ISDS   
       
    95     */
       
    96      enum TDataRecieved
       
    97         {
       
    98         ECategoryInfoRecieved,
       
    99         EChannelListRecieved,
       
   100         EPresetDataRecieved,
       
   101         EOtaInfoRecieved,
       
   102         EIridRecieved,
       
   103         ESessionLogRecieved
       
   104         };
       
   105 
       
   106 public:
       
   107 
       
   108     /**
       
   109      * CIRIsdsClient::NewL(MIsdsResponseObserver& aobserver)
       
   110      * Used by UI to create instance of CIRIsdsClient.
       
   111      */
       
   112     IMPORT_C static CIRIsdsClient* NewL(MIsdsResponseObserver& aobserver,
       
   113             const TDesC& aISDSBaseUrl);
       
   114 
       
   115     /**
       
   116      * CIRIsdsClient::NewLC(MIsdsResponseObserver& aobserver)
       
   117      * Creates instance of CIRIsdsClient.
       
   118      */
       
   119     
       
   120     static CIRIsdsClient* NewLC(MIsdsResponseObserver& aobserver,
       
   121             const TDesC& aISDSBaseUrl);
       
   122 
       
   123     /**
       
   124      * CIRIsdsClient::~CIRIsdsClient()
       
   125      * Destructor
       
   126      */
       
   127     
       
   128     ~CIRIsdsClient();
       
   129 
       
   130     /**
       
   131      * CIRIsdsClient::ConstructL()
       
   132      * Symbian two phased constructor
       
   133      */
       
   134     void ConstructL(const TDesC& aISDSBaseUrl);
       
   135 
       
   136     /**
       
   137      * CIRIsdsClient::CIRIsdsClient(MIsdsResponseObserver& aobserver)
       
   138      * Default constructor
       
   139      */
       
   140     CIRIsdsClient(MIsdsResponseObserver& aobserver); 
       
   141 
       
   142     /**
       
   143      * void CIRIsdsClientInteface(TIRIsdsclientInterfaceIDs aISDSClientRequest)
       
   144      * Called by UI to make request to ISDS for catogories
       
   145      * @param :ENUM value depending on catogory which user wants to explore
       
   146      */
       
   147     IMPORT_C TBool IRIsdsClientIntefaceL(
       
   148             TIRIsdsclientInterfaceIDs aISDSClientRequest);
       
   149 
       
   150     /**
       
   151      * TBool IRIsdsIsCategoryCachedL(
       
   152      *       TIRIsdsclientInterfaceIDs aISDSClientRequest);
       
   153      * 
       
   154      */
       
   155     IMPORT_C TBool IRIsdsIsCategoryCachedL(
       
   156             TIRIsdsclientInterfaceIDs aISDSClientRequest);
       
   157     
       
   158     /**
       
   159      * void CIRIsdsClientInteface(TUint aSelectedOption,TIRIsdsClientInterfaces aChoice)
       
   160      * This API is used by the UI to make request for isds listed channels
       
   161      * @param : aSelectedOption-returns the index of the option selected by the user
       
   162      * @param : aChoice-ENUM value specifies what data is expected preset or channel data
       
   163      */
       
   164     IMPORT_C TBool IRIsdsClientIntefaceL(TUint aSelectedOption,
       
   165             TIRIsdsClientInterfaces aChoice, TInt aHistoryBool = EFalse);
       
   166     
       
   167     /**
       
   168      * TBool IRIsdsIsChannelCachedL(TUint aSelectedOption);
       
   169      * 
       
   170      */
       
   171     IMPORT_C TBool IRIsdsIsChannelCachedL(TUint aSelectedOption);
       
   172 
       
   173     /**
       
   174      * void CIRISDSCancelRequest()
       
   175      * This API is used by the UI to cancel a request made.
       
   176      */
       
   177     IMPORT_C void IRISDSCancelRequest();
       
   178 
       
   179     /**
       
   180      * void CIRGetIRID()
       
   181      * This API is used to get IR ID from isds server 
       
   182      * isds if it doesnt have one
       
   183      */
       
   184     IMPORT_C void IRGetIRIDL();
       
   185 
       
   186     /**
       
   187      * void GetOtaStatusL()
       
   188      * This API is used to get the OTA status from the server
       
   189      * @param TBool,if ETrue the call is from UI and a call back has to be made to ui
       
   190      * TBool contains the source of update (cache/isds)upon return.Used by Ui to load the
       
   191      * loading screen based on this value.
       
   192      */
       
   193     IMPORT_C void GetOtaStatusL(TBool& aDataFrom);
       
   194 
       
   195     /**
       
   196      * void CIRISDSSearch(TDesC& aSearchString)
       
   197      * This API is used by the UI to search channels from isds
       
   198      * @param : aSearchString-search string entered by user
       
   199      */
       
   200     IMPORT_C void IRISDSSearchL(const TDesC& aSearchString);
       
   201 
       
   202     /**
       
   203      * void IRISDSPostL(TFileName &aFileName)
       
   204      *function used to post the sesson logs
       
   205      *@param sesson log file name
       
   206      */
       
   207     IMPORT_C void IRISDSPostL(TFileName &aFileName);
       
   208     
       
   209     /**
       
   210      * CIRDataProvider* GetDataProvider();
       
   211      *function pointer to CIRDataProvider
       
   212      *@param None
       
   213      */
       
   214     IMPORT_C CIRDataProvider* GetDataProvider();
       
   215 
       
   216     /*
       
   217      * void IRISDSMultiSearch()
       
   218      * function used to search the stations by multi conditions
       
   219      * @param 
       
   220      */
       
   221     IMPORT_C void IRISDSMultiSearchL(const TDesC& aGenreID,
       
   222             const TDesC& aCountryID, const TDesC& aLanguageID,
       
   223             const TDesC& aSearchText);
       
   224 
       
   225     /**
       
   226      * void RHttpGeneralError(TInt aErrorCode)
       
   227      * It is a call back function called by the data provider 
       
   228      * to return error code in case of some error.
       
   229      *@param error code
       
   230      */
       
   231     void IRHttpGeneralError(TInt aErrCode);
       
   232 
       
   233     /**
       
   234      * void IRHttpDataReceived(TDesC& aXmlPath)
       
   235      * It is a call back function called by the data provider 
       
   236      * once it recieves the XML data
       
   237      */
       
   238     void IRHttpDataReceived(const TDesC& aXmlPath,
       
   239             const CIRHttpResponseData& aResponseHeaders);
       
   240 
       
   241     /**
       
   242      * void IRHttpContentNotChanged()
       
   243      * this is call back funtion called by Dataprovider in case 
       
   244      * HTTP content isnt changed by ISDS 
       
   245      */
       
   246     void IRHttpResponseCodeReceived(TInt aResponseCode,
       
   247             CIRHttpResponseData& aResponseHeaders);
       
   248 
       
   249     /**
       
   250      * void ParseError()
       
   251      * Call back funtion called by XML parser in case of parsing error
       
   252      */
       
   253     void ParseError(TInt aErrorCode);
       
   254 
       
   255     /**
       
   256      * void ParsedStructureL(TInt aChoice)
       
   257      * Call back funtion called by XML parser after parsing is over
       
   258      * @param : aChoice -specifies the type of data recieved from ISDS
       
   259      */
       
   260     void ParsedStructureL(TInt aChoice);
       
   261 
       
   262     /**
       
   263      * void CacheError()
       
   264      * Called from cachemgmt in case of an error
       
   265      */
       
   266     void CacheError();
       
   267 
       
   268     /**
       
   269      * void CacheError()
       
   270      * Called from cachemgmt in case of cache failure
       
   271      */
       
   272     void CacheFailed();
       
   273 
       
   274     /**
       
   275      * void CacheError()
       
   276      * Called from cachemgmt in case cache is invalid
       
   277      */
       
   278     void CacheInvalid();
       
   279     
       
   280     /**
       
   281      * void CacheError()
       
   282      * Called from cachemgmt data retrival is successful
       
   283      *@param aChoice,it gives the data type of the cache
       
   284      */
       
   285     void CachedStructureL(TInt aChoice);
       
   286 
       
   287     /**
       
   288      *void CIRIsdsClient::SyncPresetL()
       
   289      *Used to syncronize presets
       
   290      *@param TInt,TDesC, the preset id and the last modified tag for the preset          
       
   291      */
       
   292     IMPORT_C TInt SyncPresetL(TInt aPresetId, const TDesC&aIfModifiedSince);
       
   293 
       
   294     /**
       
   295      *void CIRIsdsClient::ConvertToTimeDate()
       
   296      *Used to convert the date-time stamp to Symbian DateTime format
       
   297      *@param TDesC&,TDateTime& the time stamp and the DateTime ref to 
       
   298      *hold the new data
       
   299      */
       
   300     void ConvertToTimeDate(const TDesC& aTime, TDateTime& aDateTime) const;
       
   301 
       
   302     /**
       
   303      *ReleaseResources()
       
   304      *relese the resources held by isds client
       
   305      */
       
   306     IMPORT_C void ReleaseResources();
       
   307 
       
   308     /**
       
   309      *CIRIsdsClient::GetMultiplePresetsL()
       
   310      *for multiple selected presets to be saved 
       
   311      *@param RArray&,TBool,the array of preset ids to be saved,return value
       
   312      */
       
   313     IMPORT_C void GetMultiplePresetsL(const RArray<TInt>& aIndexArray,
       
   314             TBool& aDataFrom);
       
   315 
       
   316     /**
       
   317      *CIRIsdsClient::PurgeOtaInfoL
       
   318      *delete all the data cached wrt OTA
       
   319      *reset the flags
       
   320      *function called when the ota info available earlier is no longer valid
       
   321      */
       
   322     IMPORT_C void PurgeOtaInfoL();
       
   323 
       
   324 private:
       
   325     /**
       
   326      *void IRHttpIssueRequestL(CIRHttpRequestData &);
       
   327      *for making http request to Data Provider with Request object
       
   328      *@param aRequestObject :The request object which has URL and other details
       
   329      */
       
   330     void IRHttpIssueRequestL(CIRHttpRequestData &aRequestObject);
       
   331 
       
   332     /**
       
   333      * void EncodeUrlL( TDes &aQuery )
       
   334      * Encode the url using EEscapeUrlEncoded mode, This is used in session log
       
   335      * @param url to be encoded
       
   336      */
       
   337     void EncodeUrlL(TDes& aQuery);
       
   338 
       
   339 private:
       
   340     //Session log
       
   341     TBuf<256> iBrowseUrl;
       
   342     TInt iChannId;
       
   343 
       
   344     //XML parser instance
       
   345     CIRXMLContentHandler* iXmlReader;
       
   346 
       
   347     //ISDS observer reference
       
   348     MIsdsResponseObserver& iIsdsResponseObserver;
       
   349 
       
   350     //DataProvider instance
       
   351     CIRDataProvider *iDataProvider;
       
   352 
       
   353     //cache mgmt
       
   354     CIRCacheMgmt *iCache;
       
   355     CIRSettings *iSettings;
       
   356     CArrayPtrFlat<CIRIsdsPreset>* iSendPreset;
       
   357     // used to store the isds base URL
       
   358     HBufC* iISDSBaseUrl;
       
   359     //contains catogory base URL
       
   360     TBuf<256> iCatgoryURL;
       
   361     //contains search base URL
       
   362     TBuf<256> iSearchURL;
       
   363     //contains irid base URL
       
   364     TBuf<256> iGetIridUrl;
       
   365     TBuf<128> iGetOtaStatus;
       
   366     TBool iSyncRequest;//1 if the preset data request is a sync request,0 if general request
       
   367     TInt iPresetToBeSynced;//keeps the presetid for which the sync request has been sent
       
   368     TBool iDataFrom;//data from isds =1,isds =0
       
   369     TBool iCatDataFrom;//0 if isds,1 for cache
       
   370     TBool iChannelDataFrom;//0 if isds,1 for cache
       
   371     TBuf<256> iCachePath;
       
   372     TBool iOtaReqFrom;//0 internal 1from UI
       
   373     //session log
       
   374     CIRReportGenerator* iBrowseReport;
       
   375     //conditionalGet
       
   376     TBool iConditonalGet;
       
   377     TTime iLastModifiedTime;
       
   378     TInt iRequestType;
       
   379     TBool iForceGet;
       
   380     TBool iOnceForTheUsageSession;
       
   381     TBool iPostResponsePending;
       
   382     TBufC8<KIRLanguageCodeLength> iShortLanguageCode;
       
   383 
       
   384     /**
       
   385      * boolean for to track whether the cache request has made or not
       
   386      */
       
   387     TBool iCacheReqMade;
       
   388     TBool iIRIDPending;
       
   389     TBool iReqPending;
       
   390     TBool iReqFromGetIRIDFunc;
       
   391     TBool iReqFromSync;
       
   392 
       
   393     /**
       
   394      * to store further pending request objects 
       
   395      */
       
   396     CIRHttpRequestData* iTempRequestObject;
       
   397     };
       
   398 
       
   399 #endif //ISDSCLIENTDLL_H
       
   400 
       
   401