mmserv/radioutility/fmpresetutility/src/RadioFmPresetUtilityBody.cpp
changeset 12 5a06f39ad45b
parent 0 71ca22bcf22a
child 14 80975da52420
equal deleted inserted replaced
0:71ca22bcf22a 12:5a06f39ad45b
     1 /*
       
     2 * Copyright (c) 2002-2004 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:  Contains implementation of the CRadioFmPresetUtility::CBody
       
    15 *             	class, which controlls the presets for an FM tuner. 
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #include "RadioFmPresetUtilityBody.h"
       
    22 #include "debug.h"
       
    23 #include "RadioFmPresetRadioSettings.h"
       
    24 #include "RadioFmPresetCentralRepositoryHandler.h"
       
    25 #include "RadioFmPresetCRKeys.h"
       
    26 #include <e32Property.h>
       
    27 
       
    28 
       
    29 
       
    30 CRadioFmPresetUtility::CBody* CRadioFmPresetUtility::CBody::NewL( MRadioPresetObserver& aObserver )
       
    31 	{
       
    32 	CRadioFmPresetUtility::CBody* s = new(ELeave) CRadioFmPresetUtility::CBody();
       
    33 	s->iRadioPresetClient = &aObserver;
       
    34 	CleanupStack::PushL(s);
       
    35 	s->ConstructL();
       
    36 	CleanupStack::Pop(s);
       
    37 	return s;
       
    38 	}
       
    39 
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CRadioFmPresetUtility::CBody::CBody
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 CRadioFmPresetUtility::CBody::CBody()
       
    46     {
       
    47     }	
       
    48 // -----------------------------------------------------------------------------
       
    49 // CRadioFmPresetUtility::CBody::~CBody
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 CRadioFmPresetUtility::CBody::~CBody()
       
    53     {
       
    54     delete iRadioSettings;
       
    55     delete iCentralRepositoryHandler;
       
    56     }
       
    57 	
       
    58 // -----------------------------------------------------------------------------
       
    59 // CRadioFmPresetUtility::CBody::ConstructL
       
    60 // Two-phased constructor.
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 void CRadioFmPresetUtility::CBody::ConstructL()
       
    64 	{  
       
    65     iRadioSettings = new(ELeave) TRadioSettings;
       
    66     iCentralRepositoryHandler = CCentralRepositoryHandler::NewL(*iRadioSettings);
       
    67 	}
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CRadioFmPresetUtility::CBody::SetPresetL
       
    71 // 
       
    72 // (other items were commented in a header).
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 void CRadioFmPresetUtility::CBody::SetPresetL( TInt aIndex, const TFmPresetName& aName, TInt aFrequency )
       
    76 	{
       
    77 	iCentralRepositoryHandler->SavePresetFrequencyL(aIndex,aFrequency);
       
    78 	iCentralRepositoryHandler->SavePresetNameL(aIndex,aName);	
       
    79 	iRadioPresetClient->MrpeoPresetChanged(MRadioPresetObserver::EPresetAdded,aIndex);
       
    80 	}
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CRadioFmPresetUtility::CBody::SetPresetUrlL
       
    84 // 
       
    85 // (other items were commented in a header).
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 void CRadioFmPresetUtility::CBody::SetPresetUrlL( TInt aIndex, const TFmPresetUrl& aUrl )
       
    89 	{
       
    90 	iCentralRepositoryHandler->SavePresetUrlL(aIndex, aUrl);
       
    91 	iRadioPresetClient->MrpeoPresetChanged(MRadioPresetObserver::EPresetUpdated,aIndex);
       
    92 	}
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CRadioFmPresetUtility::CBody::SetPresetPtyL
       
    96 // 
       
    97 // (other items were commented in a header).
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 void CRadioFmPresetUtility::CBody::SetPresetPtyL( TInt aIndex, TUint aPty )
       
   101     {
       
   102     iCentralRepositoryHandler->SavePresetPTYL(aIndex, aPty);
       
   103     iRadioPresetClient->MrpeoPresetChanged(MRadioPresetObserver::EPresetUpdated,aIndex);
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CRadioFmPresetUtility::CBody::SetPresetPICodeL
       
   108 // 
       
   109 // (other items were commented in a header).
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 void CRadioFmPresetUtility::CBody::SetPresetPICodeL( TInt aIndex, TUint aPICode )
       
   113     {
       
   114     iCentralRepositoryHandler->SavePresetPIL(aIndex, aPICode);
       
   115     iRadioPresetClient->MrpeoPresetChanged(MRadioPresetObserver::EPresetUpdated,aIndex);
       
   116     }
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // CRadioFmPresetUtility::CBody::SetPresetFavouriteInfoL
       
   120 // 
       
   121 // (other items were commented in a header).
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 void CRadioFmPresetUtility::CBody::SetPresetFavouriteInfoL( TInt aIndex, TBool aFavourite )
       
   125     {
       
   126     iCentralRepositoryHandler->SavePresetFavouriteInfoL(aIndex, aFavourite);
       
   127     iRadioPresetClient->MrpeoPresetChanged(MRadioPresetObserver::EPresetUpdated,aIndex);
       
   128     }
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CRadioFmPresetUtility::CBody::SetPresetUserRenameInfoL
       
   132 // 
       
   133 // (other items were commented in a header).
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 void CRadioFmPresetUtility::CBody::SetPresetUserRenameInfoL( TInt aIndex, TBool aRename )
       
   137     {
       
   138     iCentralRepositoryHandler->SavePresetUserRenameInfoL(aIndex, aRename);
       
   139     iRadioPresetClient->MrpeoPresetChanged(MRadioPresetObserver::EPresetUpdated,aIndex);
       
   140     }
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // CRadioFmPresetUtility::CBody::GetPresetL
       
   144 // 
       
   145 // (other items were commented in a header).
       
   146 // -----------------------------------------------------------------------------
       
   147 //	
       
   148 void CRadioFmPresetUtility::CBody::GetPresetL( TInt aIndex, TFmPresetName& aName, TInt& aFrequency )
       
   149     {	
       
   150     aFrequency = iCentralRepositoryHandler->RetrievePresetFrequencyL(aIndex);
       
   151     aName      = iCentralRepositoryHandler->RetrievePresetNameL(aIndex);
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // CRadioFmPresetUtility::CBody::GetPresetNameL
       
   156 // 
       
   157 // (other items were commented in a header).
       
   158 // -----------------------------------------------------------------------------
       
   159 //	
       
   160 void CRadioFmPresetUtility::CBody::GetPresetNameL( TInt aIndex, TFmPresetName& aName )
       
   161 	{
       
   162    	aName = iCentralRepositoryHandler->RetrievePresetNameL(aIndex);
       
   163 	}
       
   164 
       
   165 // -----------------------------------------------------------------------------
       
   166 // CRadioFmPresetUtility::CBody::GetPresetUrlL
       
   167 // 
       
   168 // (other items were commented in a header).
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 void CRadioFmPresetUtility::CBody::GetPresetUrlL( TInt aIndex, TFmPresetUrl& aUrl )
       
   172     {
       
   173     aUrl = iCentralRepositoryHandler->RetrievePresetUrlL(aIndex);
       
   174     }
       
   175 
       
   176 // -----------------------------------------------------------------------------
       
   177 // CRadioFmPresetUtility::CBody::GetPresetPtyL
       
   178 // 
       
   179 // (other items were commented in a header).
       
   180 // -----------------------------------------------------------------------------
       
   181 //  
       
   182 void CRadioFmPresetUtility::CBody::GetPresetPtyL( TInt aIndex, TUint& aPty )
       
   183     {
       
   184     aPty = iCentralRepositoryHandler->RetrievePresetPTYL(aIndex);
       
   185     }
       
   186 
       
   187 // -----------------------------------------------------------------------------
       
   188 // CRadioFmPresetUtility::CBody::GetPresetPICodeL
       
   189 // 
       
   190 // (other items were commented in a header).
       
   191 // -----------------------------------------------------------------------------
       
   192 //  
       
   193 void CRadioFmPresetUtility::CBody::GetPresetPICodeL( TInt aIndex, TUint& aPICode )
       
   194     {
       
   195     aPICode = iCentralRepositoryHandler->RetrievePresetPIL(aIndex);
       
   196     }
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // CRadioFmPresetUtility::CBody::RetrievePresetFavouriteL
       
   200 // 
       
   201 // (other items were commented in a header).
       
   202 // -----------------------------------------------------------------------------
       
   203 //  
       
   204 void CRadioFmPresetUtility::CBody::GetPresetFavouriteInfoL( TInt aIndex, TBool& aFavourite )
       
   205     {
       
   206     aFavourite = iCentralRepositoryHandler->RetrievePresetFavouriteL(aIndex);
       
   207     }
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 // CRadioFmPresetUtility::CBody::GetPresetUserRenameInfoL
       
   211 // 
       
   212 // (other items were commented in a header).
       
   213 // -----------------------------------------------------------------------------
       
   214 //  
       
   215 void CRadioFmPresetUtility::CBody::GetPresetUserRenameInfoL( TInt aIndex, TBool& aRename )
       
   216     {
       
   217     aRename = iCentralRepositoryHandler->RetrievePresetUserRenameL(aIndex);
       
   218     }
       
   219 
       
   220 // -----------------------------------------------------------------------------
       
   221 // CRadioFmPresetUtility::CBody::GetPresetFrequencyL
       
   222 // 
       
   223 // (other items were commented in a header).
       
   224 // -----------------------------------------------------------------------------
       
   225 //	
       
   226 void CRadioFmPresetUtility::CBody::GetPresetFrequencyL( TInt aIndex, TInt& aFrequency )
       
   227 	{
       
   228     aFrequency = iCentralRepositoryHandler->RetrievePresetFrequencyL(aIndex);
       
   229 	}
       
   230 
       
   231 // -----------------------------------------------------------------------------
       
   232 // CRadioFmPresetUtility::CBody::GetMaxNumberOfPresets
       
   233 // 
       
   234 // (other items were commented in a header).
       
   235 // -----------------------------------------------------------------------------
       
   236 //
       
   237 TInt CRadioFmPresetUtility::CBody::GetMaxNumberOfPresets( TInt& aMaxNumOfPresets ) const
       
   238 	{
       
   239 	aMaxNumOfPresets = KMaxNumberOfPresetStations;
       
   240 	return KErrNone;
       
   241 	}
       
   242 
       
   243 // -----------------------------------------------------------------------------
       
   244 // CRadioFmPresetUtility::CBody::GetNumberOfPresets
       
   245 // 
       
   246 // (other items were commented in a header).
       
   247 // -----------------------------------------------------------------------------
       
   248 //	
       
   249 TInt CRadioFmPresetUtility::CBody::GetNumberOfPresets( TInt& aNumOfPresets ) const
       
   250 	{	 
       
   251 	TInt count = 0;
       
   252 	TInt error = KErrNone;
       
   253 	
       
   254 	TRAP_IGNORE(iCentralRepositoryHandler->GetNumberOfPresetsL(count);)
       
   255     
       
   256     aNumOfPresets = count;
       
   257 	return error;
       
   258 	}
       
   259 
       
   260 // -----------------------------------------------------------------------------
       
   261 // CRadioFmPresetUtility::CBody::GetFirstPresetL
       
   262 // 
       
   263 // (other items were commented in a header).
       
   264 // -----------------------------------------------------------------------------
       
   265 //
       
   266 void CRadioFmPresetUtility::CBody::GetFirstPresetL( TInt& aIndex ) const
       
   267 	{
       
   268     TInt firstPresetsIndex = 0;
       
   269     iCentralRepositoryHandler->GetFirstPresetL(firstPresetsIndex);
       
   270     aIndex = firstPresetsIndex;    
       
   271 	}
       
   272 
       
   273 // -----------------------------------------------------------------------------
       
   274 // CRadioFmPresetUtility::CBody::GetNextPresetL
       
   275 // 
       
   276 // (other items were commented in a header).
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 void CRadioFmPresetUtility::CBody::GetNextPresetL( TInt aIndex, TInt& aNextIndex ) const
       
   280 	{
       
   281      
       
   282     iCentralRepositoryHandler->GetNextPresetL(aIndex,aNextIndex); 
       
   283     
       
   284 	}
       
   285 
       
   286 // -----------------------------------------------------------------------------
       
   287 // CRadioFmPresetUtility::CBody::DeletePresetL
       
   288 // 
       
   289 // (other items were commented in a header).
       
   290 // -----------------------------------------------------------------------------
       
   291 //	
       
   292 void CRadioFmPresetUtility::CBody::DeletePresetL( TInt aIndex )
       
   293 	{
       
   294     iCentralRepositoryHandler->DeletePresetL(aIndex);
       
   295     
       
   296     iRadioPresetClient->MrpeoPresetChanged(MRadioPresetObserver::EPresetDeleted,aIndex);
       
   297     
       
   298 	}
       
   299 
       
   300 // End of File