|
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: News ticker transaction element |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "newstickertransactionelement.h" |
|
20 #include "aixmluiutils.h" |
|
21 |
|
22 #include "xntype.h" |
|
23 #include "xnproperty.h" |
|
24 #include "xntext.h" |
|
25 #include "xnmenuadapter.h" |
|
26 #include "xnnewsticker.h" |
|
27 //#include <xnmarquee.h> |
|
28 #include "mxncomponentinterface.h" |
|
29 #include "xnnodeappif.h" |
|
30 #include "xnuiengineappif.h" |
|
31 #include "xnproperty.h" |
|
32 #include "xndompropertyvalue.h" |
|
33 #include "xnvolumecontrol.h" |
|
34 #include "aistrcnv.h" |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 using namespace AiXmlUiController; |
|
39 using namespace XnTextInterface; |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CNewsTickerTransactionElement::CNewsTickerTransactionElement(AiUtility::CContentPriorityMap& aContentPriorityMap) |
|
45 : CTransactionElement(aContentPriorityMap) |
|
46 { |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CNewsTickerTransactionElement* CNewsTickerTransactionElement::NewL(AiUtility::CContentPriorityMap& aContentPriorityMap) |
|
53 { |
|
54 CNewsTickerTransactionElement* self = new( ELeave ) CNewsTickerTransactionElement(aContentPriorityMap); |
|
55 |
|
56 return self; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CNewsTickerTransactionElement::~CNewsTickerTransactionElement() |
|
63 { |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void CNewsTickerTransactionElement::InitializeL( CXnNodeAppIf& aTarget, const TDesC& aText, TInt aIndex ) |
|
70 { |
|
71 CheckTypeL( aTarget ); |
|
72 SetTarget( aTarget ); |
|
73 iNewText.Set( aText ); |
|
74 iIndex = aIndex; |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 void CNewsTickerTransactionElement::UpdateDataL() |
|
81 { |
|
82 // Set new text |
|
83 SetTextL(); |
|
84 |
|
85 // Update content priority |
|
86 UpdateContentPriorityL(); |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CNewsTickerTransactionElement::Reset() |
|
93 { |
|
94 CTransactionElement::Reset(); |
|
95 |
|
96 iNewText.Set( KNullDesC ); |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 TBool CNewsTickerTransactionElement::IsSupported( CXnNodeAppIf& aTarget ) |
|
103 { |
|
104 // Is supported only if parent is <newsticker> |
|
105 CXnNodeAppIf* ntNode = NULL; |
|
106 |
|
107 TRAP_IGNORE( ntNode = aTarget.ParentL() ); |
|
108 |
|
109 if ( !ntNode ) |
|
110 { |
|
111 return EFalse; |
|
112 } |
|
113 |
|
114 CXnType* typeInfo = ntNode->Type(); |
|
115 |
|
116 if ( !typeInfo ) |
|
117 { |
|
118 return EFalse; |
|
119 } |
|
120 |
|
121 const TDesC8& type = typeInfo->Type(); |
|
122 |
|
123 // Text element, menu item, newsticker, and marquee supported |
|
124 return ( type == XnNewstickerInterface::MXnNewstickerInterface::Type() ); |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CNewsTickerTransactionElement::CheckTypeL( CXnNodeAppIf& aTarget ) |
|
131 { |
|
132 if ( !IsSupported( aTarget ) ) |
|
133 { |
|
134 User::Leave( KErrNotSupported ); |
|
135 } |
|
136 } |
|
137 // ----------------------------------------------------------------------------- |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 void CNewsTickerTransactionElement::SetTextL() |
|
141 { |
|
142 // Titles are published to <newsticker> children elements |
|
143 CXnNodeAppIf* ntNode = Target().ParentL(); |
|
144 LeaveIfNull( ntNode, KErrNotSupported ); |
|
145 |
|
146 // Get type info |
|
147 const TDesC8& type = LeaveIfNull( ntNode->Type(), KErrNotSupported )->Type(); |
|
148 if ( type == XnNewstickerInterface::MXnNewstickerInterface::Type() ) |
|
149 { |
|
150 // Get Newsticker control interface |
|
151 XnNewstickerInterface::MXnNewstickerInterface* newsTicker = NULL; |
|
152 |
|
153 XnComponentInterface::MakeInterfaceL( newsTicker, *ntNode ); |
|
154 LeaveIfNull( newsTicker, KErrNotSupported ); |
|
155 |
|
156 TInt titleIndexVal = -1; |
|
157 CXnProperty* titleIndex = Target().GetPropertyL( XnPropertyNames::title::KTitleIndex ); |
|
158 if ( titleIndex ) |
|
159 { |
|
160 TLex8 lex( titleIndex->StringValue() ); |
|
161 TInt err = lex.Val( titleIndexVal ); |
|
162 if ( err == KErrNone && titleIndexVal > -1 ) |
|
163 { |
|
164 newsTicker->UpdateTitleL( iNewText, titleIndexVal ); |
|
165 } |
|
166 } |
|
167 } |
|
168 else |
|
169 { |
|
170 User::Leave( KErrNotSupported ); |
|
171 } |
|
172 } |
|
173 |
|
174 // End of File |