|
1 /** @file |
|
2 * Copyright (c) 2005-2006 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: Attribute table data handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <xmlengdom.h> |
|
22 #include "upnpattributebean.h" |
|
23 #include "upnpcontentdirectoryglobals.h" |
|
24 #include <upnpattribute.h> |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CUpnpAttributeBean::CUpnpAttributeBean |
|
30 // C++ default constructor can NOT contain any code, that |
|
31 // might leave. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CUpnpAttributeBean::CUpnpAttributeBean() |
|
35 { |
|
36 } |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CUpnpAttributeBean::ConstructL |
|
39 // Symbian 2nd phase constructor can leave. |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 void CUpnpAttributeBean::ConstructL() |
|
43 { |
|
44 iAtrValue = KNullString8().AllocL(); |
|
45 } |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CUpnpAttributeBean::NewLC |
|
48 // Two-phased constructor. |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 CUpnpAttributeBean* CUpnpAttributeBean::NewLC() |
|
52 { |
|
53 CUpnpAttributeBean* self = new( ELeave ) CUpnpAttributeBean; |
|
54 CleanupStack::PushL( self ); |
|
55 self->ConstructL(); |
|
56 return self; |
|
57 } |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CUpnpAttributeBean::NewLC |
|
60 // Two-phased constructor. |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CUpnpAttributeBean* CUpnpAttributeBean::NewLC(const RDbRowSet& aRowSet) |
|
64 { |
|
65 CUpnpAttributeBean* self = NewLC(); |
|
66 self->SetL(aRowSet); |
|
67 return self; |
|
68 } |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CUpnpAttributeBean::~CUpnpAttributeBean |
|
71 // Destructor |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CUpnpAttributeBean::~CUpnpAttributeBean() |
|
75 { |
|
76 delete iAtrName; |
|
77 delete iAtrValue; |
|
78 } |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CUpnpAttributeBean::SetL |
|
81 // (other items were commented in a header). |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 void CUpnpAttributeBean::SetL(const RDbRowSet& aRowSet) |
|
85 { |
|
86 // get cols' ids |
|
87 CDbColSet* colSet = aRowSet.ColSetL(); |
|
88 CleanupStack::PushL(colSet); |
|
89 const TInt idColNo = colSet->ColNo(KAtrIdColName); |
|
90 const TInt nameColNo = colSet->ColNo(KAtrNameColName); |
|
91 const TInt elmIdColNo = colSet->ColNo(KAtrElmIdColName); |
|
92 const TInt isRequiredColNo = colSet->ColNo(KAtrIsRequiredColName); |
|
93 const TInt valueColNo = colSet->ColNo(KAtrValueColName); |
|
94 CleanupStack::PopAndDestroy(colSet); |
|
95 |
|
96 // for each column call setter |
|
97 if( idColNo != KDbNullColNo ) |
|
98 { |
|
99 SetAtrId( aRowSet.ColInt(idColNo) ); |
|
100 } |
|
101 if( nameColNo != KDbNullColNo ) |
|
102 { |
|
103 SetAtrNameL( aRowSet.ColDes8(nameColNo) ); |
|
104 } |
|
105 if( elmIdColNo != KDbNullColNo ) |
|
106 { |
|
107 SetAtrElmId( aRowSet.ColInt(elmIdColNo) ); |
|
108 } |
|
109 if( isRequiredColNo != KDbNullColNo ) |
|
110 { |
|
111 SetAtrIsRequired( aRowSet.ColUint8(isRequiredColNo) ); |
|
112 } |
|
113 if( valueColNo != KDbNullColNo ) |
|
114 { |
|
115 SetAtrValueL( aRowSet, valueColNo ); |
|
116 } |
|
117 } |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CUpnpAttributeBean::SetAtrValueL |
|
120 // (other items were commented in a header). |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 void CUpnpAttributeBean::SetAtrValueL(const RDbRowSet& aRowSet, const TInt aColNo) |
|
124 { |
|
125 delete iAtrValue; |
|
126 iAtrValue = 0; |
|
127 iAtrValue = ReadLongTextColL(aRowSet, aColNo); |
|
128 } |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CUpnpAttributeBean::SetAtrValueL |
|
131 // (other items were commented in a header). |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CUpnpAttributeBean::SetAtrValueL(const TDesC8& aVal) |
|
135 { |
|
136 delete iAtrValue; |
|
137 iAtrValue = 0; |
|
138 iAtrValue = aVal.AllocL(); |
|
139 } |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CUpnpAttributeBean::SetAtrNameL |
|
142 // (other items were commented in a header). |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 void CUpnpAttributeBean::SetAtrNameL(const TDesC8& aAtrName) |
|
146 { |
|
147 delete iAtrName; |
|
148 iAtrName = NULL; |
|
149 iAtrName = aAtrName.AllocL(); |
|
150 } |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CUpnpAttributeBean::AttachToXmlElL |
|
153 // (other items were commented in a header). |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 TXmlEngAttr CUpnpAttributeBean::AttachAttrL(TXmlEngElement aElement) |
|
157 { |
|
158 // add attribute |
|
159 TXmlEngAttr ret = aElement.AddNewAttributeL( AtrName(), AtrValue() ); |
|
160 |
|
161 return ret; |
|
162 } |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CUpnpAttributeBean::CopyToUpnpElementL |
|
165 // (other items were commented in a header). |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 void CUpnpAttributeBean::AttachAttrL(CUpnpElement* aElm) |
|
169 { |
|
170 // create element |
|
171 CUpnpAttribute* atr = CUpnpAttribute::NewLC(*iAtrName); |
|
172 |
|
173 // copy values |
|
174 atr->SetValueL(*iAtrValue); |
|
175 |
|
176 // attach |
|
177 aElm->AddAttributeL(atr); |
|
178 |
|
179 // clean up |
|
180 CleanupStack::Pop(atr); |
|
181 } |
|
182 |
|
183 // End of File |