83
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-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: Data buffer transaction element
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "databuffertransactionelement.h"
|
|
20 |
#include "aixmluiutils.h"
|
|
21 |
|
|
22 |
#include "xncomponent.h"
|
|
23 |
#include "xntype.h"
|
|
24 |
#include "xntext.h"
|
|
25 |
#include "xnnewsticker.h"
|
|
26 |
#include "xnmenuadapter.h"
|
|
27 |
#include "mxncomponentinterface.h"
|
|
28 |
#include "xnvolumecontrol.h"
|
|
29 |
#include "xnnodeappif.h"
|
|
30 |
#include "xnuiengineappif.h"
|
|
31 |
#include "xnproperty.h"
|
|
32 |
#include "xndompropertyvalue.h"
|
|
33 |
#include "aistrcnv.h"
|
|
34 |
#include "aixmluiconstants.h"
|
|
35 |
|
|
36 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
37 |
|
|
38 |
using namespace AiXmlUiController;
|
|
39 |
using namespace XnTextInterface;
|
|
40 |
|
|
41 |
CDataBufferTransactionElement::CDataBufferTransactionElement(AiUtility::CContentPriorityMap& aContentPriorityMap)
|
|
42 |
: CTransactionElement(aContentPriorityMap)
|
|
43 |
{
|
|
44 |
}
|
|
45 |
|
|
46 |
CDataBufferTransactionElement* CDataBufferTransactionElement::NewL(AiUtility::CContentPriorityMap& aContentPriorityMap)
|
|
47 |
{
|
|
48 |
CDataBufferTransactionElement* self = new( ELeave ) CDataBufferTransactionElement(aContentPriorityMap);
|
|
49 |
|
|
50 |
return self;
|
|
51 |
}
|
|
52 |
|
|
53 |
CDataBufferTransactionElement::~CDataBufferTransactionElement()
|
|
54 |
{
|
|
55 |
delete iNewData;
|
|
56 |
delete iCid;
|
|
57 |
}
|
|
58 |
|
|
59 |
void CDataBufferTransactionElement::InitializeL( CXnNodeAppIf& aTarget, const TDesC8& aData )
|
|
60 |
{
|
|
61 |
CheckTypeL( aTarget );
|
|
62 |
SetTarget( aTarget );
|
|
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();
|
|
81 |
}
|
|
82 |
|
|
83 |
void CDataBufferTransactionElement::UpdateDataL()
|
|
84 |
{
|
|
85 |
// Set new text
|
|
86 |
SetDataL();
|
|
87 |
|
|
88 |
// Update content priority
|
|
89 |
UpdateContentPriorityL();
|
|
90 |
}
|
|
91 |
|
|
92 |
void CDataBufferTransactionElement::Reset()
|
|
93 |
{
|
|
94 |
CTransactionElement::Reset();
|
|
95 |
|
|
96 |
delete iNewData;
|
|
97 |
iNewData = NULL;
|
|
98 |
|
|
99 |
delete iCid;
|
|
100 |
iCid = NULL;
|
|
101 |
|
|
102 |
iIndex = KErrNotFound;
|
|
103 |
}
|
|
104 |
|
|
105 |
TBool CDataBufferTransactionElement::IsSupported( CXnNodeAppIf& aTarget,
|
|
106 |
const TDesC8& aContentType )
|
|
107 |
{
|
|
108 |
// Get target type info
|
|
109 |
CXnType* typeInfo = aTarget.Type();
|
|
110 |
|
|
111 |
if ( !typeInfo )
|
|
112 |
{
|
|
113 |
return EFalse;
|
|
114 |
}
|
|
115 |
|
|
116 |
const TDesC8& type = typeInfo->Type();
|
|
117 |
|
|
118 |
if ( aContentType == KContentTypeText ) // Text
|
|
119 |
{
|
|
120 |
// Text element and menu item supports
|
|
121 |
return ( type == XnTextInterface::MXnTextInterface::Type() ||
|
|
122 |
type == KXnMenuItem ||
|
|
123 |
type == KXnMenu ||
|
|
124 |
type == XnPropertyNames::softkey::KNodeName ||
|
|
125 |
type == XnPropertyNames::volumecontrol::KSlider );
|
|
126 |
}
|
|
127 |
else if ( aContentType == KContentTypeImageSvg ) // SVG image
|
|
128 |
{
|
|
129 |
// Newsticker support
|
|
130 |
return ( type == XnNewstickerInterface::MXnNewstickerInterface::Type() );
|
|
131 |
}
|
|
132 |
else if ( aContentType == KContentTypeData )
|
|
133 |
{
|
|
134 |
return ( type == AiUiDef::xml::element::KData() );
|
|
135 |
}
|
|
136 |
|
|
137 |
return EFalse;
|
|
138 |
}
|
|
139 |
|
|
140 |
void CDataBufferTransactionElement::CheckTypeL( CXnNodeAppIf& aTarget )
|
|
141 |
{
|
|
142 |
// Get type info
|
|
143 |
const TDesC8& type = LeaveIfNull( aTarget.Type(), KErrNotSupported )->Type();
|
|
144 |
|
|
145 |
// Text element, menu item, data and newsticker supported
|
|
146 |
if ( type != XnTextInterface::MXnTextInterface::Type() &&
|
|
147 |
type != KXnMenuItem &&
|
|
148 |
type != KXnMenu &&
|
|
149 |
type != XnPropertyNames::softkey::KNodeName &&
|
|
150 |
type != XnPropertyNames::volumecontrol::KSlider &&
|
|
151 |
type != XnNewstickerInterface::MXnNewstickerInterface::Type() &&
|
|
152 |
type != AiUiDef::xml::element::KData() )
|
|
153 |
{
|
|
154 |
User::Leave( KErrNotSupported );
|
|
155 |
}
|
|
156 |
}
|
|
157 |
|
|
158 |
void CDataBufferTransactionElement::SetDataL()
|
|
159 |
{
|
|
160 |
// Get type info
|
|
161 |
const TDesC8& type = LeaveIfNull( Target().Type(), KErrNotSupported )->Type();
|
|
162 |
|
|
163 |
if ( type == XnTextInterface::MXnTextInterface::Type() ) // Text element
|
|
164 |
{
|
|
165 |
// Set character data directly to target
|
|
166 |
Target().SetPCDataL( iNewData ? *iNewData : KNullDesC8() );
|
|
167 |
}
|
|
168 |
else if ( type == XnPropertyNames::softkey::KNodeName ||
|
|
169 |
type == KXnMenuItem ||
|
|
170 |
type == KXnMenu ) // menu item
|
|
171 |
{
|
|
172 |
// Update label attribute value.
|
|
173 |
|
|
174 |
//
|
|
175 |
CXnNodeAppIf& target = Target();
|
|
176 |
|
|
177 |
// Create new new label attribute value
|
|
178 |
CXnDomPropertyValue* propertyValue =
|
|
179 |
CXnDomPropertyValue::NewL( &target.UiEngineL()->StringPool() );
|
|
180 |
|
|
181 |
CleanupStack::PushL( propertyValue );
|
|
182 |
|
|
183 |
propertyValue->SetStringValueL( CXnDomPropertyValue::EString,
|
|
184 |
iNewData ? *iNewData : KNullDesC8() );
|
|
185 |
|
|
186 |
CXnProperty* newProperty = CXnProperty::NewL( XnPropertyNames::menu::KLabel,
|
|
187 |
propertyValue,
|
|
188 |
target.UiEngineL()->StringPool() );
|
|
189 |
CleanupStack::Pop( propertyValue );
|
|
190 |
|
|
191 |
CleanupStack::PushL( newProperty );
|
|
192 |
|
|
193 |
// Set label attribute
|
|
194 |
target.SetPropertyL( newProperty );
|
|
195 |
|
|
196 |
CleanupStack::Pop( newProperty );
|
|
197 |
|
|
198 |
// Refresh menu
|
|
199 |
target.UiEngineL()->RefreshMenuL();
|
|
200 |
}
|
|
201 |
else if ( type == XnPropertyNames::volumecontrol::KSlider ) // slider
|
|
202 |
{
|
|
203 |
// Get volume control interface
|
|
204 |
XnVolumeControlInterface::MXnVolumeControlInterface* volumeControl = NULL;
|
|
205 |
XnComponentInterface::MakeInterfaceL( volumeControl, Target() );
|
|
206 |
LeaveIfNull( volumeControl, KErrNotSupported );
|
|
207 |
|
|
208 |
TInt32 volume = 0;
|
|
209 |
User::LeaveIfError( AiUtility::ParseInt( volume, iNewData ? *iNewData : KNullDesC8() ) );
|
|
210 |
volumeControl->SetValue( volume );
|
|
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 |
}
|
|
217 |
else
|
|
218 |
{
|
|
219 |
User::Leave( KErrNotSupported );
|
|
220 |
}
|
|
221 |
}
|
|
222 |
|
|
223 |
// End of File
|