qtinternetradio/irqcommon/src/irqutility.cpp
branchGCC_SURGE
changeset 13 c9471d26c7f2
parent 11 f683e24efca3
child 14 896e9dbc5f19
equal deleted inserted replaced
9:bfc95e24a059 13:c9471d26c7f2
    49 //
    49 //
    50 //convert the CIRIsdsPreset to the IRQPreset. 
    50 //convert the CIRIsdsPreset to the IRQPreset. 
    51 //
    51 //
    52 EXPORT_C void IRQUtility::convertCIRIsdsPreset2IRQPrest(const CIRIsdsPreset& aCIRIsdsPreset, IRQPreset& aQIRPreset)
    52 EXPORT_C void IRQUtility::convertCIRIsdsPreset2IRQPrest(const CIRIsdsPreset& aCIRIsdsPreset, IRQPreset& aQIRPreset)
    53 {
    53 {
    54   aQIRPreset.uniqID = aCIRIsdsPreset.UniqId(); 
       
    55   aQIRPreset.type = aCIRIsdsPreset.GetChannelType();
    54   aQIRPreset.type = aCIRIsdsPreset.GetChannelType();
    56   aQIRPreset.index  = aCIRIsdsPreset.GetIndex();
       
    57   
    55   
    58   aQIRPreset.presetId = aCIRIsdsPreset.GetId();
    56   aQIRPreset.presetId = aCIRIsdsPreset.GetId();
    59   aQIRPreset.iChannelUrlCount  = aCIRIsdsPreset.GetUrlCount();
    57   aQIRPreset.iChannelUrlCount  = aCIRIsdsPreset.GetUrlCount();
    60   aQIRPreset.name = QString::fromUtf16((aCIRIsdsPreset.GetName()).Ptr(), (aCIRIsdsPreset.GetName()).Length());
    58   aQIRPreset.name = QString::fromUtf16((aCIRIsdsPreset.GetName()).Ptr(), (aCIRIsdsPreset.GetName()).Length());
    61   
    59   
    99 
    97 
   100 //convert the IRQPreset to the CIRIsdsPreset 
    98 //convert the IRQPreset to the CIRIsdsPreset 
   101 //
    99 //
   102 EXPORT_C void IRQUtility::convertIRQPreset2CIRIsdsPreset(const IRQPreset& aQIRPreset, CIRIsdsPreset& aCIRIsdsPreset)
   100 EXPORT_C void IRQUtility::convertIRQPreset2CIRIsdsPreset(const IRQPreset& aQIRPreset, CIRIsdsPreset& aCIRIsdsPreset)
   103 {
   101 {
   104   aCIRIsdsPreset.SetId(aQIRPreset.uniqID);
       
   105   aCIRIsdsPreset.SetIndex(aQIRPreset.index);
       
   106   aCIRIsdsPreset.SetId(aQIRPreset.presetId);
   102   aCIRIsdsPreset.SetId(aQIRPreset.presetId);
   107   aCIRIsdsPreset.SetUrlCount(aQIRPreset.iChannelUrlCount);
   103   aCIRIsdsPreset.SetUrlCount(aQIRPreset.iChannelUrlCount);
   108   aCIRIsdsPreset.SetChannelType(aQIRPreset.type);  
   104   aCIRIsdsPreset.SetChannelType(aQIRPreset.type);  
   109   
   105   
   110   TPtrC16 namePtr(reinterpret_cast<const TUint16*>(aQIRPreset.name.utf16()));
   106   TPtrC16 namePtr(reinterpret_cast<const TUint16*>(aQIRPreset.name.utf16()));
   155 
   151 
   156 //convert CIRPreset to the IRQPreset 
   152 //convert CIRPreset to the IRQPreset 
   157 //
   153 //
   158 EXPORT_C void IRQUtility::convertCIRPreset2IRQPreset(const CIRPreset& aCIRPreset, IRQPreset& aIRQPreset)
   154 EXPORT_C void IRQUtility::convertCIRPreset2IRQPreset(const CIRPreset& aCIRPreset, IRQPreset& aIRQPreset)
   159 {
   155 {
   160   CIRIsdsPreset * cirIsdsPreset = NULL;  
   156     aIRQPreset.uniqID = aCIRPreset.Id(); 
   161   TRAPD(err, cirIsdsPreset = CIRIsdsPreset::NewL());
   157     aIRQPreset.type = aCIRPreset.GetChannelType();
   162   if( KErrNone != err)
   158     
   163     return;
   159     aIRQPreset.presetId = aCIRPreset.GetId();
   164    
   160     aIRQPreset.iChannelUrlCount  = aCIRPreset.GetUrlCount();
   165   aCIRPreset.CopyPresetData(*cirIsdsPreset);  
   161     aIRQPreset.name = QString::fromUtf16((aCIRPreset.Name()).Ptr(), (aCIRPreset.Name()).Length());
   166   convertCIRIsdsPreset2IRQPrest(*cirIsdsPreset, aIRQPreset);
   162     
   167   delete cirIsdsPreset;  
   163     aIRQPreset.languageCode  = QString::fromUtf16(aCIRPreset.GetLangId().Ptr(), aCIRPreset.GetLangId().Length());
       
   164     aIRQPreset.languageName  = QString::fromUtf16(aCIRPreset.GetLangName().Ptr(), aCIRPreset.GetLangName().Length());
       
   165     
       
   166     aIRQPreset.countryCode  = QString::fromUtf16(aCIRPreset.GetCountryId().Ptr(),aCIRPreset.GetCountryId().Length());
       
   167     aIRQPreset.countryName  = QString::fromUtf16(aCIRPreset.GetCountryName().Ptr(),aCIRPreset.GetCountryName().Length());
       
   168     
       
   169     aIRQPreset.lastModified  = QString::fromUtf16(aCIRPreset.GetLastModifiedTime().Ptr(), aCIRPreset.GetLastModifiedTime().Length());
       
   170     aIRQPreset.description  = QString::fromUtf16(aCIRPreset.GetDescription().Ptr(), aCIRPreset.GetDescription().Length());
       
   171     aIRQPreset.shortDesc  = QString::fromUtf16(aCIRPreset.GetShortDescription().Ptr(), aCIRPreset.GetShortDescription().Length());
       
   172     
       
   173     aIRQPreset.genreId  = QString::fromUtf16(aCIRPreset.GetGenreId().Ptr(), aCIRPreset.GetGenreId().Length());
       
   174     aIRQPreset.genreName  = QString::fromUtf16(aCIRPreset.GetGenreName().Ptr(), aCIRPreset.GetGenreName().Length());
       
   175     
       
   176     aIRQPreset.advertisementUrl  = QString::fromUtf16(aCIRPreset.GetAdvertisementUrl().Ptr(), aCIRPreset.GetAdvertisementUrl().Length());
       
   177     aIRQPreset.advertisementInUse  = QString::fromUtf16(aCIRPreset.GetAdvertisementInUse().Ptr(),aCIRPreset.GetAdvertisementInUse().Length());
       
   178     
       
   179     aIRQPreset.imgUrl  = QString::fromUtf16(aCIRPreset.GetImgUrl().Ptr(), aCIRPreset.GetImgUrl().Length());   
       
   180     
       
   181     aIRQPreset.musicStoreStatus  = QString::fromUtf16(aCIRPreset.GetMusicStoreStatus().Ptr(), aCIRPreset.GetMusicStoreStatus().Length());
       
   182     aIRQPreset.clearChannelServerList();
       
   183     
       
   184     IRQChannelServerURL url;
       
   185     
       
   186     for(int i=0; i<aCIRPreset.GetUrlCount(); i++)
       
   187     {
       
   188         CIRChannelServerUrl& tempServerUrl = aCIRPreset.GetUrl(i);
       
   189         url.bitrate = tempServerUrl.GetBitRate();
       
   190         url.serverName = QString::fromUtf16(tempServerUrl.GetServerName().Ptr(), tempServerUrl.GetServerName().Length());
       
   191         url.url = QString::fromUtf16(tempServerUrl.GetServerUrl().Ptr(), tempServerUrl.GetServerUrl().Length());
       
   192         aIRQPreset.insertChannelServer(url);
       
   193     }
       
   194     
       
   195     aIRQPreset.sortURLArray();   
   168 }
   196 }
   169 
   197 
   170 //switch from the symbian error code to the IRQ error code 
   198 //switch from the symbian error code to the IRQ error code 
   171 //
   199 //
   172 EXPORT_C void IRQUtility::convertSError2QError(const int aSError, int& aQError)
   200 EXPORT_C void IRQUtility::convertSError2QError(const int aSError, int& aQError)
   243         return false;
   271         return false;
   244     }
   272     }
   245     
   273     
   246     bool ret = false;
   274     bool ret = false;
   247     TUid songRecognitionAppUid = getSongRecognitionAppUid();
   275     TUid songRecognitionAppUid = getSongRecognitionAppUid();
   248     TApaAppInfo appInfo;
   276     TApaAppInfo *appInfo = new TApaAppInfo;
   249     lsSession.GetAllApps();  
   277     lsSession.GetAllApps();  
   250 
   278 
   251     while( KErrNone == lsSession.GetNextApp(appInfo) )
   279     while( KErrNone == lsSession.GetNextApp(*appInfo) )
   252     {
   280     {
   253         TBool appIsHidden = EFalse;
   281         TBool appIsHidden = EFalse;
   254         TApaAppCapabilityBuf capability;
   282         TApaAppCapabilityBuf capability;
   255         if( KErrNone == lsSession.GetAppCapability(capability,appInfo.iUid) )
   283         if( KErrNone == lsSession.GetAppCapability(capability,appInfo->iUid) )
   256         {
   284         {
   257             appIsHidden = capability().iAppIsHidden;
   285             appIsHidden = capability().iAppIsHidden;
   258         }
   286         }
   259         
   287         
   260         if(!appIsHidden)
   288         if(!appIsHidden)
   261         {
   289         {
   262             if(songRecognitionAppUid == appInfo.iUid)
   290             if(songRecognitionAppUid == appInfo->iUid)
   263             {
   291             {
   264                 ret = true;
   292                 ret = true;
   265                 break;
   293                 break;
   266             }
   294             }
   267         }
   295         }
   268     }
   296     }
   269     
   297     delete appInfo;
   270     lsSession.Close();
   298     lsSession.Close();
   271     return ret;         
   299     return ret;         
   272 }   
   300 }   
   273     
   301     
   274     
   302