accessoryservices/accessoryserver/src/Control/AccModeSetting.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  Support class used to deliver accessory settings related
       
    15 *        parameters.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "acc_debug.h"
       
    23 #include <AccModeSetting.h>
       
    24 
       
    25 // EXTERNAL DATA STRUCTURES
       
    26 
       
    27 // EXTERNAL FUNCTION PROTOTYPES
       
    28 
       
    29 // CONSTANTS
       
    30 
       
    31 // MACROS
       
    32 
       
    33 // LOCAL CONSTANTS AND MACROS
       
    34 
       
    35 // MODULE DATA STRUCTURES
       
    36 
       
    37 // LOCAL FUNCTION PROTOTYPES
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 
       
    41 // ============================= LOCAL FUNCTIONS ===============================
       
    42 
       
    43 // ============================ MEMBER FUNCTIONS ===============================
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // TAccModeSetting::TAccModeSetting
       
    47 // C++ default constructor can NOT contain any code, that
       
    48 // might leave.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 EXPORT_C TAccModeSetting::TAccModeSetting()
       
    52     {
       
    53     API_TRACE_( "[AccFW:Client] TAccModeSetting::TAccModeSetting()" );
       
    54 
       
    55     iId = 0;
       
    56     iType = EAccModeSettingNotSet;
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // TAccModeSetting::SetId
       
    61 //
       
    62 // (other items were commented in a header).
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 EXPORT_C void TAccModeSetting::SetId( const TUint32 aId )
       
    66     {
       
    67     API_TRACE_1( "[AccFW:Client] TAccModeSetting::SetId(%d)", aId  );
       
    68 
       
    69     iId = aId;
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // TAccModeSetting::SetTInt
       
    74 //
       
    75 // (other items were commented in a header).
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 EXPORT_C void TAccModeSetting::SetTInt( const TInt aValue )
       
    79     {
       
    80     API_TRACE_1( "[AccFW:Client] TAccModeSetting::SetTInt(%d)", aValue );
       
    81 
       
    82     iValue.Num( aValue );
       
    83     iType = EAccModeSettingInt;
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // TAccModeSetting::SetTBool
       
    88 //
       
    89 // (other items were commented in a header).
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 EXPORT_C void TAccModeSetting::SetTBool( const TBool aValue )
       
    93     {
       
    94     API_TRACE_1( "[AccFW:Client] TAccModeSetting::SetTBool(%d)", aValue );
       
    95 
       
    96     if( aValue )
       
    97         {
       
    98         _LIT( KTrue, "1" );
       
    99         TBuf<1> temp;
       
   100         temp.Append( KTrue );
       
   101         iValue = temp;
       
   102         }
       
   103     else
       
   104         {
       
   105         _LIT( KFalse, "0" );
       
   106         TBuf<1> temp;
       
   107         temp.Append( KFalse );
       
   108         iValue = temp;
       
   109         }
       
   110 
       
   111     iType = EAccModeSettingBool;
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // TAccModeSetting::SetTDes
       
   116 //
       
   117 // (other items were commented in a header).
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 EXPORT_C TInt TAccModeSetting::SetTDes( const TDesC& aValue )
       
   121     {
       
   122     API_TRACE_( "[AccFW:Client] TAccModeSetting::SetTDes()" );
       
   123 
       
   124     if( KMaxAccModeSetting < aValue.Length() )
       
   125       {
       
   126       API_TRACE_1( "[AccFW:Client] TAccModeSetting::SetTDes() parameter aValue=%d too long", aValue.Length() );
       
   127         return KErrArgument;
       
   128       }
       
   129 
       
   130     iValue = aValue;
       
   131     iType = EAccModeSettingDes;
       
   132 
       
   133     API_TRACE_1( "[AccFW:Client] TAccModeSetting::SetTDes() returns %d", KErrNone );
       
   134     return KErrNone;
       
   135     }
       
   136 
       
   137 // -----------------------------------------------------------------------------
       
   138 // TAccModeSetting::Type
       
   139 //
       
   140 // (other items were commented in a header).
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 EXPORT_C TAccModeSettingType TAccModeSetting::Type() const
       
   144     {
       
   145     API_TRACE_1( "[AccFW:Client] TAccModeSetting::Type() - returns %d", iType );
       
   146 
       
   147     return iType;
       
   148     }
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // TAccModeSetting::Id
       
   152 //
       
   153 // (other items were commented in a header).
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 EXPORT_C TUint32 TAccModeSetting::Id() const
       
   157     {
       
   158     API_TRACE_1( "[AccFW:Client] TAccModeSetting::GetId() - returns %d", iId );
       
   159 
       
   160     return iId;
       
   161     }
       
   162 
       
   163 // -----------------------------------------------------------------------------
       
   164 // TAccModeSetting::GetTInt
       
   165 //
       
   166 // (other items were commented in a header).
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 EXPORT_C TInt TAccModeSetting::GetTInt( TInt& aValue ) const
       
   170     {
       
   171     if( iType != EAccModeSettingInt )
       
   172         {
       
   173         API_TRACE_1( "[AccFW:Client] TAccModeSetting::GetTInt() - returns %d", KErrNotFound );
       
   174         return KErrNotFound;
       
   175         }
       
   176 
       
   177     TLex parse( iValue );
       
   178     parse.Val( aValue );
       
   179 
       
   180     API_TRACE_1( "[AccFW:Client] TAccModeSetting::GetTInt() - aValue=%d", aValue );
       
   181 
       
   182     return KErrNone;
       
   183     }
       
   184 
       
   185 // -----------------------------------------------------------------------------
       
   186 // TAccModeSetting::GetTBool
       
   187 //
       
   188 // (other items were commented in a header).
       
   189 // -----------------------------------------------------------------------------
       
   190 //
       
   191 EXPORT_C TInt TAccModeSetting::GetTBool( TBool& aValue ) const
       
   192     {
       
   193     if( iType != EAccModeSettingBool )
       
   194         {
       
   195         API_TRACE_1( "[AccFW:Client] TAccModeSetting::GetTBool() - returns %d", KErrNotFound );
       
   196         return KErrNotFound;
       
   197         }
       
   198 
       
   199     TInt temp( 0 );
       
   200     TLex parse( iValue );
       
   201     parse.Val( temp );
       
   202     aValue = static_cast<TBool>( temp );
       
   203 
       
   204     API_TRACE_1( "[AccFW:Client] TAccModeSetting::GetTBool() - aValue=%d", aValue );
       
   205 
       
   206     return KErrNone;
       
   207     }
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 // TAccModeSetting::GetTDes
       
   211 //
       
   212 // (other items were commented in a header).
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 EXPORT_C TInt TAccModeSetting::GetTDes( TDes& aValue ) const
       
   216     {
       
   217     if( iType != EAccModeSettingDes )
       
   218         {
       
   219         API_TRACE_1( "[AccFW:Client] TAccModeSetting::GetTDes() - returns %d", KErrNotFound );
       
   220         return KErrNotFound;
       
   221         }
       
   222 
       
   223     aValue = iValue;
       
   224 
       
   225     API_TRACE_( "[AccFW:Client] TAccModeSetting::GetTDes() - return KErrNone" );
       
   226 
       
   227     return KErrNone;
       
   228     }
       
   229 
       
   230 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   231 //  End of File
       
   232