remotemgmt_plat/syncml_ds_customization_api/tsrc/exampledevinfextdataplugin/inc/exampledevinfextdatacontainerplugin.h
branchRCL_3
changeset 25 b183ec05bd8c
equal deleted inserted replaced
24:13d7c31c74e0 25:b183ec05bd8c
       
     1 /*
       
     2 * Copyright (c) 2010 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:  Example Device Info Extension Data Container Plugin 
       
    15 *  header file.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef __EXAMPLEDEVINFEXTDATACONTAINERPLUGIN_H__
       
    20 #define __EXAMPLEDEVINFEXTDATACONTAINERPLUGIN_H__
       
    21 
       
    22 // EXTERNAL INCLUDES
       
    23 #include <nsmldevinfextdatacontainerplugin.h>
       
    24 
       
    25 // FORWARD DECLARATIONS
       
    26 class CDesCArrayFlat;
       
    27 
       
    28 //  CONSTANTS
       
    29 const TUint KExampleDevInfExtDataContainerImplUid = 0x2002DC7D;
       
    30 const TInt KExtensionElementMaxLength = 50;
       
    31 
       
    32 // CLASS DEFINITION
       
    33 /**
       
    34  * Type definition for TExampleDevInfExtExtensionItem, which holds
       
    35  * the contents for a single extension (i.e. XNam value + 0..N 
       
    36  * XVal values). Note that this type is only for testing purposes,
       
    37  * e.g. the maximum length of the XNam/XVal elements is set to 
       
    38  * 50 characters.
       
    39  */
       
    40 NONSHARABLE_CLASS( TExampleDevInfExtExtensionItem )
       
    41     {
       
    42     public:
       
    43         TBuf8< KExtensionElementMaxLength > iXNam;
       
    44         RArray< TBuf8 < KExtensionElementMaxLength > > iXValArray;
       
    45     };
       
    46 
       
    47 
       
    48 // CLASS DEFINITION
       
    49 /**
       
    50  * CExampleDevInfExtDataContainerPlugin is an example plugin,
       
    51  * which implements the CNSmlDevInfExtDataContainerPlugin ECom interface.
       
    52  * The example plugin is primarily used for unit test purposes.
       
    53  * It allows modifying the XNam & XVal entries stored in the plugin,
       
    54  * which in turn makes it possible to test the plugin interface
       
    55  * with different configurations.
       
    56  * 
       
    57  * Note that the maximum length for the XNam & XVal is limited to
       
    58  * 50 characters; with longer strings the values become truncated
       
    59  * to 50 characters.
       
    60  */
       
    61 class CExampleDevInfExtDataContainerPlugin : 
       
    62     public CNSmlDevInfExtDataContainerPlugin
       
    63     {
       
    64 
       
    65     public:  // Constructor(s) and destructor
       
    66         ~CExampleDevInfExtDataContainerPlugin();
       
    67         CExampleDevInfExtDataContainerPlugin();
       
    68         void ConstructL();
       
    69         static CExampleDevInfExtDataContainerPlugin* NewL();
       
    70     
       
    71     public: // From CNSmlDevInfExtDataContainerPlugin
       
    72         TInt GetExtensionCountL();
       
    73         const TDesC8& GetExtNameL( TInt aExtIndex );
       
    74         TInt GetExtValueCountL( TInt aExtIndex );
       
    75         const TDesC8& GetExtValueL( TInt aExtIndex, TInt aValueIndex );
       
    76 
       
    77     public:  // New methods
       
    78         /**
       
    79          * Removes all extension definitions currently configured
       
    80          *  to the plugin. After a call to this method, the extension
       
    81          *  count is zero.
       
    82          */
       
    83         void ClearExtensions();
       
    84         
       
    85         /**
       
    86          * Inserts a new extension with the given XNam name and XVal value
       
    87          * to the plugin. If there are multiple XVal to be defined per
       
    88          * XNam, this method shall be called multiple times with the same
       
    89          * XNam value.
       
    90          * 
       
    91          * @param aXNam XNam value for the extension to be added.
       
    92          * @param aXVal XVal value for the extension to be added.
       
    93          */
       
    94         void InsertExtension( const TDesC8& aXNam, const TDesC8& aXVal );
       
    95         
       
    96         /**
       
    97          * Removes the given extensions from the Plugin. If an extension with
       
    98          * the given XNam name is not found, does nothing.
       
    99          * 
       
   100          * @param aXNam The XNam value for the extension to be removed.
       
   101          */
       
   102         void RemoveExtension( const TDesC8& aXNam );
       
   103 
       
   104     private:  // Private utility methods
       
   105         TInt FindExtensionIndex( const TDesC8& aXNam );
       
   106         void AddXValToItem( const TInt aIndex, const TDesC8& aXVal );
       
   107         void AddNewXValItem( const TDesC8& aXNam, const TDesC8& aXVal );
       
   108         
       
   109     private:  // Data
       
   110         RArray< TExampleDevInfExtExtensionItem > iExtensionArray;
       
   111 
       
   112     };
       
   113         
       
   114 #endif // __EXAMPLEDEVINFEXTDATACONTAINERPLUGIN_H__