|
1 /* |
|
2 * Copyright (c) 2008 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: Publisher data |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 |
|
20 // User includes |
|
21 #include <aifwpublisherinfo.h> |
|
22 #include "xnappuiadapter.h" |
|
23 #include "xnplugindata.h" |
|
24 |
|
25 #include "xnpublisherdata.h" |
|
26 |
|
27 // Constants |
|
28 enum TXnPublisherDataFlags |
|
29 { |
|
30 EIsVirgin, |
|
31 EIsStarted, |
|
32 EIsLoading, |
|
33 EIsFailed |
|
34 }; |
|
35 |
|
36 // ============================ LOCAL FUNCTIONS ================================ |
|
37 |
|
38 // ============================ MEMBER FUNCTIONS =============================== |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CXnPublisherData::NewL() |
|
41 // Two-phased constructor. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CXnPublisherData* CXnPublisherData::NewL( CXnPluginData& aOwner, |
|
45 CXnNode& aNode ) |
|
46 { |
|
47 CXnPublisherData* self = CXnPublisherData::NewLC( aOwner, aNode ); |
|
48 CleanupStack::Pop( self ); |
|
49 return self; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CXnPublisherData::NewLC() |
|
54 // Two-phased constructor. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CXnPublisherData* CXnPublisherData::NewLC( CXnPluginData& aOwner, |
|
58 CXnNode& aNode ) |
|
59 { |
|
60 CXnPublisherData* self = new ( ELeave ) CXnPublisherData( aOwner, aNode ); |
|
61 CleanupStack::PushL( self ); |
|
62 self->ConstructL(); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CXnPublisherData::~CXnPublisherData() |
|
68 // C++ default destructor. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CXnPublisherData::~CXnPublisherData() |
|
72 { |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CXnPublisherData::CXnPublisherData() |
|
77 // C++ default constructor. |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 CXnPublisherData::CXnPublisherData( CXnPluginData& aOwner, CXnNode& aNode ) |
|
81 : iOwner( aOwner ), iNode( aNode ) |
|
82 { |
|
83 iAppUi = static_cast< CXnAppUiAdapter* >( iAvkonAppUi ); |
|
84 |
|
85 iFlags.Set( EIsVirgin ); |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CXnPublisherData::ConstructL() |
|
90 // 2nd phase constructor. |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 void CXnPublisherData::ConstructL() |
|
94 { |
|
95 User::LeaveIfError( iAppUi->PublisherInfo( iNode, iInfo ) ); |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CXnPublisherData::operator==() |
|
100 // |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 TBool CXnPublisherData::operator==( CXnNode& aNode ) const |
|
104 { |
|
105 THsPublisherInfo info; |
|
106 |
|
107 TRAPD( err, iAppUi->PublisherInfo( aNode, info ) ); |
|
108 |
|
109 if ( !err ) |
|
110 { |
|
111 return iInfo == info; |
|
112 } |
|
113 |
|
114 return EFalse; |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CXnPublisherData::operator==() |
|
119 // |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 TBool CXnPublisherData::operator==( const THsPublisherInfo& aInfo ) const |
|
123 { |
|
124 return iInfo == aInfo; |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CXnPublisherData::Info() |
|
129 // |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 const THsPublisherInfo& CXnPublisherData::Info() const |
|
133 { |
|
134 return iInfo; |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CXnPublisherData::ContentSource() |
|
139 // |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 CXnNode* CXnPublisherData::ContentSource() const |
|
143 { |
|
144 return &iNode; |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CXnPublisherData::Load() |
|
149 // |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 void CXnPublisherData::Load( TInt aReason ) |
|
153 { |
|
154 if ( iFlags.IsSet( EIsFailed ) ) |
|
155 { |
|
156 return; |
|
157 } |
|
158 |
|
159 if ( aReason != EAiFwPluginStartup && iFlags.IsSet( EIsVirgin ) ) |
|
160 { |
|
161 aReason = EAiFwSystemStartup; |
|
162 } |
|
163 |
|
164 iFlags.Set( EIsLoading ); |
|
165 |
|
166 TAiFwCallback cb( NotifyLoaded, this ); |
|
167 TAiFwPublisherInfo publisher( iInfo, cb, aReason ); |
|
168 |
|
169 iAppUi->LoadPublisher( publisher ); |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CXnPublisherData::Load() |
|
174 // |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 void CXnPublisherData::Destroy( TInt aReason ) |
|
178 { |
|
179 if ( iFlags.IsSet( EIsFailed ) ) |
|
180 { |
|
181 return; |
|
182 } |
|
183 |
|
184 iFlags.Clear( EIsLoading ); |
|
185 |
|
186 TAiFwCallback cb( NotifyDestroyed, this ); |
|
187 TAiFwPublisherInfo publisher( iInfo, cb, aReason ); |
|
188 |
|
189 iAppUi->DestroyPublisher( publisher ); |
|
190 } |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CXnPublisherData::IsFailed() |
|
194 // |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 TBool CXnPublisherData::IsFailed() const |
|
198 { |
|
199 return iFlags.IsSet( EIsFailed ); |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CXnPublisherData::IsLoading() |
|
204 // |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 TBool CXnPublisherData::IsLoading() const |
|
208 { |
|
209 return iFlags.IsSet( EIsLoading ); |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CXnPublisherData::Owner() |
|
214 // |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 CXnPluginData* CXnPublisherData::Owner() const |
|
218 { |
|
219 return &iOwner; |
|
220 } |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CXnPublisherData::NotifyLoaded() |
|
224 // |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 /* static */ void CXnPublisherData::NotifyLoaded( TAny* aAny, TInt aResult ) |
|
228 { |
|
229 CXnPublisherData* self = static_cast< CXnPublisherData* >( aAny ); |
|
230 |
|
231 self->iFlags.Clear( EIsLoading ); |
|
232 |
|
233 if ( aResult == KErrCancel ) |
|
234 { |
|
235 // Loading canceled |
|
236 } |
|
237 else |
|
238 { |
|
239 // Loading complete |
|
240 if ( aResult == KErrNone || aResult == KErrAlreadyExists ) |
|
241 { |
|
242 self->iFlags.Set( EIsStarted ); |
|
243 self->iFlags.Clear( EIsVirgin ); |
|
244 } |
|
245 else |
|
246 { |
|
247 self->iFlags.Set( EIsFailed ); |
|
248 } |
|
249 } |
|
250 |
|
251 TRAP_IGNORE( self->iOwner.NotifyPublisherReadyL() ); |
|
252 } |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // CXnPublisherData::NotifyDestroyed() |
|
256 // |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 /* static */ void CXnPublisherData::NotifyDestroyed( TAny* /*aAny*/, |
|
260 TInt /*aResult*/ ) |
|
261 { |
|
262 } |
|
263 |
|
264 // End of file |