mmserv/radioutility/presetutility/src/presetutilitybody.cpp
changeset 14 80975da52420
equal deleted inserted replaced
12:5a06f39ad45b 14:80975da52420
       
     1 /*
       
     2 * Copyright (c) 2009 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:
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 #include "presetutilitybody.h"
       
    20 #include "cenrephandler.h"
       
    21 #include "presetcrkeys.h"
       
    22 #include <presetutilityobserver.h>
       
    23 #include "trace.h"
       
    24 
       
    25 
       
    26 // ============= MEMBER FUNCTIONS ==============
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 //
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 EXPORT_C CPresetUtilityBody* CPresetUtilityBody::NewL()
       
    33     {
       
    34     FUNC_LOG;
       
    35     CPresetUtilityBody* self = new (ELeave) CPresetUtilityBody();
       
    36     CleanupStack::PushL( self );
       
    37     self->ConstructL();
       
    38     CleanupStack::Pop( self );
       
    39     return self;
       
    40     }
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 CPresetUtilityBody::CPresetUtilityBody()
       
    47     {
       
    48     FUNC_LOG;
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 EXPORT_C CPresetUtilityBody::~CPresetUtilityBody()
       
    56     {
       
    57     FUNC_LOG;
       
    58     delete iCenrepHandler;
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 void CPresetUtilityBody::ConstructL()
       
    66     {
       
    67     FUNC_LOG;
       
    68     iCenrepHandler = CCenrepHandler::NewL();
       
    69     }
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 void CPresetUtilityBody::SetObserver( MPresetUtilityObserver* aObserver )
       
    76     {
       
    77     FUNC_LOG;
       
    78     iObserver = aObserver;
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 TInt CPresetUtilityBody::MaxNumberOfPresets() const
       
    86     {
       
    87     FUNC_LOG;
       
    88     return iCenrepHandler->MaxPresetCount();
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 TInt CPresetUtilityBody::PresetCount() const
       
    96     {
       
    97     FUNC_LOG;
       
    98     return iCenrepHandler->PresetCount();
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 TInt CPresetUtilityBody::FirstPreset() const
       
   106     {
       
   107     FUNC_LOG;
       
   108     return iCenrepHandler->FirstPreset();
       
   109     }
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 TInt CPresetUtilityBody::NextPreset( TInt aFromIndex ) const
       
   116     {
       
   117     return iCenrepHandler->NextPreset( aFromIndex );
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 TInt CPresetUtilityBody::DeletePreset( TInt aIndex )
       
   125     {
       
   126     FUNC_LOG;
       
   127     TInt err( iCenrepHandler->DeletePreset( aIndex ) );
       
   128     if ( iObserver )
       
   129         {
       
   130         iObserver->PresetChanged( MPresetUtilityObserver::EPresetDeleted, aIndex );
       
   131         }
       
   132     return err;
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 TInt CPresetUtilityBody::SavePresetL( const TPreset& aPreset, TInt aIndex )
       
   140     {
       
   141     FUNC_LOG;
       
   142     TInt usedIndex = iCenrepHandler->SavePresetL( aPreset, aIndex );
       
   143     if ( iObserver )
       
   144         {
       
   145         iObserver->PresetChanged( MPresetUtilityObserver::EPresetAdded, aIndex );
       
   146         }
       
   147     return usedIndex;
       
   148     }
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 // -----------------------------------------------------------------------------
       
   153 //
       
   154 void CPresetUtilityBody::ReadPresetL( TInt aIndex, TPreset& aPreset )
       
   155     {
       
   156     FUNC_LOG;
       
   157     iCenrepHandler->ReadPresetL( aIndex, aPreset );
       
   158     }