qtinternetradio/irqsonghistory/src/irqsonghistoryengine.cpp
changeset 5 0930554dc389
parent 0 09774dfdd46b
child 8 3b03c28289e6
equal deleted inserted replaced
3:ee64f059b8e1 5:0930554dc389
   160     TPtrC artistName(reinterpret_cast<const TUint16*>(aMetaData.getArtistName().utf16()), aMetaData.getArtistName().length());
   160     TPtrC artistName(reinterpret_cast<const TUint16*>(aMetaData.getArtistName().utf16()), aMetaData.getArtistName().length());
   161     TPtrC channelUrl(reinterpret_cast<const TUint16*>(aMetaData.getStreamUrl().utf16()), aMetaData.getStreamUrl().length());
   161     TPtrC channelUrl(reinterpret_cast<const TUint16*>(aMetaData.getStreamUrl().utf16()), aMetaData.getStreamUrl().length());
   162     TPtrC channelName(reinterpret_cast<const TUint16*>(aPreset.name.utf16()), aPreset.name.length());
   162     TPtrC channelName(reinterpret_cast<const TUint16*>(aPreset.name.utf16()), aPreset.name.length());
   163     TPtrC channelDesc(reinterpret_cast<const TUint16*>(aPreset.description.utf16()), aPreset.description.length());
   163     TPtrC channelDesc(reinterpret_cast<const TUint16*>(aPreset.description.utf16()), aPreset.description.length());
   164     TPtrC imageUrl(reinterpret_cast<const TUint16*>(aPreset.imgUrl.utf16()), aPreset.imgUrl.length());
   164     TPtrC imageUrl(reinterpret_cast<const TUint16*>(aPreset.imgUrl.utf16()), aPreset.imgUrl.length());
       
   165     TPtrC genreName(reinterpret_cast<const TUint16*>(aPreset.genreName.utf16()), aPreset.genreName.length());
       
   166     TPtrC countryName(reinterpret_cast<const TUint16*>(aPreset.countryName.utf16()), aPreset.countryName.length());
       
   167     TPtrC languageName(reinterpret_cast<const TUint16*>(aPreset.languageName.utf16()), aPreset.languageName.length());
   165     TPtrC musicFlag(reinterpret_cast<const TUint16*>(aPreset.musicStoreStatus.utf16()), aPreset.musicStoreStatus.length());
   168     TPtrC musicFlag(reinterpret_cast<const TUint16*>(aPreset.musicStoreStatus.utf16()), aPreset.musicStoreStatus.length());
   166     TUint8 channelType = aPreset.type;
   169     TUint8 channelType = aPreset.type;
   167     TUint16 channelId = aPreset.presetId;
   170     TUint16 channelId = aPreset.presetId;
   168     TUint16 bitrate = aMetaData.getBitrate();
   171     TUint16 bitrate = aMetaData.getBitrate();
   169 
   172 
   171     {
   174     {
   172         TInt ret = iSongHistoryDb->GetIdPresentInDbL( channelId );
   175         TInt ret = iSongHistoryDb->GetIdPresentInDbL( channelId );
   173         if(ret)
   176         if(ret)
   174         {
   177         {
   175             TInt modified = iSongHistoryDb->UpdateSongHistoryDbL( channelId ,
   178             TInt modified = iSongHistoryDb->UpdateSongHistoryDbL( channelId ,
   176                        channelName ,channelUrl ,imageUrl ,musicFlag);   
   179                        channelName ,channelUrl ,imageUrl ,genreName, countryName, languageName, musicFlag);   
   177             // TODO notify uplayer to change layout?
   180             // TODO notify uplayer to change layout?
   178         }
   181         }
   179     }
   182     }
   180     else if (channelType != 0)
   183     else if (channelType != 0)
   181     {
   184     {
   204                          channelType,
   207                          channelType,
   205                          channelId,
   208                          channelId,
   206                          bitrate,
   209                          bitrate,
   207                          channelDesc,
   210                          channelDesc,
   208                          imageUrl,
   211                          imageUrl,
       
   212                          genreName,
       
   213                          countryName,
       
   214                          languageName,
   209                          musicFlag);
   215                          musicFlag);
   210 
   216 
   211     CleanupStack::PopAndDestroy(4, &delSongName);
   217     CleanupStack::PopAndDestroy(4, &delSongName);
   212 }
   218 }
   213 
   219 
   313     int channelType;
   319     int channelType;
   314     int channelId;
   320     int channelId;
   315     int bitrate;
   321     int bitrate;
   316     QString channelDesc;
   322     QString channelDesc;
   317     QString imageUrl;
   323     QString imageUrl;
       
   324     QString genreName;
       
   325     QString countryName;
       
   326     QString languageName;
   318     QString musicStoreStatus;
   327     QString musicStoreStatus;
   319     for (int arrCount = 0 ; arrCount < songCount ; arrCount++ )
   328     for (int arrCount = 0 ; arrCount < songCount ; arrCount++ )
   320     {
   329     {
   321         songName = QString::fromUtf16(historyDataArr[arrCount]->GetSongInfo().Ptr(),
   330         songName = QString::fromUtf16(historyDataArr[arrCount]->GetSongInfo().Ptr(),
   322                              historyDataArr[arrCount]->GetSongInfo().Length());
   331                              historyDataArr[arrCount]->GetSongInfo().Length());
   331         bitrate = historyDataArr[arrCount]->GetBitrate();
   340         bitrate = historyDataArr[arrCount]->GetBitrate();
   332         channelDesc = QString::fromUtf16(historyDataArr[arrCount]->GetChannelDesc().Ptr(),
   341         channelDesc = QString::fromUtf16(historyDataArr[arrCount]->GetChannelDesc().Ptr(),
   333                              historyDataArr[arrCount]->GetChannelDesc().Length());
   342                              historyDataArr[arrCount]->GetChannelDesc().Length());
   334         imageUrl = QString::fromUtf16(historyDataArr[arrCount]->GetImageUrl().Ptr(),
   343         imageUrl = QString::fromUtf16(historyDataArr[arrCount]->GetImageUrl().Ptr(),
   335                                      historyDataArr[arrCount]->GetImageUrl().Length());
   344                                      historyDataArr[arrCount]->GetImageUrl().Length());
       
   345         genreName = QString::fromUtf16(historyDataArr[arrCount]->GetGenreName().Ptr(),                
       
   346                                      historyDataArr[arrCount]->GetGenreName().Length());
       
   347         countryName = QString::fromUtf16(historyDataArr[arrCount]->GetCountryName().Ptr(),
       
   348                                      historyDataArr[arrCount]->GetCountryName().Length());
       
   349         languageName = QString::fromUtf16(historyDataArr[arrCount]->GetLanguageName().Ptr(),
       
   350                                      historyDataArr[arrCount]->GetLanguageName().Length());
   336         musicStoreStatus = QString::fromUtf16(historyDataArr[arrCount]->GetChannelMusicStatus().Ptr(),
   351         musicStoreStatus = QString::fromUtf16(historyDataArr[arrCount]->GetChannelMusicStatus().Ptr(),
   337                              historyDataArr[arrCount]->GetChannelMusicStatus().Length());
   352                              historyDataArr[arrCount]->GetChannelMusicStatus().Length());
   338        IRQSongHistoryInfo* irqsongHistory = new IRQSongHistoryInfo();
   353        IRQSongHistoryInfo* irqsongHistory = new IRQSongHistoryInfo();
   339        if (NULL == irqsongHistory)
   354        if (NULL == irqsongHistory)
   340        {
   355        {
   341            break;
   356            break;
   342        }
   357        }
   343        irqsongHistory->setHistoryInfo(artist, songName, streamUrl, channelName, channelDesc 
   358        irqsongHistory->setHistoryInfo(artist, songName, streamUrl, channelName, channelDesc 
   344                                       , imageUrl, musicStoreStatus, channelType, channelId, bitrate);
   359                                       , imageUrl, genreName, countryName, languageName, musicStoreStatus, channelType, channelId, bitrate);
   345        aSongHistoryArr.append(irqsongHistory);
   360        aSongHistoryArr.append(irqsongHistory);
   346     }
   361     }
   347     
   362     
   348     historyDataArr.ResetAndDestroy();
   363     historyDataArr.ResetAndDestroy();
   349 }
   364 }
   441 // ---------------------------------------------------------------------------
   456 // ---------------------------------------------------------------------------
   442 EXPORT_C void IRQSongHistoryEngine::updateSongHistoryDb(int aChannelId,
   457 EXPORT_C void IRQSongHistoryEngine::updateSongHistoryDb(int aChannelId,
   443         const QString& aChannelName,
   458         const QString& aChannelName,
   444         const QString& aChannelUrl,
   459         const QString& aChannelUrl,
   445         const QString& aImageUrl,
   460         const QString& aImageUrl,
       
   461         const QString& aGenreName,
       
   462         const QString& aCountryName,
       
   463         const QString& aLanguageName,
   446         const QString& aMusicFlag)
   464         const QString& aMusicFlag)
   447 {
   465 {
   448     TInt ret = KErrNone ;
   466     TInt ret = KErrNone ;
   449     TUint16 channelId = aChannelId; // prevent data overflow
   467     TUint16 channelId = aChannelId; // prevent data overflow
   450 
   468 
   458     if (ret)
   476     if (ret)
   459     {
   477     {
   460         TPtrC channelName(reinterpret_cast<const TUint16*>(aChannelName.utf16()));
   478         TPtrC channelName(reinterpret_cast<const TUint16*>(aChannelName.utf16()));
   461         TPtrC channelUrl(reinterpret_cast<const TUint16*>(aChannelUrl.utf16()));
   479         TPtrC channelUrl(reinterpret_cast<const TUint16*>(aChannelUrl.utf16()));
   462         TPtrC imageUrl(reinterpret_cast<const TUint16*>(aImageUrl.utf16()));
   480         TPtrC imageUrl(reinterpret_cast<const TUint16*>(aImageUrl.utf16()));
       
   481         TPtrC genreName(reinterpret_cast<const TUint16*>(aGenreName.utf16()));
       
   482         TPtrC countryName(reinterpret_cast<const TUint16*>(aCountryName.utf16()));
       
   483         TPtrC languageName(reinterpret_cast<const TUint16*>(aLanguageName.utf16()));
   463         TPtrC musicFlag(reinterpret_cast<const TUint16*>(aMusicFlag.utf16()));
   484         TPtrC musicFlag(reinterpret_cast<const TUint16*>(aMusicFlag.utf16()));
   464         TRAP_IGNORE(iSongHistoryDb->UpdateSongHistoryDbL( channelId ,
   485         TRAP_IGNORE(iSongHistoryDb->UpdateSongHistoryDbL( channelId ,
   465                 channelName,
   486                 channelName,
   466                 channelUrl,
   487                 channelUrl,
   467                 imageUrl,
   488                 imageUrl,
       
   489                 genreName,
       
   490                 countryName,
       
   491                 languageName,
   468                 musicFlag));
   492                 musicFlag));
   469     }
   493     }
   470 }
   494 }
   471 
   495 
   472 EXPORT_C bool IRQSongHistoryEngine::deleteOneItem(int aIndex)
   496 EXPORT_C bool IRQSongHistoryEngine::deleteOneItem(int aIndex)
   478         return false;
   502         return false;
   479     }
   503     }
   480     
   504     
   481     return true;
   505     return true;
   482 }
   506 }
       
   507 
       
   508 EXPORT_C bool IRQSongHistoryEngine::deleteOneSongHistoryItem(int aIndex)
       
   509 {    
       
   510     int retValue = 0;
       
   511     retValue = iSongHistoryDb->DeleteOneSongHistory(aIndex);
       
   512     if( KErrNone != retValue )
       
   513     {
       
   514         return false;
       
   515     }
       
   516     
       
   517     return true;
       
   518 }