qtinternetradio/irqisdsclient/src/irqisdsclient.cpp
changeset 0 09774dfdd46b
child 3 ee64f059b8e1
equal deleted inserted replaced
-1:000000000000 0:09774dfdd46b
       
     1 /*
       
     2 * Copyright (c) 2006-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 "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:  a new wrapper class in QT 
       
    15  *
       
    16 */
       
    17 
       
    18 #include "irqisdsclientimpl.h"   
       
    19  
       
    20 //Static function
       
    21 //to get an instance of the IRQIsdsClient
       
    22 //@return IRQIsdsClient *
       
    23 EXPORT_C IRQIsdsClient *IRQIsdsClient::openInstance(IRQFavoritesDB *aFavPresets)
       
    24 {
       
    25     if (NULL == aFavPresets)
       
    26         return NULL;
       
    27 
       
    28     IRQIsdsClient* irqisdsclient =
       
    29             reinterpret_cast<IRQIsdsClient*> (Dll::Tls());
       
    30 
       
    31     if (NULL == irqisdsclient)
       
    32     {
       
    33         irqisdsclient = new IRQIsdsClient(aFavPresets);
       
    34         int result = 0;
       
    35         result = Dll::SetTls(irqisdsclient); 
       
    36         
       
    37         if( KErrNone != result )
       
    38         {
       
    39             delete irqisdsclient;
       
    40             return NULL;
       
    41         }
       
    42         
       
    43         irqisdsclient->iSingletonInstances = 1;
       
    44     }
       
    45     else
       
    46         irqisdsclient->iSingletonInstances++;
       
    47 
       
    48     return irqisdsclient;
       
    49 }
       
    50 
       
    51 //
       
    52 //close the instance.
       
    53 //@return void
       
    54 EXPORT_C void IRQIsdsClient::closeInstance()
       
    55 {
       
    56     iSingletonInstances--;
       
    57 
       
    58     if (0 == iSingletonInstances)
       
    59     {
       
    60         Dll::SetTls(NULL);
       
    61         delete this;
       
    62     }
       
    63 
       
    64     return;
       
    65 }
       
    66 
       
    67 //Issue a search request to the isds server
       
    68 //@param QString, the requested search string
       
    69 //
       
    70 EXPORT_C void IRQIsdsClient::isdsSearchRequest(const QString& aIsdsSearchString)
       
    71 {
       
    72     iImpl->isdsSearchRequestImpl(aIsdsSearchString);     
       
    73 }
       
    74 
       
    75 //Send the category request by the category type
       
    76 // 
       
    77 EXPORT_C void IRQIsdsClient::isdsCategoryRequest(
       
    78         IRQIsdsClient::IRQIsdsClientInterfaceIDs aIDType, bool& aCache)
       
    79 { 
       
    80     iImpl->isdsCategoryRequestImpl(aIDType, aCache);
       
    81 }
       
    82 
       
    83 EXPORT_C bool IRQIsdsClient::isdsIsCategoryCached(IRQIsdsClient::IRQIsdsClientInterfaceIDs aIDType)
       
    84 {
       
    85     return iImpl->isdsIsCategoryCachedImpl(aIDType);
       
    86 }
       
    87 
       
    88 EXPORT_C bool IRQIsdsClient::isdsIsChannelCached(int aIndex)
       
    89 {
       
    90     return iImpl->isdsIsChannelCachedImpl(aIndex);
       
    91 }
       
    92 //Send the channels request by the channel index in the specify category
       
    93 //
       
    94 EXPORT_C void IRQIsdsClient::isdsChannelRequest(int aIndex, bool& aCache)
       
    95 {
       
    96     
       
    97     if( 0 > aIndex )
       
    98         return;
       
    99     
       
   100     /* if the isds has the banner, the index can't be 0 , or it will crash*/
       
   101     if( isdsIsCategoryBanner() && 0 == aIndex )
       
   102         return;
       
   103     
       
   104     iImpl->isdsChannelRequestImpl(aIndex, aCache);
       
   105 }
       
   106 
       
   107 //issue a listen request to the isds client
       
   108 //@param int,bool, the current index of channel, the history tag  
       
   109 //
       
   110 EXPORT_C void IRQIsdsClient::isdsListenRequest(int aCurrentIndex,
       
   111         bool aHistoryBool)
       
   112 { 
       
   113     if (0 > aCurrentIndex)
       
   114         return;
       
   115 
       
   116     /* if the isds has the banner, the index can't be 0 , or it will crash*/
       
   117     if (isdsIsChannelBanner() && 0 == aCurrentIndex)
       
   118         return;
       
   119     
       
   120     iImpl->isdsListenRequestImpl(aCurrentIndex,aHistoryBool); 
       
   121 }
       
   122 
       
   123 //to syncronize presets
       
   124 //@param int,QString, the preset id and the last modified tag for the preset   
       
   125 //
       
   126 EXPORT_C int IRQIsdsClient::isdsSyncPreset(int aPresetId,
       
   127         const QString& aIfModifySince)
       
   128 {     
       
   129     TInt result = 0;
       
   130     result = iImpl->isdsSyncPresetImpl(aPresetId, aIfModifySince);
       
   131     return result;
       
   132 } 
       
   133 
       
   134 //Cacel the request sent by the UI.
       
   135 //@param None
       
   136 //
       
   137 EXPORT_C void IRQIsdsClient::isdsCancelRequest()
       
   138 {
       
   139     iImpl->isdsCancelRequestImpl();  
       
   140 }
       
   141 
       
   142  
       
   143 
       
   144 //to see wether category view has a banner.
       
   145 //@param None
       
   146 //
       
   147 EXPORT_C bool IRQIsdsClient::isdsIsCategoryBanner()
       
   148 {
       
   149     return iImpl->isdsIsCategoryBannerImpl();
       
   150 }
       
   151 
       
   152 //
       
   153 //to see wether channel view has a banner.
       
   154 //@param None
       
   155 EXPORT_C bool IRQIsdsClient::isdsIsChannelBanner()
       
   156 {
       
   157     return iImpl->isdsIsChannelBannerImpl();
       
   158 }
       
   159 
       
   160 //the api is called from the UI(nowplaying view) to download logo.
       
   161 //@param None
       
   162 //
       
   163 EXPORT_C void IRQIsdsClient::isdsLogoDownSendRequest(IRQPreset* aPreset,
       
   164         int aNPVReq, int aXValue, int aYValue)
       
   165 { 
       
   166     iImpl->isdsLogoDownSendRequestImpl(aPreset, aNPVReq, aXValue, aYValue);
       
   167 }
       
   168 
       
   169 EXPORT_C bool IRQIsdsClient::isdsIsLogoCached(IRQPreset* aPreset, int aXValue, int aYValue)
       
   170 {
       
   171     return iImpl->isdsIsLogoCachedImpl(aPreset, aXValue, aYValue);
       
   172 }
       
   173 //
       
   174 //the api is called to cancel the current transaction
       
   175 //@param None
       
   176 //
       
   177 EXPORT_C void IRQIsdsClient::isdsLogoDownCancelTransaction()
       
   178 {
       
   179     iImpl->isdsLogoDownCancelTransactionImpl();
       
   180 }
       
   181 
       
   182 //
       
   183 //To know the status of downloading logo
       
   184 EXPORT_C bool IRQIsdsClient::isdsLogoDownIsRunning() const
       
   185 {
       
   186     return iImpl->isdsLogoDownIsRunningImpl();
       
   187 }
       
   188 
       
   189 //takes the url as a parameter and returns the logo data which is in cache
       
   190 //this API is called form the search results for to display logo on the view
       
   191 //@param QString: the url of the img, int: the status for getting
       
   192 //
       
   193 EXPORT_C void IRQIsdsClient::isdsLogoDownCheckCacheLogo(const QString& aURL,
       
   194         int& aStatus)
       
   195 { 
       
   196     iImpl->isdsLogoDownCheckCacheLogoImpl(aURL, aStatus);
       
   197 }
       
   198 
       
   199 //get the cache logo from the logodown engine. The "send" is the point from a logodown engine
       
   200 //@param None
       
   201 //
       
   202 EXPORT_C TDesC8& IRQIsdsClient::isdsLogoDownSendCacheLogo()
       
   203 {
       
   204     return iImpl->isdsLogoDownSendCacheLogoImpl();
       
   205 }
       
   206 
       
   207 EXPORT_C void IRQIsdsClient::isdsPostLog(const QString& aFileName)
       
   208 {
       
   209     iImpl->isdsPostLogImpl(aFileName);
       
   210 }
       
   211 
       
   212 EXPORT_C void IRQIsdsClient::isdsGetIRID()
       
   213 {
       
   214     iImpl->isdsGetIRIDImpl();
       
   215 }
       
   216 
       
   217 EXPORT_C void IRQIsdsClient::isdsGetBrowseBanner(QString& aBannerUrl, QString& aClickThroughUrl)
       
   218 {
       
   219     iImpl->isdsGetBrowseBannerImpl(aBannerUrl, aClickThroughUrl);
       
   220 }
       
   221 
       
   222 EXPORT_C void IRQIsdsClient::isdsMultSearch(QString aGenreID, QString aCountryID, QString aLanguageID, QString aSearchText)
       
   223 {
       
   224     iImpl->isdsMultSearchImpl(aGenreID, aCountryID, aLanguageID, aSearchText);
       
   225 }
       
   226 
       
   227 EXPORT_C bool IRQIsdsClient::isdsIsConstructSucceed() const
       
   228 {
       
   229     return iImpl->isdsIsConstructSucceed();
       
   230 }
       
   231 
       
   232 /************************ private functions **************************/
       
   233 //the c++ default destruction function
       
   234 // private
       
   235 IRQIsdsClient::~IRQIsdsClient()
       
   236 {    
       
   237     delete iImpl;
       
   238 }
       
   239 
       
   240 
       
   241 IRQIsdsClient::IRQIsdsClient(IRQFavoritesDB *aFavPresets)
       
   242 {    
       
   243     iImpl = new IRQIsdsClientImpl(aFavPresets); 
       
   244     Q_ASSERT(iImpl);
       
   245     
       
   246     connect(iImpl, SIGNAL(categoryItemsChangedImpl(QList<IRQBrowseCategoryItem *> *)),
       
   247                 this, SIGNAL(categoryItemsChanged(QList<IRQBrowseCategoryItem *> *)));
       
   248     
       
   249     connect(iImpl, SIGNAL(channelItemsChangedImpl(QList<IRQChannelItem *> *)),
       
   250                     this, SIGNAL(channelItemsChanged(QList<IRQChannelItem *> *)));
       
   251     
       
   252     connect(iImpl, SIGNAL(operationExceptionImpl(IRQError)),
       
   253             this, SIGNAL(operationException(IRQError)));
       
   254     
       
   255     
       
   256     connect(iImpl, SIGNAL(presetResponseImpl(IRQPreset *)),
       
   257             this, SIGNAL(presetResponse(IRQPreset *)));
       
   258    
       
   259     
       
   260     connect(iImpl, SIGNAL(syncPresetResultImpl(IRQSycPresetStatus, IRQPreset*)),
       
   261                 this, SIGNAL(syncPresetResult(IRQSycPresetStatus,  IRQPreset*)));
       
   262     
       
   263     
       
   264     connect(iImpl, SIGNAL(presetLogoDownloadedImpl(IRQPreset*)),
       
   265                     this, SIGNAL(presetLogoDownloaded(IRQPreset*)));
       
   266    
       
   267     
       
   268     connect(iImpl, SIGNAL(presetLogoDownloadErrorImpl()),
       
   269                         this, SIGNAL(presetLogoDownloadError()));     
       
   270    
       
   271     
       
   272     connect(iImpl, SIGNAL(iridReceivedImpl(QString)), 
       
   273                         this, SIGNAL(iridReceived(QString)));
       
   274     
       
   275 }
       
   276 
       
   277  
       
   278