|
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: Transaction element for publishing empty content |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "xntype.h" |
|
20 #include "xnnewsticker.h" |
|
21 #include "xnbitmap.h" |
|
22 #include "xntext.h" |
|
23 #include "emptycontenttransactionelement.h" |
|
24 #include "aixmluiconstants.h" |
|
25 #include "aixmluiutils.h" |
|
26 |
|
27 using namespace AiXmlUiController; |
|
28 using namespace XnImageInterface; |
|
29 using namespace XnTextInterface; |
|
30 using namespace AiUiDef::xml; |
|
31 |
|
32 const TInt KControlIndexOffset = 1; |
|
33 |
|
34 // ======== MEMBER FUNCTIONS ======== |
|
35 |
|
36 CEmptyContentTransactionElement::CEmptyContentTransactionElement( |
|
37 AiUtility::CContentPriorityMap& aContentPriorityMap) |
|
38 : CTransactionElement( aContentPriorityMap ), |
|
39 iIndex( KErrNotFound ) |
|
40 { |
|
41 } |
|
42 |
|
43 CEmptyContentTransactionElement* CEmptyContentTransactionElement::NewL( |
|
44 AiUtility::CContentPriorityMap& aContentPriorityMap) |
|
45 { |
|
46 CEmptyContentTransactionElement* self = |
|
47 new( ELeave ) CEmptyContentTransactionElement( aContentPriorityMap ); |
|
48 return self; |
|
49 } |
|
50 |
|
51 CEmptyContentTransactionElement::~CEmptyContentTransactionElement() |
|
52 { |
|
53 } |
|
54 |
|
55 void CEmptyContentTransactionElement::InitializeL( CXnNodeAppIf& aTarget, TInt aIndex ) |
|
56 { |
|
57 SetTarget( aTarget ); |
|
58 |
|
59 // Indexes in XML theme run 1...n, but in control interface 0...n-1 |
|
60 iIndex = aIndex - KControlIndexOffset; |
|
61 } |
|
62 |
|
63 void CEmptyContentTransactionElement::Reset() |
|
64 { |
|
65 CTransactionElement::Reset(); |
|
66 iIndex = KErrNotFound; |
|
67 } |
|
68 |
|
69 void CEmptyContentTransactionElement::UpdateDataL() |
|
70 { |
|
71 CXnType* type = Target().Type(); |
|
72 |
|
73 if ( type->Type() == XnImageInterface::MXnImageInterface::Type() ) |
|
74 { |
|
75 MXnImageInterface* imageIntr = NULL; |
|
76 if ( !XnComponentInterface::MakeInterfaceL( imageIntr, Target() ) ) |
|
77 { |
|
78 User::Leave( KErrNotSupported ); |
|
79 } |
|
80 // Clears the bitmaps from component |
|
81 imageIntr->SetContentBitmaps( NULL, NULL ); |
|
82 } |
|
83 else if ( type->Type() == XnTextInterface::MXnTextInterface::Type() ) // text element |
|
84 { |
|
85 // Get control interface |
|
86 XnTextInterface::MXnTextInterface* textControl = NULL; |
|
87 XnComponentInterface::MakeInterfaceL( textControl, Target() ); |
|
88 LeaveIfNull( textControl, KErrNotSupported ); |
|
89 |
|
90 // Clears the text from component |
|
91 textControl->SetTextL( KNullDesC ); |
|
92 } |
|
93 else |
|
94 { |
|
95 CXnNodeAppIf* parent = Target().ParentL(); |
|
96 LeaveIfNull( parent, KErrNotSupported ); |
|
97 const TDesC8& type = LeaveIfNull( parent->Type(), KErrNotSupported )->Type(); |
|
98 |
|
99 if ( type == XnNewstickerInterface::MXnNewstickerInterface::Type() ) |
|
100 { |
|
101 XnNewstickerInterface::MXnNewstickerInterface* newsticker = NULL; |
|
102 XnComponentInterface::MakeInterfaceL( newsticker, *parent ); |
|
103 LeaveIfNull( newsticker, KErrGeneral ); |
|
104 TInt titleIndexVal = -1; |
|
105 CXnProperty* titleIndex = Target().GetPropertyL( XnPropertyNames::title::KTitleIndex ); |
|
106 if ( titleIndex ) |
|
107 { |
|
108 TLex8 lex( titleIndex->StringValue() ); |
|
109 TInt err = lex.Val( titleIndexVal ); |
|
110 if ( err == KErrNone && titleIndexVal > -1 ) |
|
111 { |
|
112 newsticker->DeleteTitle( titleIndexVal ); |
|
113 } |
|
114 } |
|
115 } |
|
116 } |
|
117 // Clear current content priority |
|
118 ClearContentPriorityL(); |
|
119 } |