natfw/natfwunsaf_protocols/unsaf_codec/inc/natfwunsaftextattribute.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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 
       
    20 
       
    21 #ifndef CNATFWUNSAFTEXTATTRIBUTE_H
       
    22 #define CNATFWUNSAFTEXTATTRIBUTE_H
       
    23 
       
    24 // INCLUDES
       
    25 #include <in_sock.h>
       
    26 #include "natfwunsafattribute.h"
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 
       
    30 // CLASS DECLARATION
       
    31 /**
       
    32  * An abstract base class for variable length text attributes.
       
    33  * The length of the value must be a multiple of 4 measured in bytes.
       
    34  */
       
    35 class CNATFWUNSAFTextAttribute : public CNATFWUNSAFAttribute
       
    36     {
       
    37     public: // Constructors and destructor
       
    38 
       
    39         /**
       
    40         * Destructor, deletes the resources of CNATFWUNSAFTextAttribute.
       
    41         */
       
    42         virtual ~CNATFWUNSAFTextAttribute();
       
    43 
       
    44     public: // From CNATFWUNSAFAttribute
       
    45 
       
    46         HBufC8* EncodeValueL() const;
       
    47 
       
    48     public: // New functions
       
    49 
       
    50         /**
       
    51         * Returns the attribute value
       
    52         * @return Attribute value
       
    53         */
       
    54         IMPORT_C const TDesC8& Value() const;
       
    55 
       
    56     protected: // Constructors
       
    57 
       
    58         CNATFWUNSAFTextAttribute();
       
    59 
       
    60         /**
       
    61         * Second phase constructor.
       
    62         * @param aValue Attribute value, does not contain the attribute length
       
    63         */
       
    64         void ConstructL(const TDesC8& aValue);
       
    65 
       
    66     protected: // New functions
       
    67 
       
    68         /**
       
    69         * Decodes an UNSAF attribute from a byte stream.
       
    70         * @param aByteStream Byte stream, containing attribute type, length and
       
    71         *    value.
       
    72         */
       
    73         void DecodeL(const TDesC8& aByteStream);
       
    74 
       
    75     private:
       
    76 
       
    77         enum TValueGranularity
       
    78             {
       
    79             //The length of iValue has to be a multiple of 4
       
    80             EGranularity = 4
       
    81             };
       
    82 
       
    83     private: // Data
       
    84 
       
    85         //Attribute value, owned
       
    86         HBufC8* iValue;
       
    87 
       
    88     private: // For testing purposes
       
    89 
       
    90         __DECLARE_TEST;
       
    91     };
       
    92 
       
    93 #endif // CNATFWUNSAFTEXTATTRIBUTE_H
       
    94 
       
    95