|
1 /* |
|
2 * Copyright (c) 2002-2004 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 the License "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: Supports registration of UI Lib modules. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CDownloadMgrUiLibRegistry.h" |
|
22 #include "CDownloadMgrUiDownloadsList.h" |
|
23 #include "CDownloadMgrUiUserInteractions.h" |
|
24 #include "DMgrUiLibPanic.h" |
|
25 #include "UiLibLogger.h" |
|
26 |
|
27 /** |
|
28 * Extension class. |
|
29 * |
|
30 * This class also acts a common exit observer when UILib is used. It is used not only for |
|
31 * deciding if an embedded handler application is runnong or not, but also for indicating |
|
32 * if eg. a COD Service Flow is running. |
|
33 */ |
|
34 NONSHARABLE_CLASS( CUiLibRegistryExtension ) : public CBase |
|
35 { |
|
36 public: // Constructors and destructor |
|
37 |
|
38 /** |
|
39 * Two-phased constructor. |
|
40 */ |
|
41 static CUiLibRegistryExtension* NewL |
|
42 ( CDownloadMgrUiLibRegistry& aRegistry ); |
|
43 |
|
44 /** |
|
45 * Destructor. |
|
46 */ |
|
47 virtual ~CUiLibRegistryExtension(); |
|
48 |
|
49 protected: // Constructors |
|
50 |
|
51 /** |
|
52 * C++ default constructor. |
|
53 */ |
|
54 CUiLibRegistryExtension( CDownloadMgrUiLibRegistry& aRegistry ); |
|
55 |
|
56 /** |
|
57 * By default Symbian 2nd phase constructor is private. |
|
58 */ |
|
59 void ConstructL(); |
|
60 |
|
61 private: // Data |
|
62 |
|
63 CDownloadMgrUiLibRegistry& iRegistry; |
|
64 }; |
|
65 |
|
66 // ============================ MEMBER FUNCTIONS =============================== |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CUiLibRegistryExtension::CUiLibRegistryExtension |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CUiLibRegistryExtension::CUiLibRegistryExtension |
|
73 ( CDownloadMgrUiLibRegistry& aRegistry ) |
|
74 : iRegistry( aRegistry ) |
|
75 { |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CUiLibRegistryExtension::ConstructL |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void CUiLibRegistryExtension::ConstructL() |
|
83 { |
|
84 CLOG_ENTERFN("CUiLibRegistryExtension::ConstructL"); |
|
85 CLOG_LEAVEFN("CUiLibRegistryExtension::ConstructL"); |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CUiLibRegistryExtension::NewL |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 CUiLibRegistryExtension* CUiLibRegistryExtension::NewL |
|
93 ( CDownloadMgrUiLibRegistry& aRegistry ) |
|
94 { |
|
95 CUiLibRegistryExtension* self = |
|
96 new (ELeave) CUiLibRegistryExtension( aRegistry ); |
|
97 CleanupStack::PushL( self ); |
|
98 self->ConstructL(); |
|
99 CleanupStack::Pop(); |
|
100 return self; |
|
101 } |
|
102 |
|
103 // Destructor |
|
104 CUiLibRegistryExtension::~CUiLibRegistryExtension() |
|
105 { |
|
106 CLOG_ENTERFN("CUiLibRegistryExtension::~CUiLibRegistryExtension"); |
|
107 CLOG_LEAVEFN("CUiLibRegistryExtension::~CUiLibRegistryExtension"); |
|
108 } |
|
109 |
|
110 // ============================ MEMBER FUNCTIONS =============================== |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CDownloadMgrUiLibRegistry::CDownloadMgrUiLibRegistry |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 CDownloadMgrUiLibRegistry::CDownloadMgrUiLibRegistry( RHttpDownloadMgr& aDownloadMgr ) |
|
117 : iDownloadMgr( aDownloadMgr ) |
|
118 { |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CDownloadMgrUiLibRegistry::ConstructL |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 void CDownloadMgrUiLibRegistry::ConstructL() |
|
126 { |
|
127 // Create the log file |
|
128 LOG_CREATE; |
|
129 iExtension = CUiLibRegistryExtension::NewL( *this ); |
|
130 ////////////////////// |
|
131 // EDlMgrAppUid |
|
132 TInt32 appUid( 0 ); |
|
133 User::LeaveIfError( iDownloadMgr.GetIntAttribute( EDlMgrAppUid, appUid ) ); |
|
134 iClientAppUid = TUid::Uid( (TInt)appUid ); |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CDownloadMgrUiLibRegistry::NewL |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 EXPORT_C |
|
142 CDownloadMgrUiLibRegistry* CDownloadMgrUiLibRegistry::NewL( RHttpDownloadMgr& aDownloadMgr ) |
|
143 { |
|
144 CDownloadMgrUiLibRegistry* self = |
|
145 new ( ELeave ) CDownloadMgrUiLibRegistry( aDownloadMgr ); |
|
146 CleanupStack::PushL( self ); |
|
147 self->ConstructL(); |
|
148 CleanupStack::Pop(); |
|
149 return self; |
|
150 } |
|
151 |
|
152 // Destructor |
|
153 EXPORT_C |
|
154 CDownloadMgrUiLibRegistry::~CDownloadMgrUiLibRegistry() |
|
155 { |
|
156 CLOG_ENTERFN("CDownloadMgrUiLibRegistry::~CDownloadMgrUiLibRegistry"); |
|
157 RemoveUiComponentsAsObservers(); |
|
158 // |
|
159 delete iUserInteractions; |
|
160 iUserInteractions = 0; |
|
161 CLOG_WRITE("iUserInteractions deleted"); |
|
162 delete iDownloadsList; |
|
163 iDownloadsList = 0; |
|
164 CLOG_WRITE("iDownloadsList deleted"); |
|
165 delete iExtension; |
|
166 iExtension = 0; |
|
167 CLOG_LEAVEFN("CDownloadMgrUiLibRegistry::~CDownloadMgrUiLibRegistry"); |
|
168 } |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CDownloadMgrUiLibRegistry::RegisterUserInteractionsL |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 EXPORT_C |
|
175 CDownloadMgrUiUserInteractions& CDownloadMgrUiLibRegistry::RegisterUserInteractionsL() |
|
176 { |
|
177 CLOG_ENTERFN("CDownloadMgrUiLibRegistry::RegisterUserInteractionsL"); |
|
178 |
|
179 __ASSERT_ALWAYS( iUserInteractions == NULL, Panic( EUiLibPanNotNull ) ); |
|
180 |
|
181 iUserInteractions = CDownloadMgrUiUserInteractions::NewL( *this ); |
|
182 // Register UI component as observer if not done yet |
|
183 TRAPD( err, SetUiComponentsAsObserversL() ); |
|
184 if ( err ) |
|
185 { |
|
186 CLOG_WRITE_FORMAT(" err: %d", err); |
|
187 RemoveUiComponentsAsObservers(); |
|
188 User::Leave( err ); |
|
189 } |
|
190 |
|
191 CLOG_LEAVEFN("CDownloadMgrUiLibRegistry::RegisterUserInteractionsL"); |
|
192 return *iUserInteractions; |
|
193 } |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // CDownloadMgrUiLibRegistry::RegisterDownloadsListL |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 EXPORT_C |
|
200 CDownloadMgrUiDownloadsList& CDownloadMgrUiLibRegistry::RegisterDownloadsListL() |
|
201 { |
|
202 CLOG_ENTERFN("CDownloadMgrUiLibRegistry::RegisterDownloadsListL"); |
|
203 |
|
204 __ASSERT_ALWAYS( iDownloadsList == NULL, Panic( EUiLibPanNotNull ) ); |
|
205 |
|
206 iDownloadsList = CDownloadMgrUiDownloadsList::NewL( *this ); |
|
207 // Register UI component as observer if not done yet |
|
208 TRAPD( err, SetUiComponentsAsObserversL() ); |
|
209 if ( err ) |
|
210 { |
|
211 CLOG_WRITE_FORMAT(" err: %d", err); |
|
212 RemoveUiComponentsAsObservers(); |
|
213 User::Leave( err ); |
|
214 } |
|
215 |
|
216 CLOG_LEAVEFN("CDownloadMgrUiLibRegistry::RegisterDownloadsListL"); |
|
217 return *iDownloadsList; |
|
218 } |
|
219 |
|
220 // ----------------------------------------------------------------------------- |
|
221 // CDownloadMgrUiLibRegistry::ClientAppUid |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 TUid CDownloadMgrUiLibRegistry::ClientAppUid() const |
|
225 { |
|
226 CLOG_WRITE_FORMAT("iClientAppUid: %d", iClientAppUid); |
|
227 return (iClientAppUid); |
|
228 } |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // CDownloadMgrUiLibRegistry::DownloadsListInstalled |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 TBool CDownloadMgrUiLibRegistry::DownloadsListInstalled() const |
|
235 { |
|
236 CLOG_WRITE_FORMAT("DownloadsListInstalled: %x", iDownloadsList); |
|
237 return (iDownloadsList!=NULL); |
|
238 } |
|
239 |
|
240 // ----------------------------------------------------------------------------- |
|
241 // CDownloadMgrUiLibRegistry::DownloadsList |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 CDownloadMgrUiDownloadsList& CDownloadMgrUiLibRegistry::DownloadsList() const |
|
245 { |
|
246 __ASSERT_DEBUG( iDownloadsList, Panic( EUiLibPanNull ) ); |
|
247 return (*iDownloadsList); |
|
248 } |
|
249 |
|
250 // ----------------------------------------------------------------------------- |
|
251 // CDownloadMgrUiLibRegistry::UserInteractionsInstalled |
|
252 // ----------------------------------------------------------------------------- |
|
253 // |
|
254 TBool CDownloadMgrUiLibRegistry::UserInteractionsInstalled() const |
|
255 { |
|
256 CLOG_WRITE_FORMAT("UserInteractionsInstalled: %x", iUserInteractions); |
|
257 return (iUserInteractions!=NULL); |
|
258 } |
|
259 |
|
260 // ----------------------------------------------------------------------------- |
|
261 // CDownloadMgrUiLibRegistry::UserInteractions |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 CDownloadMgrUiUserInteractions& CDownloadMgrUiLibRegistry::UserInteractions() const |
|
265 { |
|
266 __ASSERT_DEBUG( iUserInteractions, Panic( EUiLibPanNull ) ); |
|
267 return (*iUserInteractions); |
|
268 } |
|
269 |
|
270 // ----------------------------------------------------------------------------- |
|
271 // CDownloadMgrUiLibRegistry::DownloadMgr |
|
272 // ----------------------------------------------------------------------------- |
|
273 // |
|
274 RHttpDownloadMgr& CDownloadMgrUiLibRegistry::DownloadMgr() const |
|
275 { |
|
276 CLOG_WRITE_FORMAT("DownloadMgr: %x", &iDownloadMgr); |
|
277 return (iDownloadMgr); |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // CDownloadMgrUiLibRegistry::DownloadCount |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 TInt CDownloadMgrUiLibRegistry::DownloadCount() const |
|
285 { |
|
286 return (iDownloadMgr.CurrentDownloads().Count()); |
|
287 } |
|
288 |
|
289 // ----------------------------------------------------------------------------- |
|
290 // CDownloadMgrUiLibRegistry::SetUiComponentsAsObserversL |
|
291 // ----------------------------------------------------------------------------- |
|
292 // |
|
293 void CDownloadMgrUiLibRegistry::SetUiComponentsAsObserversL() |
|
294 { |
|
295 if ( iUserInteractions ) |
|
296 { |
|
297 CLOG_WRITE(" AddObserverL iUserInteractions ..."); |
|
298 iDownloadMgr.AddObserverL( *iUserInteractions ); |
|
299 CLOG_WRITE(" AddObserverL iUserInteractions OK"); |
|
300 } |
|
301 if ( iDownloadsList ) |
|
302 { |
|
303 CLOG_WRITE(" AddObserverL iDownloadsList ..."); |
|
304 iDownloadMgr.AddObserverL( *iDownloadsList ); |
|
305 CLOG_WRITE(" AddObserverL iDownloadsList OK"); |
|
306 } |
|
307 } |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // CDownloadMgrUiLibRegistry::RemoveUiComponentsAsObservers |
|
311 // ----------------------------------------------------------------------------- |
|
312 // |
|
313 void CDownloadMgrUiLibRegistry::RemoveUiComponentsAsObservers() |
|
314 { |
|
315 if ( iUserInteractions ) |
|
316 { |
|
317 CLOG_WRITE(" RemoveObserver iUserInteractions ..."); |
|
318 iDownloadMgr.RemoveObserver( *iUserInteractions ); |
|
319 CLOG_WRITE(" RemoveObserver iUserInteractions OK"); |
|
320 } |
|
321 if ( iDownloadsList ) |
|
322 { |
|
323 CLOG_WRITE(" RemoveObserver iDownloadsList ..."); |
|
324 iDownloadMgr.RemoveObserver( *iDownloadsList ); |
|
325 CLOG_WRITE(" RemoveObserver iDownloadsList OK"); |
|
326 } |
|
327 } |
|
328 |
|
329 // End of file. |