websrv_pub/web_service_connection_api/inc/SenXmlProperties.h
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 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:  Xml properties class declaration     
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef SEN_XML_PROPERTIES_H
       
    20 #define SEN_XML_PROPERTIES_H
       
    21 
       
    22 #include <e32std.h>
       
    23 #include <SenDomFragment.h>
       
    24 #include <MSenProperties.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class RWriteStream;
       
    28 class CSenXmlReader;
       
    29 class CSenPropertiesFragment;
       
    30 
       
    31 // CONSTANTS
       
    32 _LIT8(KSenXmlPropertiesLocalname,       "Properties");
       
    33 _LIT8(KSenTypeAttributeName,            "Type");
       
    34 _LIT8(KSenOmittedAttributeName,         "Omitted");
       
    35 _LIT8(KSenOmittedTrueNoValue,            "");
       
    36 _LIT8(KSenPropertyTrue,                 "true");
       
    37 _LIT8(KSenPropertyFalse,                "false");
       
    38 
       
    39 
       
    40 //_LIT8(KSenXmlPropertiesQualifiedname,  "props:Properties);
       
    41 //_LIT8(KSenXmlPropertiesNamespace,      "urn:com.nokia.Sen.properties.1.0");
       
    42 
       
    43 // CLASS DESCRIPTION
       
    44 
       
    45 /*
       
    46 * 
       
    47 * This class provides XML based implementation, which is mainly targetted
       
    48 * for further evolved subclasses, which extend this to more concrete classes,
       
    49 * like CSenHttpTransportProperties. Class provides serialization of properties
       
    50 * into XML.
       
    51 * 
       
    52 * Please bear in mind the following limitations:
       
    53 * 
       
    54 * 1. It is illegal to provide following property names as argument to 
       
    55 *    any of the setter methods, as they become XML tags - local element
       
    56 *    names - when properties object is serialized:
       
    57 *      (a) zero-length descriptor
       
    58 *      (b) descriptor starts with number and
       
    59 *      c descriptor contains any of the 5 basic XML entities in 
       
    60 *          unencoded form (&, ', ", <, >)
       
    61 * 
       
    62 * 2. It is illegal to provide following property values as argument to 
       
    63 *    any of the setter methods, as they become XML element content when 
       
    64 *    properties object is serialized:
       
    65 *      (a) descriptor contains any of the 5 basic XML entities in
       
    66 *      unencoded form (&, ', ", <, >)
       
    67 * @lib SenUtils.lib
       
    68 * @since Series60 5.0
       
    69 */
       
    70 
       
    71 class CSenXmlProperties : public CBase, public MSenProperties
       
    72     {
       
    73     public:
       
    74 
       
    75         /**
       
    76         * Basic constructor.
       
    77         * @return a pointer to new CSenXmlProperties class instance.
       
    78         */
       
    79         IMPORT_C static CSenXmlProperties* NewL();
       
    80         /**
       
    81         * Basic constructor.
       
    82         * @return a pointer to new CSenXmlProperties class instance.
       
    83         */        
       
    84         IMPORT_C static CSenXmlProperties* NewLC();
       
    85 
       
    86         /**
       
    87         * Basic constructor.
       
    88 		* @param aXmlUtf8 
       
    89     	* @param aParser It is a XML reader        
       
    90         * @return a pointer to new CSenTransportProperties class instance.
       
    91         */
       
    92         IMPORT_C static CSenXmlProperties* NewL(const TDesC8& aXmlUtf8,
       
    93                                        CSenXmlReader& aParser);
       
    94         /**
       
    95         * Basic constructor.
       
    96 		* @param aXmlUtf8 
       
    97     	* @param aParser It is a XML reader        
       
    98         * @return a pointer to new CSenTransportProperties class instance.
       
    99         */
       
   100         IMPORT_C static CSenXmlProperties* NewLC(const TDesC8& aXmlUtf8,
       
   101                                         CSenXmlReader& aParser);
       
   102 
       
   103         /**
       
   104         * Basic constructor.
       
   105 		* @param aElement
       
   106         * @return a pointer to new CSenXmlProperties class instance.
       
   107         */
       
   108         IMPORT_C static CSenXmlProperties* NewL(const CSenElement& aElement);
       
   109         /**
       
   110         * Basic constructor.
       
   111 		* @param aElement
       
   112         * @return a pointer to new CSenXmlProperties class instance.
       
   113         */        
       
   114         IMPORT_C static CSenXmlProperties* NewLC(const CSenElement& aElement);
       
   115 
       
   116         // From MSenProperties
       
   117         virtual void SetReader(CSenXmlReader& aReader);
       
   118         virtual TSenPropertiesClassType PropertiesClassType();
       
   119         virtual void WriteToL(RWriteStream& aWriteStream);
       
   120         virtual void ReadFromL(const TDesC8& aBuffer);
       
   121         virtual HBufC8* AsUtf8L();
       
   122         virtual HBufC8* AsUtf8LC();
       
   123         virtual TBool IsSafeToCast(TSenPropertiesClassType aClass);
       
   124         
       
   125         virtual MSenProperties* Clone(TInt& aOkOrError) const;
       
   126         virtual MSenProperties* CloneL() const;
       
   127 
       
   128         /**
       
   129         * @see MSenProperties
       
   130         * Leave codes: 
       
   131         *      KErrSenInvalidCharacters if aName contains illegal characters.     
       
   132         *      KErrSenZeroLengthDescriptor if aName is zero length.
       
   133         */
       
   134         virtual TInt SetPropertyL(const TDesC8& aName,
       
   135                                   const TDesC8& aValue);
       
   136 
       
   137         virtual TInt PropertyL(const TDesC8& aName, TPtrC8& aValue);
       
   138         
       
   139         /**
       
   140         * @see MSenProperties
       
   141         * Leave codes: 
       
   142         *      KErrSenInvalidCharacters if aName contains illegal characters.     
       
   143         *      KErrSenZeroLengthDescriptor if aName is zero length.
       
   144         */
       
   145         virtual TInt SetIntPropertyL(const TDesC8& aName,
       
   146                                      const TInt aValue);
       
   147                                      
       
   148         virtual TInt IntPropertyL(const TDesC8& aName,
       
   149                                   TInt& aValue);
       
   150         /**
       
   151         * @see MSenProperties
       
   152         * Leave codes: 
       
   153         *      KErrSenInvalidCharacters if aName contains illegal characters.     
       
   154         *      KErrSenZeroLengthDescriptor if aName is zero length.
       
   155         */
       
   156         virtual TInt SetBoolPropertyL(const TDesC8& aName,
       
   157                                       const TBool aValue);
       
   158                                       
       
   159         virtual TInt BoolPropertyL(const TDesC8& aName,
       
   160                                    TBool& aValue);        
       
   161         virtual TInt SetOmittedL(const TDesC8& aName, TBool aValue);
       
   162 
       
   163         virtual TInt RemovePropertyL(const TDesC8& aName);
       
   164         /**
       
   165         * Destructor.
       
   166         */
       
   167         virtual ~CSenXmlProperties();
       
   168         
       
   169         /**
       
   170         * Sets new property. 
       
   171         *
       
   172         * If property with given name does not exist, 
       
   173         * new property with given value will be added. Otherwise the value of 
       
   174         * existing property will be updated.
       
   175         *
       
   176         * @since Series60
       
   177         * @param aName         Name of the property, which can be later used to
       
   178         *                      refer the given value.
       
   179         * @param aValue        Is the value of this property.
       
   180         * @param aType         Is the type of this property.
       
   181         * @return              KErrNone if no error, or some of the system wide
       
   182         *                      error codes.
       
   183         */
       
   184         virtual TInt SetPropertyL(const TDesC8& aName, 
       
   185                                   const TDesC8& aValue,
       
   186                                   const TDesC8& aType);
       
   187 
       
   188         /**
       
   189         * Gets the value of the property behind certain name.
       
   190         * @since Series60
       
   191         * @param aName    The name identifying this property.
       
   192         * @param aValue   A TPtrC8 reference to be filled in with the value of
       
   193         *                 the property.
       
   194         * @param aType    A TPtrC8 reference to be filled in with the type of
       
   195         *                 the property.
       
   196         * @return         KErrNone if no error, or some of the system wide
       
   197         *                 error codes.     
       
   198         */
       
   199         virtual TInt PropertyL(const TDesC8& aName, 
       
   200                                TPtrC8& aValue,
       
   201                                TPtrC8& aType);
       
   202     
       
   203     protected: // base class functions
       
   204 
       
   205         virtual void BaseConstructL(const TDesC8& aLocalname, 
       
   206                                     const TDesC8& aXml,
       
   207                                     CSenXmlReader* aParser = NULL);
       
   208 
       
   209         virtual void BaseConstructL(const TDesC8& aNamespace, 
       
   210                                     const TDesC8& aLocalname, 
       
   211                                     const TDesC8& aXml,
       
   212                                     CSenXmlReader* aParser = NULL);
       
   213 
       
   214         virtual void BaseConstructL(const TDesC8& aNamespace, 
       
   215                                     const TDesC8& aLocalname, 
       
   216                                     const TDesC8& aQualifiedName, 
       
   217                                     const TDesC8& aXml,
       
   218                                     CSenXmlReader* aParser = NULL);
       
   219 
       
   220         virtual void BaseConstructL(const CSenElement& aElement);
       
   221 
       
   222     protected:
       
   223         /**
       
   224         * Constructor.
       
   225         */
       
   226         CSenXmlProperties();
       
   227 
       
   228     protected:
       
   229         CSenPropertiesFragment*     ipFragment; // owned
       
   230         CSenXmlReader*              ipReader;   // owned
       
   231     };
       
   232 
       
   233 #endif // SEN_XML_PROPERTIES_H