17 |
17 |
18 |
18 |
19 #include "databuffertransactionelement.h" |
19 #include "databuffertransactionelement.h" |
20 #include "aixmluiutils.h" |
20 #include "aixmluiutils.h" |
21 |
21 |
|
22 #include "xncomponent.h" |
22 #include "xntype.h" |
23 #include "xntype.h" |
23 #include "xntext.h" |
24 #include "xntext.h" |
24 #include "xnnewsticker.h" |
25 #include "xnnewsticker.h" |
25 #include "xnmenuadapter.h" |
26 #include "xnmenuadapter.h" |
26 #include "mxncomponentinterface.h" |
27 #include "mxncomponentinterface.h" |
49 return self; |
50 return self; |
50 } |
51 } |
51 |
52 |
52 CDataBufferTransactionElement::~CDataBufferTransactionElement() |
53 CDataBufferTransactionElement::~CDataBufferTransactionElement() |
53 { |
54 { |
|
55 delete iNewData; |
|
56 delete iCid; |
54 } |
57 } |
55 |
58 |
56 void CDataBufferTransactionElement::InitializeL( CXnNodeAppIf& aTarget, const TDesC8& aData ) |
59 void CDataBufferTransactionElement::InitializeL( CXnNodeAppIf& aTarget, const TDesC8& aData ) |
57 { |
60 { |
58 CheckTypeL( aTarget ); |
61 CheckTypeL( aTarget ); |
59 SetTarget( aTarget ); |
62 SetTarget( aTarget ); |
60 iNewData.Set( aData ); |
63 |
|
64 delete iNewData; |
|
65 iNewData = NULL; |
|
66 |
|
67 iNewData = aData.AllocL(); |
|
68 } |
|
69 |
|
70 void CDataBufferTransactionElement::InitializeL( CXnNodeAppIf& aTarget, const TDesC8& aData, |
|
71 const TDesC& aCid, TInt aIndex ) |
|
72 { |
|
73 InitializeL( aTarget, aData ); |
|
74 |
|
75 iIndex = aIndex; |
|
76 |
|
77 delete iCid; |
|
78 iCid = NULL; |
|
79 |
|
80 iCid = aCid.AllocL(); |
61 } |
81 } |
62 |
82 |
63 void CDataBufferTransactionElement::UpdateDataL() |
83 void CDataBufferTransactionElement::UpdateDataL() |
64 { |
84 { |
65 // Set new text |
85 // Set new text |
71 |
91 |
72 void CDataBufferTransactionElement::Reset() |
92 void CDataBufferTransactionElement::Reset() |
73 { |
93 { |
74 CTransactionElement::Reset(); |
94 CTransactionElement::Reset(); |
75 |
95 |
76 iNewData.Set( KNullDesC8); |
96 delete iNewData; |
|
97 iNewData = NULL; |
|
98 |
|
99 delete iCid; |
|
100 iCid = NULL; |
|
101 |
|
102 iIndex = KErrNotFound; |
77 } |
103 } |
78 |
104 |
79 TBool CDataBufferTransactionElement::IsSupported( CXnNodeAppIf& aTarget, |
105 TBool CDataBufferTransactionElement::IsSupported( CXnNodeAppIf& aTarget, |
80 const TDesC8& aContentType ) |
106 const TDesC8& aContentType ) |
81 { |
107 { |
101 else if ( aContentType == KContentTypeImageSvg ) // SVG image |
127 else if ( aContentType == KContentTypeImageSvg ) // SVG image |
102 { |
128 { |
103 // Newsticker support |
129 // Newsticker support |
104 return ( type == XnNewstickerInterface::MXnNewstickerInterface::Type() ); |
130 return ( type == XnNewstickerInterface::MXnNewstickerInterface::Type() ); |
105 } |
131 } |
|
132 else if ( aContentType == KContentTypeData ) |
|
133 { |
|
134 return ( type == AiUiDef::xml::element::KData() ); |
|
135 } |
106 |
136 |
107 return EFalse; |
137 return EFalse; |
108 } |
138 } |
109 |
139 |
110 void CDataBufferTransactionElement::CheckTypeL( CXnNodeAppIf& aTarget ) |
140 void CDataBufferTransactionElement::CheckTypeL( CXnNodeAppIf& aTarget ) |
111 { |
141 { |
112 // Get type info |
142 // Get type info |
113 const TDesC8& type = LeaveIfNull( aTarget.Type(), KErrNotSupported )->Type(); |
143 const TDesC8& type = LeaveIfNull( aTarget.Type(), KErrNotSupported )->Type(); |
114 |
144 |
115 // Text element, menu item, and newsticker supported |
145 // Text element, menu item, data and newsticker supported |
116 if ( type != XnTextInterface::MXnTextInterface::Type() && |
146 if ( type != XnTextInterface::MXnTextInterface::Type() && |
117 type != KXnMenuItem && |
147 type != KXnMenuItem && |
118 type != KXnMenu && |
148 type != KXnMenu && |
119 type != XnPropertyNames::softkey::KNodeName && |
149 type != XnPropertyNames::softkey::KNodeName && |
120 type != XnPropertyNames::volumecontrol::KSlider && |
150 type != XnPropertyNames::volumecontrol::KSlider && |
121 type != XnNewstickerInterface::MXnNewstickerInterface::Type() ) |
151 type != XnNewstickerInterface::MXnNewstickerInterface::Type() && |
|
152 type != AiUiDef::xml::element::KData() ) |
122 { |
153 { |
123 User::Leave( KErrNotSupported ); |
154 User::Leave( KErrNotSupported ); |
124 } |
155 } |
125 } |
156 } |
126 |
157 |
130 const TDesC8& type = LeaveIfNull( Target().Type(), KErrNotSupported )->Type(); |
161 const TDesC8& type = LeaveIfNull( Target().Type(), KErrNotSupported )->Type(); |
131 |
162 |
132 if ( type == XnTextInterface::MXnTextInterface::Type() ) // Text element |
163 if ( type == XnTextInterface::MXnTextInterface::Type() ) // Text element |
133 { |
164 { |
134 // Set character data directly to target |
165 // Set character data directly to target |
135 Target().SetPCDataL( iNewData ); |
166 Target().SetPCDataL( iNewData ? *iNewData : KNullDesC8() ); |
136 } |
167 } |
137 else if ( type == XnPropertyNames::softkey::KNodeName || |
168 else if ( type == XnPropertyNames::softkey::KNodeName || |
138 type == KXnMenuItem || |
169 type == KXnMenuItem || |
139 type == KXnMenu ) // menu item |
170 type == KXnMenu ) // menu item |
140 { |
171 { |
148 CXnDomPropertyValue::NewL( &target.UiEngineL()->StringPool() ); |
179 CXnDomPropertyValue::NewL( &target.UiEngineL()->StringPool() ); |
149 |
180 |
150 CleanupStack::PushL( propertyValue ); |
181 CleanupStack::PushL( propertyValue ); |
151 |
182 |
152 propertyValue->SetStringValueL( CXnDomPropertyValue::EString, |
183 propertyValue->SetStringValueL( CXnDomPropertyValue::EString, |
153 iNewData ); |
184 iNewData ? *iNewData : KNullDesC8() ); |
154 |
185 |
155 CXnProperty* newProperty = CXnProperty::NewL( XnPropertyNames::menu::KLabel, |
186 CXnProperty* newProperty = CXnProperty::NewL( XnPropertyNames::menu::KLabel, |
156 propertyValue, |
187 propertyValue, |
157 target.UiEngineL()->StringPool() ); |
188 target.UiEngineL()->StringPool() ); |
158 CleanupStack::Pop( propertyValue ); |
189 CleanupStack::Pop( propertyValue ); |
173 XnVolumeControlInterface::MXnVolumeControlInterface* volumeControl = NULL; |
204 XnVolumeControlInterface::MXnVolumeControlInterface* volumeControl = NULL; |
174 XnComponentInterface::MakeInterfaceL( volumeControl, Target() ); |
205 XnComponentInterface::MakeInterfaceL( volumeControl, Target() ); |
175 LeaveIfNull( volumeControl, KErrNotSupported ); |
206 LeaveIfNull( volumeControl, KErrNotSupported ); |
176 |
207 |
177 TInt32 volume = 0; |
208 TInt32 volume = 0; |
178 User::LeaveIfError( AiUtility::ParseInt( volume, iNewData ) ); |
209 User::LeaveIfError( AiUtility::ParseInt( volume, iNewData ? *iNewData : KNullDesC8() ) ); |
179 volumeControl->SetValue( volume ); |
210 volumeControl->SetValue( volume ); |
180 } |
211 } |
|
212 else if ( type == AiUiDef::xml::element::KData() ) |
|
213 { |
|
214 CXnComponent& component( Target().ParentL()->Component() ); |
|
215 component.SetDataL( iNewData ? *iNewData : KNullDesC8(), iCid ? *iCid : KNullDesC(), iIndex ); |
|
216 } |
181 else |
217 else |
182 { |
218 { |
183 User::Leave( KErrNotSupported ); |
219 User::Leave( KErrNotSupported ); |
184 } |
220 } |
185 } |
221 } |