internetradio2.0/favoritesdbsrc/irfavoritesdb.cpp
changeset 8 3b03c28289e6
parent 5 0930554dc389
child 11 f683e24efca3
equal deleted inserted replaced
5:0930554dc389 8:3b03c28289e6
   178             //Convert to Plugnized Preset
   178             //Convert to Plugnized Preset
   179             //That is accepted by the preset server
   179             //That is accepted by the preset server
   180             preset->CIRIsdsPresetToCIRPresetImpl(aPreset);
   180             preset->CIRIsdsPresetToCIRPresetImpl(aPreset);
   181             //setname of CPSPresetInterface is called
   181             //setname of CPSPresetInterface is called
   182             preset->SetNameL( aPreset.GetName() );
   182             preset->SetNameL( aPreset.GetName() );
   183             //asign the preset id of the fav preset to uniqid value of the preset
       
   184             aPreset.SetUniqId(preset->Id());
       
   185             transaction->CommitL();
   183             transaction->CommitL();
   186             CleanupStack::PopAndDestroy( transaction );
   184             CleanupStack::PopAndDestroy( transaction );
   187             //added to check multiple insertion
   185             //added to check multiple insertion
   188             presetSaved = ETrue;
   186             presetSaved = ETrue;
   189             }
   187             }
   407 //for presetSync
   405 //for presetSync
   408 //---------------------------------------------------------------------------
   406 //---------------------------------------------------------------------------
   409 //
   407 //
   410 
   408 
   411 EXPORT_C void CIRFavoritesDb::ReplacePresetL( CIRIsdsPreset& aNewPreset )
   409 EXPORT_C void CIRFavoritesDb::ReplacePresetL( CIRIsdsPreset& aNewPreset )
   412 	{
   410 {
   413 	IRLOG_DEBUG( "CIRFavoritesDb::ReplacePresetL" );
   411 	IRLOG_DEBUG( "CIRFavoritesDb::ReplacePresetL" );
   414 	iMoveStatus=EFalse;
   412 	iMoveStatus=EFalse;
   415 	CIRPreset* preset;
   413 	CIRPreset* preset;
   416 	TInt index = SearchPreset(aNewPreset.GetId(),KNullId);
   414 	TInt index = SearchPreset(aNewPreset.GetId(),KNullId);
   417 	//actual index
   415 	//actual index
   418     if (index >= 0)
   416     if (index >= 0)
   419         {
   417     {
   420         ASSERT( index >= 0 || index < iFavPresetList.Count() );
   418         ASSERT( index >= 0 || index < iFavPresetList.Count() );
   421     	index = iFavPresetList[index]->Index();
   419     	index = iFavPresetList[index]->Index();
   422     	preset = PresetByIndex(index);
   420     	preset = PresetByIndex(index);
   423     	if(preset)
   421     	if (preset)
   424     		{
   422     	{
   425         	CPSTransaction* transaction = preset->CreateTransactionLC();
   423     	    CPSTransaction* transaction = preset->CreateTransactionLC();
   426         	//change the preset data and commit
   424         	//change the preset data and commit
       
   425     	    //update 'name' only if this station has not been renamed before
       
   426     	    if (preset->GetRenamed())
       
   427             {
       
   428     	        aNewPreset.SetName(preset->Name());
       
   429             }
   427         	preset->CIRIsdsPresetToCIRPresetImpl(aNewPreset);
   430         	preset->CIRIsdsPresetToCIRPresetImpl(aNewPreset);
   428         	preset->SetChannelType(EIsdsPreset);
   431         	preset->SetChannelType(EIsdsPreset);
   429         		preset->SetNameL( aNewPreset.GetName() );
       
   430         	transaction->CommitL();
   432         	transaction->CommitL();
   431         	CleanupStack::PopAndDestroy( transaction );
   433         	CleanupStack::PopAndDestroy( transaction );
   432     		}
   434     	}
   433         }
   435     }
   434 	IRLOG_DEBUG( "CIRFavoritesDb::ReplacePresetL - Exiting." );
   436 	IRLOG_DEBUG( "CIRFavoritesDb::ReplacePresetL - Exiting." );
   435 	}
   437 }
   436 
   438 
   437 //---------------------------------------------------------------------------
   439 //---------------------------------------------------------------------------
   438 //CIRFavoritesDb::ReplaceUserDefinedPresetL()
   440 //CIRFavoritesDb::ReplaceUserDefinedPresetL()
   439 //replaces a userdefined preset with a new userdefiend preset
   441 //replaces a userdefined preset with a new userdefiend preset
   440 //for presetSync
   442 //for presetSync
   580     CleanupStack::PopAndDestroy(transaction);
   582     CleanupStack::PopAndDestroy(transaction);
   581     
   583     
   582     return KErrNone;
   584     return KErrNone;
   583 }
   585 }
   584 
   586 
       
   587 EXPORT_C TInt CIRFavoritesDb::RenamePresetL(const CIRIsdsPreset &aIsdsPreset, const TDesC &aNewName)
       
   588 {
       
   589     TInt index = 0;
       
   590     if (aIsdsPreset.GetChannelType() == 0)
       
   591     {
       
   592         index = SearchUserDefinedPreset(aNewName, aIsdsPreset.GetChannelUrlAtL(0));
       
   593         if (KErrNotFound != index)
       
   594         {
       
   595             //there is already a user-defined station with same name and url
       
   596             return KErrAlreadyExists;
       
   597         }
       
   598         else
       
   599         {
       
   600             index = SearchUserDefinedPreset(aIsdsPreset.GetName(), aIsdsPreset.GetChannelUrlAtL(0));
       
   601         }
       
   602     }
       
   603     else
       
   604     {
       
   605         index = SearchPreset(aIsdsPreset.GetId(), KNullId);
       
   606     }
       
   607     
       
   608     if (KErrNotFound == index)
       
   609     {
       
   610         return KErrNotFound;
       
   611     }
       
   612     
       
   613     CIRPreset *irPreset = iFavPresetList[index];
       
   614     //open a transaction with the preset server
       
   615     CPSTransaction* transaction = irPreset->CreateTransactionLC();
       
   616     irPreset->SetNameL(aNewName);
       
   617     irPreset->SetRenamed();
       
   618     transaction->CommitL();
       
   619     CleanupStack::PopAndDestroy(transaction);
       
   620     
       
   621     return KErrNone;
       
   622 }
       
   623 
   585 //---------------------------------------------------------------------------
   624 //---------------------------------------------------------------------------
   586 //CIRFavoritesDb::ConstructL()
   625 //CIRFavoritesDb::ConstructL()
   587 //Standard 2nd phase construction
   626 //Standard 2nd phase construction
   588 //---------------------------------------------------------------------------
   627 //---------------------------------------------------------------------------
   589 //
   628 //