accessoryservices/accessoryserver/src/Policy/AccPolGenericIDAccessor.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2002-2006 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:  Private, Accessory Policy Generic ID Accessory
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    <AccPolGIDHeader.h>
       
    22 #include    <AccPolGenericID.h>
       
    23 #include    <AccConGenericID.h>
       
    24 #include    "AccPolGenericIDAccessor.h"
       
    25 #include    "acc_debug.h"
       
    26 
       
    27 // EXTERNAL DATA STRUCTURES
       
    28 
       
    29 // EXTERNAL FUNCTION PROTOTYPES
       
    30 
       
    31 // CONSTANTS
       
    32 
       
    33 // MACROS
       
    34 
       
    35 // LOCAL CONSTANTS AND MACROS
       
    36 
       
    37 // MODULE DATA STRUCTURES
       
    38 
       
    39 // LOCAL FUNCTION PROTOTYPES
       
    40 
       
    41 // FORWARD DECLARATIONS
       
    42 
       
    43 // ============================= LOCAL FUNCTIONS ===============================
       
    44 
       
    45 // ============================ MEMBER FUNCTIONS ===============================
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // TAccPolGenericIDAccessor::TAccPolGenericIDAccessor
       
    49 // C++ default constructor can NOT contain any code, that
       
    50 // might leave.
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 EXPORT_C TAccPolGenericIDAccessor::TAccPolGenericIDAccessor()
       
    54     {
       
    55     COM_TRACE_( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::TAccPolGenericIDAccessor()" );
       
    56     COM_TRACE_( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::TAccPolGenericIDAccessor() - return void" );
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // TAccPolGenericIDAccessor::SetFeatureAttributeL
       
    61 // Set matching Generic ID feature attribute.
       
    62 // (other items were commented in a header).
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 EXPORT_C void TAccPolGenericIDAccessor::SetFeatureAttributeL( 
       
    66     TAccPolGenericID& aGenericID,
       
    67     const TUint aGIDAttribute, 
       
    68     const TUint32 aGIDAttributeBitMask )
       
    69     {
       
    70     COM_TRACE_2( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetFeatureAttributeL() 0x%x, 0x%x", 
       
    71                   aGIDAttribute, 
       
    72                   aGIDAttributeBitMask );
       
    73 
       
    74     switch ( aGIDAttribute )
       
    75         {
       
    76         case KAccPolDTDeviceType:
       
    77             {
       
    78             aGenericID.iStaticAttributes.iAccessoryDeviceType = aGIDAttributeBitMask;
       
    79             }
       
    80             break;
       
    81 
       
    82         case KAccPolPCPhysicalConnection:
       
    83             {
       
    84             aGenericID.iStaticAttributes.iPhysicalConnection = aGIDAttributeBitMask;
       
    85             }
       
    86             break;
       
    87 
       
    88         case KAccPolAPApplicationProtocol:
       
    89             {
       
    90             aGenericID.iStaticAttributes.iApplicationProtocol = aGIDAttributeBitMask;
       
    91             }
       
    92             break;
       
    93 
       
    94         default:
       
    95             {
       
    96             // If attribute is not of known type leave with KErrGeneral
       
    97             User::Leave( KErrGeneral );
       
    98             }
       
    99         }
       
   100 
       
   101     COM_TRACE_( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetFeatureAttributeL() - return void" );
       
   102     }
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // TAccPolGenericIDAccessor::SetFeatureAttributeL
       
   106 // Set matching Generic ID feature attribute.
       
   107 // (other items were commented in a header).
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 EXPORT_C void TAccPolGenericIDAccessor::SetFeatureAttributeL( 
       
   111     TAccPolGenericID& aGenericID,
       
   112     const TUint aGIDAttribute, 
       
   113     const TUint64 aGIDAttributeBitMask )
       
   114     {
       
   115     COM_TRACE_1( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetFeatureAttributeL() %d", 
       
   116                   aGIDAttribute );
       
   117 
       
   118     switch ( aGIDAttribute )
       
   119         {
       
   120         case KAccPolSBCapabilities:
       
   121             {
       
   122             aGenericID.iStaticAttributes.iCapabilitiesSubblocks = aGIDAttributeBitMask;
       
   123             }
       
   124             break;
       
   125 
       
   126         default:
       
   127             {
       
   128             // If attribute is not of known type leave with KErrGeneral
       
   129             User::Leave( KErrGeneral );
       
   130             }
       
   131         }
       
   132     COM_TRACE_( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetFeatureAttributeL() - return void" );
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // TAccPolGenericIDAccessor::SetHWModelID
       
   137 // Set hardware model ID for Generic ID.
       
   138 // (other items were commented in a header).
       
   139 // -----------------------------------------------------------------------------
       
   140 //
       
   141 EXPORT_C void TAccPolGenericIDAccessor::SetHWModelID( 
       
   142     TAccPolGenericID& aGenericID,
       
   143     const TDesC& aHWModelID )
       
   144     {
       
   145     COM_TRACE_RAW_1( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetHWModelIDL() ", aHWModelID );
       
   146     aGenericID.iStaticAttributes.iHWModelID.Copy( aHWModelID );
       
   147     COM_TRACE_( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetHWModelIDL() - return void" );
       
   148     }
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // TAccPolGenericIDAccessor::SetHWDeviceID
       
   152 // Set hardware model ID for Generic ID.
       
   153 // (other items were commented in a header).
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 EXPORT_C void TAccPolGenericIDAccessor::SetHWDeviceID( 
       
   157     TAccPolGenericID& aGenericID,
       
   158     const TUint64 aHWDeviceID )
       
   159     {
       
   160     COM_TRACE_2( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetHWDeviceIDL() H:0x%x, L:0x%x",  
       
   161                   I64HIGH( aHWDeviceID ), 
       
   162                   I64LOW( aHWDeviceID ) );        
       
   163     aGenericID.iStaticAttributes.iHWDeviceID = aHWDeviceID;
       
   164     COM_TRACE_( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetHWDeviceIDL() - return void" );
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // TAccPolGenericIDAccessor::SetDeviceAddress
       
   169 // Set device address for Generic ID.
       
   170 // (other items were commented in a header).
       
   171 // -----------------------------------------------------------------------------
       
   172 //
       
   173 EXPORT_C void TAccPolGenericIDAccessor::SetDeviceAddress( 
       
   174     TAccPolGenericID& aGenericID,
       
   175     const TUint64 aDeviceAddress )
       
   176     {
       
   177     COM_TRACE_2( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetDeviceAddressL() H:0x%x, L:0x%x",
       
   178                   I64HIGH( aDeviceAddress ), 
       
   179                   I64LOW( aDeviceAddress ) );        
       
   180     aGenericID.iStaticAttributes.iDeviceAddress = aDeviceAddress;
       
   181     COM_TRACE_( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetDeviceAddressL() - return void" );
       
   182     }
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 // TAccPolGenericIDAccessor::SetDBIDL
       
   186 // Set unique identifier (DBID) for Generic ID.
       
   187 // (other items were commented in a header).
       
   188 // -----------------------------------------------------------------------------
       
   189 //
       
   190 EXPORT_C void TAccPolGenericIDAccessor::SetDBID( 
       
   191     TAccPolGenericID& aGenericID,
       
   192     const TInt aDBID )
       
   193     {
       
   194     COM_TRACE_1( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetDBIDL() 0x%x", aDBID );
       
   195     aGenericID.iStaticAttributes.iDBID = aDBID;
       
   196     COM_TRACE_( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::SetDBIDL() - return void" );
       
   197     }
       
   198 
       
   199 // -----------------------------------------------------------------------------
       
   200 // TAccPolGenericIDAccessor::CompareGenericID
       
   201 // Compare two Generic ID instances.
       
   202 // (other items were commented in a header).
       
   203 // -----------------------------------------------------------------------------
       
   204 //
       
   205 EXPORT_C TBool TAccPolGenericIDAccessor::CompareGenericID( 
       
   206     const TAccPolGenericID& aLValue,
       
   207     const TAccPolGenericID& aRValue )
       
   208     {
       
   209     COM_TRACE_( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::CompareGenericID()" );
       
   210     TBool ret( EFalse );
       
   211 
       
   212     ret = ( aLValue.iStaticAttributes.iAccessoryDeviceType == 
       
   213             aRValue.iStaticAttributes.iAccessoryDeviceType &&
       
   214             aLValue.iStaticAttributes.iPhysicalConnection == 
       
   215             aRValue.iStaticAttributes.iPhysicalConnection &&
       
   216             aLValue.iStaticAttributes.iApplicationProtocol == 
       
   217             aRValue.iStaticAttributes.iApplicationProtocol &&
       
   218             aLValue.iStaticAttributes.iCapabilitiesSubblocks == 
       
   219             aRValue.iStaticAttributes.iCapabilitiesSubblocks &&
       
   220             aLValue.iStaticAttributes.iHWModelID == 
       
   221             aRValue.iStaticAttributes.iHWModelID &&
       
   222             aLValue.iStaticAttributes.iHWDeviceID == 
       
   223             aRValue.iStaticAttributes.iHWDeviceID );
       
   224 
       
   225     COM_TRACE_1( "[AccFW: ACCPOLICY] TAccPolGenericIDAccessor::CompareGenericID() - return %d", ret );
       
   226     return ret;
       
   227     }
       
   228 
       
   229 // -----------------------------------------------------------------------------
       
   230 // TAccPolGenericIDAccessor::SetGenericIDStaticAttributes
       
   231 // -----------------------------------------------------------------------------
       
   232 //
       
   233 EXPORT_C void TAccPolGenericIDAccessor::SetGenericIDStaticAttributes( 
       
   234     CAccConGenericID* const aLGenericID, 
       
   235     const TAccPolGenericID& aRGenericID )
       
   236     {
       
   237     aLGenericID->iGenericID = aRGenericID;
       
   238     }
       
   239 
       
   240 // -----------------------------------------------------------------------------
       
   241 // TAccPolGenericIDAccessor::SetGenericIDStaticAttributes
       
   242 // -----------------------------------------------------------------------------
       
   243 //                                   
       
   244 void TAccPolGenericIDAccessor::SetGenericIDStaticAttributes( 
       
   245     TAccPolGenericID& aGenericID, 
       
   246     const TAccPolGIDHeader &aGenericIDHeader)
       
   247     {
       
   248 	aGenericID.iStaticAttributes = aGenericIDHeader;
       
   249     }
       
   250 
       
   251 // -----------------------------------------------------------------------------
       
   252 // TAccPolGenericIDAccessor::NameValueBuf
       
   253 // -----------------------------------------------------------------------------
       
   254 //
       
   255 EXPORT_C CBufFlat* TAccPolGenericIDAccessor::NameValueBuf( 
       
   256     CAccConGenericID* const aGenericID )
       
   257     {
       
   258     return aGenericID->iNameValueBuf;
       
   259     }
       
   260 
       
   261 // -----------------------------------------------------------------------------
       
   262 // TAccPolGenericIDAccessor::GenericIDRef
       
   263 // -----------------------------------------------------------------------------
       
   264 //
       
   265 EXPORT_C TAccPolGenericID& TAccPolGenericIDAccessor::GenericIDRef( 
       
   266     CAccConGenericID* const aGenericID )
       
   267     {
       
   268     return aGenericID->iGenericID;
       
   269     }
       
   270 
       
   271 #ifdef _DEBUG
       
   272 // -----------------------------------------------------------------------------
       
   273 // TAccPolGenericIDAccessor::DebugPrint
       
   274 // Trace out the static header of Generic ID instance in debug build.
       
   275 // (other items were commented in a header).
       
   276 // -----------------------------------------------------------------------------
       
   277 //
       
   278 EXPORT_C void TAccPolGenericIDAccessor::DebugPrint( const TAccPolGenericID& aGenericID )
       
   279     {
       
   280     COM_TRACE_( "[AccFW: ACCPOLICY] START GenericID:" );
       
   281     COM_TRACE_1("    DeviceType:0x%x",
       
   282                      aGenericID.iStaticAttributes.iAccessoryDeviceType );
       
   283     COM_TRACE_1( "    PhysicalConnection:0x%x", 
       
   284                       aGenericID.iStaticAttributes.iPhysicalConnection );
       
   285     COM_TRACE_1( "    ApplicationProtocol :0x%x", 
       
   286                       aGenericID.iStaticAttributes.iApplicationProtocol );
       
   287     COM_TRACE_2( "    CapabilitiesSubblocks: HIGH:0x%x, LOW:0x%x" ,
       
   288                       I64HIGH( aGenericID.iStaticAttributes.iCapabilitiesSubblocks ),
       
   289                       I64LOW( aGenericID.iStaticAttributes.iCapabilitiesSubblocks ) );
       
   290     COM_TRACE_RAW_1( "    HWModelID:", 
       
   291                           aGenericID.iStaticAttributes.iHWModelID );
       
   292     COM_TRACE_2( "    HWDeviceID: HIGH:0x%x, LOW:0x%x \n" ,
       
   293                       I64HIGH( aGenericID.iStaticAttributes.iHWDeviceID ),
       
   294                       I64LOW( aGenericID.iStaticAttributes.iHWDeviceID ) );
       
   295     COM_TRACE_2( "    DeviceAddress: HIGH:0x%x, LOW:0x%x" ,
       
   296                       I64HIGH( aGenericID.iStaticAttributes.iDeviceAddress ),
       
   297                       I64LOW( aGenericID.iStaticAttributes.iDeviceAddress ));
       
   298     COM_TRACE_1( "    Unique Id: %d", 
       
   299                       aGenericID.iStaticAttributes.iDBID );
       
   300     COM_TRACE_( "[AccFW: ACCPOLICY] GenericID END" );
       
   301     }
       
   302 #else
       
   303 
       
   304 // -----------------------------------------------------------------------------
       
   305 // TAccPolGenericIDAccessor::DebugPrint
       
   306 // This function does nothing in non-debug mode
       
   307 // (other items were commented in a header).
       
   308 // -----------------------------------------------------------------------------
       
   309 //
       
   310 EXPORT_C void TAccPolGenericIDAccessor::DebugPrint( const TAccPolGenericID& /*aGenericID*/ )
       
   311     {
       
   312     // No debug
       
   313     }
       
   314 
       
   315 #endif // _DEBUG
       
   316 
       
   317 //  End of File