|
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: Generates XML from an UPNP Item |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifndef C_UPNPITEMTOXML_H |
|
24 #define C_UPNPITEMTOXML_H |
|
25 |
|
26 // INCLUDES |
|
27 #include <e32base.h> |
|
28 #include <s32mem.h> |
|
29 |
|
30 // CONSTANTS |
|
31 // None |
|
32 |
|
33 // MACROS |
|
34 // None |
|
35 |
|
36 // FORWARD DECLARATIONS |
|
37 class CUpnpItem; |
|
38 |
|
39 /** |
|
40 * Converts an UPnP item to xml document |
|
41 * |
|
42 * @since Series 60 3.2 |
|
43 * @lib upnpxmlparser.lib |
|
44 */ |
|
45 NONSHARABLE_CLASS( CUpnpItemToXML ) : public CBase |
|
46 { |
|
47 public: // Constructors and destructor |
|
48 |
|
49 /** |
|
50 * Two-phased constructor. |
|
51 * |
|
52 * @param aItem |
|
53 * @return new instance |
|
54 */ |
|
55 static CUpnpItemToXML* NewL( const CUpnpItem& aItem ); |
|
56 |
|
57 /** |
|
58 * Two-phased constructor. |
|
59 * |
|
60 * @param aItem |
|
61 * @return new instance |
|
62 */ |
|
63 static CUpnpItemToXML* NewLC( const CUpnpItem& aItem ); |
|
64 |
|
65 /** |
|
66 * Destructor. |
|
67 */ |
|
68 virtual ~CUpnpItemToXML(); |
|
69 |
|
70 |
|
71 public: // Functions from CUPnPObject |
|
72 |
|
73 /** |
|
74 * Returns object's XML description |
|
75 * Leaves in case of errors. |
|
76 * @since Series 60 3.1 |
|
77 * @param none |
|
78 * @return HBufC8 pointer to buffer containing XML data |
|
79 */ |
|
80 HBufC8* AsXmlL( const TBool aIncludeChilds = ETrue ); |
|
81 |
|
82 /** |
|
83 * Returns object's XML description. This version of the method |
|
84 * is used to create the XML with empty <res> tag |
|
85 * Leaves in case of errors. |
|
86 * @since Series 60 3.1 |
|
87 * @param None |
|
88 * @return HBufC8 pointer to buffer containing XML data |
|
89 */ |
|
90 HBufC8* AsXmlEmptyL(); |
|
91 |
|
92 |
|
93 /** |
|
94 * CUpnpItemToXML::AsResultArgumentL |
|
95 * Returns object's XML description that is embedded inside a |
|
96 * DIDL-LITE tag. The <res> tag of xml description is empty. |
|
97 * The returned value is xml encoded can therefore be used |
|
98 * for example when creating a CreateObject action. |
|
99 * @since Series 60 3.1 |
|
100 * @param none |
|
101 * @return TDesC8& the date string |
|
102 */ |
|
103 HBufC8* AsResultArgumentL(); |
|
104 |
|
105 /** |
|
106 * Creates valid XML headers to source data. Do not decode the XML. |
|
107 * |
|
108 * @since Series 60 3.1 |
|
109 * @param TDesC8 reference to source data |
|
110 * @return HBufC8 buffer to valid XML |
|
111 */ |
|
112 HBufC8* CreateUnDecodedXmlL( const TDesC8& aData ); |
|
113 |
|
114 private: |
|
115 |
|
116 /** |
|
117 * Return value from an element |
|
118 * |
|
119 * @param aElemenName (const TDesC8&) name of the element |
|
120 * @return (const TDesC8&) value of the element |
|
121 */ |
|
122 const TDesC8& GetValueFromElement( |
|
123 const TDesC8& aElementName ); |
|
124 |
|
125 /** |
|
126 * Validates format of dc:date |
|
127 * |
|
128 * @param aDate dc:date string |
|
129 * @return ETrue if format of dc:date is valid |
|
130 */ |
|
131 TBool ValidateDateL( const TDesC8& aDate ); |
|
132 |
|
133 /** |
|
134 * Validates format of res@duration |
|
135 * |
|
136 * @param aDuration res@duration string |
|
137 * @return ETrue if format of res@duration is valid |
|
138 */ |
|
139 TBool ValidateDurationL( const TDesC8& aDuration ); |
|
140 |
|
141 /** |
|
142 * Parse to a delimeter |
|
143 * |
|
144 * @param aLexer lexer |
|
145 * @param aDelimeter delimeter character |
|
146 */ |
|
147 void ParseToDelimeter( TLex8& aLex, TChar aDelimeter ); |
|
148 |
|
149 private: |
|
150 |
|
151 /** |
|
152 * C++ default constructor. |
|
153 */ |
|
154 CUpnpItemToXML( const CUpnpItem& aItem ); |
|
155 |
|
156 /** |
|
157 * By default Symbian 2nd phase constructor is private. |
|
158 */ |
|
159 void ConstructL(); |
|
160 |
|
161 private: // Data |
|
162 |
|
163 CUpnpItem* iItem; // Not own |
|
164 }; |
|
165 |
|
166 #endif // C_UPNPITEMTOXML_H |
|
167 |
|
168 // End of File |