2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Xml properties class declaration
19 #ifndef SEN_XML_PROPERTIES_H
20 #define SEN_XML_PROPERTIES_H
23 #include <SenDomFragment.h>
24 #include <MSenProperties.h>
26 // FORWARD DECLARATIONS
29 class CSenPropertiesFragment;
32 _LIT8(KSenXmlPropertiesLocalname, "Properties");
33 _LIT8(KSenTypeAttributeName, "Type");
34 _LIT8(KSenOmittedAttributeName, "Omitted");
35 _LIT8(KSenOmittedTrueNoValue, "");
36 _LIT8(KSenPropertyTrue, "true");
37 _LIT8(KSenPropertyFalse, "false");
40 //_LIT8(KSenXmlPropertiesQualifiedname, "props:Properties);
41 //_LIT8(KSenXmlPropertiesNamespace, "urn:com.nokia.Sen.properties.1.0");
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
52 * Please bear in mind the following limitations:
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 (&, ', ", <, >)
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 (&, ', ", <, >)
71 class CSenXmlProperties : public CBase, public MSenProperties
77 * @return a pointer to new CSenXmlProperties class instance.
79 IMPORT_C static CSenXmlProperties* NewL();
82 * @return a pointer to new CSenXmlProperties class instance.
84 IMPORT_C static CSenXmlProperties* NewLC();
89 * @param aParser It is a XML reader
90 * @return a pointer to new CSenTransportProperties class instance.
92 IMPORT_C static CSenXmlProperties* NewL(const TDesC8& aXmlUtf8,
93 CSenXmlReader& aParser);
97 * @param aParser It is a XML reader
98 * @return a pointer to new CSenTransportProperties class instance.
100 IMPORT_C static CSenXmlProperties* NewLC(const TDesC8& aXmlUtf8,
101 CSenXmlReader& aParser);
106 * @return a pointer to new CSenXmlProperties class instance.
108 IMPORT_C static CSenXmlProperties* NewL(const CSenElement& aElement);
112 * @return a pointer to new CSenXmlProperties class instance.
114 IMPORT_C static CSenXmlProperties* NewLC(const CSenElement& aElement);
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);
125 virtual MSenProperties* Clone(TInt& aOkOrError) const;
126 virtual MSenProperties* CloneL() const;
129 * @see MSenProperties
131 * KErrSenInvalidCharacters if aName contains illegal characters.
132 * KErrSenZeroLengthDescriptor if aName is zero length.
134 virtual TInt SetPropertyL(const TDesC8& aName,
135 const TDesC8& aValue);
137 virtual TInt PropertyL(const TDesC8& aName, TPtrC8& aValue);
140 * @see MSenProperties
142 * KErrSenInvalidCharacters if aName contains illegal characters.
143 * KErrSenZeroLengthDescriptor if aName is zero length.
145 virtual TInt SetIntPropertyL(const TDesC8& aName,
148 virtual TInt IntPropertyL(const TDesC8& aName,
151 * @see MSenProperties
153 * KErrSenInvalidCharacters if aName contains illegal characters.
154 * KErrSenZeroLengthDescriptor if aName is zero length.
156 virtual TInt SetBoolPropertyL(const TDesC8& aName,
159 virtual TInt BoolPropertyL(const TDesC8& aName,
161 virtual TInt SetOmittedL(const TDesC8& aName, TBool aValue);
163 virtual TInt RemovePropertyL(const TDesC8& aName);
167 virtual ~CSenXmlProperties();
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.
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
184 virtual TInt SetPropertyL(const TDesC8& aName,
185 const TDesC8& aValue,
186 const TDesC8& aType);
189 * Gets the value of the property behind certain name.
191 * @param aName The name identifying this property.
192 * @param aValue A TPtrC8 reference to be filled in with the value of
194 * @param aType A TPtrC8 reference to be filled in with the type of
196 * @return KErrNone if no error, or some of the system wide
199 virtual TInt PropertyL(const TDesC8& aName,
203 protected: // base class functions
205 virtual void BaseConstructL(const TDesC8& aLocalname,
207 CSenXmlReader* aParser = NULL);
209 virtual void BaseConstructL(const TDesC8& aNamespace,
210 const TDesC8& aLocalname,
212 CSenXmlReader* aParser = NULL);
214 virtual void BaseConstructL(const TDesC8& aNamespace,
215 const TDesC8& aLocalname,
216 const TDesC8& aQualifiedName,
218 CSenXmlReader* aParser = NULL);
220 virtual void BaseConstructL(const CSenElement& aElement);
229 CSenPropertiesFragment* ipFragment; // owned
230 CSenXmlReader* ipReader; // owned
233 #endif // SEN_XML_PROPERTIES_H