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