|
1 /* |
|
2 * Copyright (c) 2008-2009 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: Blocking attribute retriever |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "glxattributeretriever.h" |
|
21 |
|
22 #include <aknWaitDialog.h> |
|
23 #include <avkon.rsg> |
|
24 #include <EIKENV.H> |
|
25 #include <aknutils.h> |
|
26 #include <bautils.h> |
|
27 #include <data_caging_path_literals.hrh> |
|
28 #include <stringloader.h> |
|
29 |
|
30 #include <mpxattributespecs.h> |
|
31 #include <mpxcollectionpath.h> |
|
32 |
|
33 #include <glxlog.h> |
|
34 #include <glxmedialist.h> |
|
35 #include <glxpanic.h> |
|
36 #include <glxuistd.h> |
|
37 #include <glxuiutilities.rsg> |
|
38 #include <mglxfetchcontext.h> |
|
39 #include <mglxmedialistobserver.h> |
|
40 #include <glxresourceutilities.h> |
|
41 |
|
42 |
|
43 |
|
44 /** |
|
45 * Observer that should be implemented by users of the |
|
46 * CGlxAttributeRetriever class to inform them when attribute retrieval is complete |
|
47 */ |
|
48 class MGlxAttributeRetrieverObserver |
|
49 { |
|
50 public: |
|
51 /** |
|
52 * Called when attribute retrieval is complete |
|
53 * @param aError symbian os error code. |
|
54 */ |
|
55 virtual void AttributeRetrievalCompleteL(TInt aError) = 0; |
|
56 }; |
|
57 |
|
58 /** |
|
59 * CGlxAttributeRetriever |
|
60 * This class informs the MGlxAttributeRetrieverObserver when all |
|
61 * requested metadata has been retrived. |
|
62 * @ingroup mlm_media_list_manager_design |
|
63 * @lib glxuiutlities.lib |
|
64 */ |
|
65 NONSHARABLE_CLASS( CGlxAttributeRetriever ) |
|
66 : public CActive, public MGlxMediaListObserver |
|
67 { |
|
68 public: |
|
69 /** |
|
70 * Constructor |
|
71 * @param aObserver observer to be informed when attribute retrieval is complete |
|
72 */ |
|
73 CGlxAttributeRetriever(MGlxAttributeRetrieverObserver& aObserver); |
|
74 |
|
75 /** |
|
76 * Destructor |
|
77 */ |
|
78 ~CGlxAttributeRetriever(); |
|
79 |
|
80 /** |
|
81 * Retrieve the attrubutes |
|
82 * @param aContext the fetch context containing the attribute to be retrieved |
|
83 * @param aList the medialist containing the item for which the attributes are retrieved |
|
84 * @return Error code |
|
85 */ |
|
86 void RetrieveL(const MGlxFetchContext* aContext, MGlxMediaList* aList); |
|
87 |
|
88 void CancelRetrieve(); |
|
89 |
|
90 private: // from CActive |
|
91 void RunL(); |
|
92 void DoCancel(); |
|
93 |
|
94 public: // From MGlxMediaListObserver |
|
95 void HandleAttributesAvailableL(TInt aItemIndex, const RArray<TMPXAttribute>& aAttributes, MGlxMediaList* aList); |
|
96 void HandleItemAddedL(TInt aStartIndex, TInt aEndIndex, MGlxMediaList* aList); |
|
97 void HandleItemRemovedL(TInt aStartIndex, TInt aEndIndex, MGlxMediaList* aList); |
|
98 void HandleItemModifiedL(const RArray<TInt>& aItemIndexes, MGlxMediaList* aList); |
|
99 void HandleFocusChangedL(NGlxListDefs::TFocusChangeType aType, TInt aNewIndex, TInt aOldIndex, MGlxMediaList* aList); |
|
100 void HandleMediaL(TInt aListIndex, MGlxMediaList* aList); |
|
101 void HandleItemSelectedL(TInt aIndex, TBool aSelected, MGlxMediaList* aList); |
|
102 void HandleMessageL(const CMPXMessage& aMessage, MGlxMediaList* aList); |
|
103 void HandlePopulatedL(MGlxMediaList* aList); |
|
104 void HandleError(TInt aError); |
|
105 |
|
106 private: |
|
107 /** |
|
108 * Asynchronously notifies the observer is attribute retrieval is complete |
|
109 */ |
|
110 void NotifyObserverIfCompleteL(); |
|
111 |
|
112 /** |
|
113 * Completes the active object causing a call from the |
|
114 * active scheduler to RunL() |
|
115 * @param aError error code passed to RunL() |
|
116 * (test in RunL using iStatus.Int()) |
|
117 */ |
|
118 void CompleteSelf(TInt aError); |
|
119 |
|
120 private: |
|
121 /// pointer to a Fetch Context associated with the desired attribute. Not owned |
|
122 const MGlxFetchContext* iContext; |
|
123 |
|
124 /// pointer to the Media List. Not owned |
|
125 MGlxMediaList* iList; |
|
126 |
|
127 /** |
|
128 * observer |
|
129 */ |
|
130 MGlxAttributeRetrieverObserver& iObserver; |
|
131 |
|
132 /** |
|
133 * Internal cache of objects still to retrieve |
|
134 */ |
|
135 TInt iRequestCount; |
|
136 }; |
|
137 |
|
138 /** |
|
139 * Abstract interface for a blocking attribute retriever |
|
140 */ |
|
141 class MGlxBlockingAttributeRetriever |
|
142 { |
|
143 public: |
|
144 /** |
|
145 * Retrieve the attrubutes (call blocks until attribute retrieval is complete) |
|
146 * @param aContext the fetch context containing the attribute to be retrieved |
|
147 * @param aList the medialist containing the item for which the attributes are retrieved |
|
148 * @return Error code |
|
149 */ |
|
150 virtual TInt RetrieveL(const MGlxFetchContext* aContext, MGlxMediaList* aList) = 0; |
|
151 virtual ~MGlxBlockingAttributeRetriever() {}; |
|
152 }; |
|
153 |
|
154 /** |
|
155 * This class displays a wait dialog and blocks until all requested metadata has been retrieved. |
|
156 */ |
|
157 class CGlxWaitDialogAttributeRetriever : public CBase, |
|
158 public MProgressDialogCallback, |
|
159 public MGlxBlockingAttributeRetriever, |
|
160 public MGlxAttributeRetrieverObserver |
|
161 { |
|
162 public: |
|
163 static CGlxWaitDialogAttributeRetriever* NewLC(); |
|
164 |
|
165 public: // from MGlxBlockingAttributeRetriever |
|
166 /** |
|
167 * See @ref MGlxBlockingAttributeRetriever::RetrieveL |
|
168 */ |
|
169 TInt RetrieveL(const MGlxFetchContext* aContext, MGlxMediaList* aList); |
|
170 |
|
171 private: // from MGlxAttributeRetrieverObserver |
|
172 /** |
|
173 * See @ref MGlxAttributeRetrieverObserver::AttributeRetrievalCompleteL |
|
174 */ |
|
175 void AttributeRetrievalCompleteL(TInt aError); |
|
176 |
|
177 public: // From MProgressDialogCallback |
|
178 void DialogDismissedL(TInt aButtonId); |
|
179 |
|
180 private: |
|
181 /** |
|
182 * Constructor |
|
183 */ |
|
184 CGlxWaitDialogAttributeRetriever(); |
|
185 |
|
186 /** |
|
187 * Destructor |
|
188 */ |
|
189 ~CGlxWaitDialogAttributeRetriever(); |
|
190 |
|
191 /** |
|
192 * Second stage constructor |
|
193 */ |
|
194 void ConstructL(); |
|
195 |
|
196 private: |
|
197 /** |
|
198 * Loads the resource file for this dll |
|
199 */ |
|
200 void AddResourceFileL(); |
|
201 |
|
202 /** |
|
203 * Unloads the resource file for this dll |
|
204 */ |
|
205 void RemoveResourceFile(); |
|
206 |
|
207 private: |
|
208 /// App environment used for accessing resource file (not owned) |
|
209 CCoeEnv* iCoeEnv; |
|
210 |
|
211 /// Wait dialog |
|
212 CAknWaitDialog* iWaitDialog; |
|
213 |
|
214 /// Resource file offset |
|
215 TInt iResourceOffset; |
|
216 |
|
217 /** |
|
218 * Attribute retriever (owned) |
|
219 */ |
|
220 CGlxAttributeRetriever* iAttributeRetriever; |
|
221 |
|
222 /** |
|
223 * Attribute retrieval error |
|
224 */ |
|
225 TInt iError; |
|
226 }; |
|
227 |
|
228 /** |
|
229 * This class blocks until all requested metadata has been retrieved |
|
230 */ |
|
231 class CGlxSynchronousAttributeRetriever : public CBase, |
|
232 public MGlxBlockingAttributeRetriever, |
|
233 public MGlxAttributeRetrieverObserver |
|
234 { |
|
235 public: |
|
236 static CGlxSynchronousAttributeRetriever* NewLC(); |
|
237 |
|
238 public: // from MGlxBlockingAttributeRetriever |
|
239 /** |
|
240 * See @ref MGlxBlockingAttributeRetriever::RetrieveL |
|
241 */ |
|
242 TInt RetrieveL(const MGlxFetchContext* aContext, MGlxMediaList* aList); |
|
243 |
|
244 private: // from MGlxAttributeRetrieverObserver |
|
245 /** |
|
246 * See @ref MGlxAttributeRetrieverObserver::AttributeRetrievalCompleteL |
|
247 */ |
|
248 void AttributeRetrievalCompleteL(TInt aError); |
|
249 |
|
250 private: |
|
251 /** |
|
252 * StopScheduler |
|
253 */ |
|
254 void StopScheduler(); |
|
255 |
|
256 private: |
|
257 /** |
|
258 * Second stage constructor |
|
259 */ |
|
260 void ConstructL(); |
|
261 |
|
262 /** |
|
263 * Destructor |
|
264 */ |
|
265 ~CGlxSynchronousAttributeRetriever(); |
|
266 |
|
267 private: |
|
268 /// Active scheduler wait object. Owned |
|
269 CActiveSchedulerWait* iSchedulerWait; |
|
270 |
|
271 /** |
|
272 * Attribute retriever (owned) |
|
273 */ |
|
274 CGlxAttributeRetriever* iAttributeRetriever; |
|
275 |
|
276 /** |
|
277 * Attribute retrieval error |
|
278 */ |
|
279 TInt iError; |
|
280 }; |
|
281 |
|
282 // ----------------------------------------------------------------------------- |
|
283 // RetrieveL |
|
284 // ----------------------------------------------------------------------------- |
|
285 // |
|
286 EXPORT_C TInt GlxAttributeRetriever::RetrieveL(const MGlxFetchContext& aContext, |
|
287 MGlxMediaList& aList, TBool aShowDialog) |
|
288 { |
|
289 MGlxBlockingAttributeRetriever* retriever = NULL; |
|
290 if (aShowDialog) |
|
291 { |
|
292 retriever = CGlxWaitDialogAttributeRetriever::NewLC(); |
|
293 } |
|
294 else |
|
295 { |
|
296 retriever = CGlxSynchronousAttributeRetriever::NewLC(); |
|
297 } |
|
298 TInt err = retriever->RetrieveL(&aContext, &aList); |
|
299 /** |
|
300 * This will cause a code scanner warning, but it is not possible to do |
|
301 * CleanupStack::PopAndDestroy(retriever) because the pointer pushed |
|
302 * onto the cleanup stack was either of class CGlxWaitDialogAttributeRetriever |
|
303 * or a CGlxSynchronousAttributeRetriever and the object 'retriever' is of |
|
304 * class MGlxBlockingAttributeRetriever |
|
305 */ |
|
306 CleanupStack::PopAndDestroy(); |
|
307 return err; |
|
308 } |
|
309 |
|
310 // ----------------------------------------------------------------------------- |
|
311 // Constructor |
|
312 // ----------------------------------------------------------------------------- |
|
313 // |
|
314 CGlxAttributeRetriever::CGlxAttributeRetriever(MGlxAttributeRetrieverObserver& aObserver) |
|
315 : CActive(EPriorityHigh), iObserver(aObserver) // We want out RunL to be serviced ASAP |
|
316 { |
|
317 CActiveScheduler::Add(this); |
|
318 } |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // Destructor |
|
322 // ----------------------------------------------------------------------------- |
|
323 // |
|
324 CGlxAttributeRetriever::~CGlxAttributeRetriever() |
|
325 { |
|
326 Cancel(); |
|
327 |
|
328 if ( iList ) |
|
329 { |
|
330 iList->RemoveMediaListObserver( this ); |
|
331 } |
|
332 } |
|
333 |
|
334 |
|
335 // ----------------------------------------------------------------------------- |
|
336 // CGlxAttributeRetriever::RetrieveL |
|
337 // ----------------------------------------------------------------------------- |
|
338 // |
|
339 void CGlxAttributeRetriever::RetrieveL(const MGlxFetchContext* aContext, MGlxMediaList* aList) |
|
340 { |
|
341 iContext = aContext; |
|
342 iList = aList; |
|
343 iList->AddMediaListObserverL(this); |
|
344 |
|
345 if(iList->IsPopulated()) |
|
346 { |
|
347 NotifyObserverIfCompleteL(); |
|
348 } |
|
349 } |
|
350 |
|
351 void CGlxAttributeRetriever::CancelRetrieve() |
|
352 { |
|
353 // Simply remove media list observer to prevent call backs from the media list |
|
354 iList->RemoveMediaListObserver(this); |
|
355 } |
|
356 |
|
357 // ----------------------------------------------------------------------------- |
|
358 // CGlxAttributeRetriever::RunL |
|
359 // ----------------------------------------------------------------------------- |
|
360 // |
|
361 void CGlxAttributeRetriever::RunL() |
|
362 { |
|
363 iObserver.AttributeRetrievalCompleteL(iStatus.Int()); |
|
364 } |
|
365 |
|
366 // ----------------------------------------------------------------------------- |
|
367 // CGlxAttributeRetriever::DoCancel |
|
368 // ----------------------------------------------------------------------------- |
|
369 // |
|
370 void CGlxAttributeRetriever::DoCancel() |
|
371 { |
|
372 // No need to do anything |
|
373 } |
|
374 |
|
375 // ----------------------------------------------------------------------------- |
|
376 // CGlxAttributeRetriever::NotifyObserverIfCompleteL() |
|
377 // ----------------------------------------------------------------------------- |
|
378 // |
|
379 void CGlxAttributeRetriever::NotifyObserverIfCompleteL() |
|
380 { |
|
381 iRequestCount--; |
|
382 |
|
383 if( iRequestCount <= 0 ) |
|
384 { |
|
385 iRequestCount = iContext->RequestCountL(iList); |
|
386 if(iRequestCount <= 0) |
|
387 { |
|
388 iList->RemoveMediaListObserver(this); // prevent any more callbacks from the media list |
|
389 CompleteSelf(iRequestCount); // request count is an error |
|
390 } |
|
391 } |
|
392 } |
|
393 |
|
394 // --------------------------------------------------------------------------- |
|
395 // CGlxDataSource::CompleteSelf |
|
396 // --------------------------------------------------------------------------- |
|
397 // |
|
398 void CGlxAttributeRetriever::CompleteSelf(TInt aError) |
|
399 { |
|
400 TRequestStatus* status=&iStatus; |
|
401 User::RequestComplete(status, aError); |
|
402 SetActive(); |
|
403 } |
|
404 |
|
405 // ----------------------------------------------------------------------------- |
|
406 // HandleAttributesAvailableL |
|
407 // ----------------------------------------------------------------------------- |
|
408 // |
|
409 void CGlxAttributeRetriever::HandleAttributesAvailableL(TInt /* aItemIndex */, |
|
410 const RArray<TMPXAttribute>& /* aAttributes */, MGlxMediaList* /*aList*/) |
|
411 { |
|
412 NotifyObserverIfCompleteL(); |
|
413 } |
|
414 |
|
415 // ----------------------------------------------------------------------------- |
|
416 // HandleItemAddedL |
|
417 // ----------------------------------------------------------------------------- |
|
418 // |
|
419 void CGlxAttributeRetriever::HandleItemAddedL(TInt /* aStartIndex */, |
|
420 TInt /* aEndIndex */, MGlxMediaList* /* aList */) |
|
421 { |
|
422 // No implementaion |
|
423 } |
|
424 |
|
425 // ----------------------------------------------------------------------------- |
|
426 // HandleItemRemovedL |
|
427 // ----------------------------------------------------------------------------- |
|
428 // |
|
429 void CGlxAttributeRetriever::HandleItemRemovedL(TInt /* aStartIndex */, |
|
430 TInt /* aEndIndex */, MGlxMediaList* /* aList */) |
|
431 { |
|
432 // No implementaion |
|
433 } |
|
434 |
|
435 // ----------------------------------------------------------------------------- |
|
436 // HandleItemModifiedL |
|
437 // ----------------------------------------------------------------------------- |
|
438 // |
|
439 void CGlxAttributeRetriever::HandleItemModifiedL(const RArray<TInt>& /* aItemIndexes */, |
|
440 MGlxMediaList* /* aList */) |
|
441 { |
|
442 // No implementaion |
|
443 } |
|
444 |
|
445 // ----------------------------------------------------------------------------- |
|
446 // HandleFocusChangedL |
|
447 // ----------------------------------------------------------------------------- |
|
448 // |
|
449 void CGlxAttributeRetriever::HandleFocusChangedL(NGlxListDefs::TFocusChangeType /* aType */, |
|
450 TInt /* aNewIndex */, TInt /* aOldIndex */, MGlxMediaList* /* aList */) |
|
451 { |
|
452 // No implementaion |
|
453 } |
|
454 |
|
455 // ----------------------------------------------------------------------------- |
|
456 // HandleMediaL |
|
457 // ----------------------------------------------------------------------------- |
|
458 // |
|
459 void CGlxAttributeRetriever::HandleMediaL(TInt /* aListIndex */, |
|
460 MGlxMediaList* /* aList */) |
|
461 { |
|
462 // No implementaion |
|
463 } |
|
464 |
|
465 // ----------------------------------------------------------------------------- |
|
466 // HandleItemSelectedL |
|
467 // ----------------------------------------------------------------------------- |
|
468 // |
|
469 void CGlxAttributeRetriever::HandleItemSelectedL(TInt /* aIndex */, |
|
470 TBool /* aSelected */, MGlxMediaList* /* aList */) |
|
471 { |
|
472 // No implementaion |
|
473 } |
|
474 |
|
475 // ----------------------------------------------------------------------------- |
|
476 // HandleMessageL |
|
477 // ----------------------------------------------------------------------------- |
|
478 // |
|
479 void CGlxAttributeRetriever::HandleMessageL(const CMPXMessage& /* aMessage */, |
|
480 MGlxMediaList* /* aList */) |
|
481 { |
|
482 // No implementaion |
|
483 } |
|
484 |
|
485 // ----------------------------------------------------------------------------- |
|
486 // HandleError |
|
487 // ----------------------------------------------------------------------------- |
|
488 // |
|
489 void CGlxAttributeRetriever::HandleError(TInt /* aError */) |
|
490 { |
|
491 // An error has been reported. But is it ours? |
|
492 // If the request is not complete then the error is not ours |
|
493 iRequestCount = 0; |
|
494 TRAP_IGNORE(NotifyObserverIfCompleteL()); |
|
495 |
|
496 } |
|
497 |
|
498 // ----------------------------------------------------------------------------- |
|
499 // HandlePopulatedL |
|
500 // ----------------------------------------------------------------------------- |
|
501 // |
|
502 void CGlxAttributeRetriever::HandlePopulatedL(MGlxMediaList* /*aList*/) |
|
503 { |
|
504 // If the media list is empty we will never get the HandleAttributesAvailableL callback, |
|
505 // therefore the call to NotifyObserversIfCompleteL below is necessary. |
|
506 NotifyObserverIfCompleteL(); |
|
507 } |
|
508 |
|
509 // ----------------------------------------------------------------------------- |
|
510 // CGlxWaitDialogAttributeRetriever |
|
511 // ----------------------------------------------------------------------------- |
|
512 // |
|
513 |
|
514 // ----------------------------------------------------------------------------- |
|
515 // CGlxWaitDialogAttributeRetriever::NewLC |
|
516 // ----------------------------------------------------------------------------- |
|
517 // |
|
518 CGlxWaitDialogAttributeRetriever* CGlxWaitDialogAttributeRetriever::NewLC() |
|
519 { |
|
520 CGlxWaitDialogAttributeRetriever* self = new (ELeave) CGlxWaitDialogAttributeRetriever(); |
|
521 CleanupStack::PushL(self); |
|
522 self->ConstructL(); |
|
523 return self; |
|
524 } |
|
525 |
|
526 // ----------------------------------------------------------------------------- |
|
527 // CGlxWaitDialogAttributeRetriever::RetrieveL |
|
528 // ----------------------------------------------------------------------------- |
|
529 // |
|
530 TInt CGlxWaitDialogAttributeRetriever::RetrieveL(const MGlxFetchContext* aContext, MGlxMediaList* aList) |
|
531 { |
|
532 // Load the resource file for this dll containing the wait dialog |
|
533 AddResourceFileL(); |
|
534 |
|
535 // prepare the wait dialog |
|
536 iWaitDialog = new( ELeave ) CAknWaitDialog(reinterpret_cast<CEikDialog**>(&iWaitDialog)); |
|
537 iWaitDialog->PrepareLC(R_GLX_WAIT_NOTE_BLOCKING); // Pushes a point to a CEikDialog onto the CleanupStack. RunLD Pops it. |
|
538 |
|
539 iWaitDialog->SetCallback(this); |
|
540 |
|
541 // Load string for dialog |
|
542 HBufC* title = StringLoader::LoadLC( R_GLX_PROGRESS_GENERAL ); |
|
543 iWaitDialog->SetTextL(*title); |
|
544 CleanupStack::PopAndDestroy(title); |
|
545 |
|
546 // The cancel key is specified in the resource |
|
547 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
548 cba->AddCommandSetToStackL(R_AVKON_SOFTKEYS_CANCEL); |
|
549 |
|
550 iAttributeRetriever->RetrieveL(aContext, aList); |
|
551 iWaitDialog->RunLD(); // starts another active scheduler and blocks |
|
552 return iError; |
|
553 } |
|
554 |
|
555 // ----------------------------------------------------------------------------- |
|
556 // CGlxWaitDialogAttributeRetriever::AttributeRetrievalComplete |
|
557 // ----------------------------------------------------------------------------- |
|
558 // |
|
559 void CGlxWaitDialogAttributeRetriever::AttributeRetrievalCompleteL(TInt aError) |
|
560 { |
|
561 iError = aError; |
|
562 iWaitDialog->ProcessFinishedL(); |
|
563 } |
|
564 |
|
565 // ----------------------------------------------------------------------------- |
|
566 // CGlxWaitDialogAttributeRetriever::DialogDismissedL |
|
567 // ----------------------------------------------------------------------------- |
|
568 // |
|
569 void CGlxWaitDialogAttributeRetriever::DialogDismissedL(TInt aButtonId) |
|
570 { |
|
571 if (aButtonId == EEikBidCancel) |
|
572 { |
|
573 iAttributeRetriever->CancelRetrieve(); |
|
574 iError = KErrCancel; |
|
575 } |
|
576 } |
|
577 |
|
578 // ----------------------------------------------------------------------------- |
|
579 // Constructor |
|
580 // ----------------------------------------------------------------------------- |
|
581 // |
|
582 CGlxWaitDialogAttributeRetriever::CGlxWaitDialogAttributeRetriever() |
|
583 { |
|
584 iCoeEnv = CCoeEnv::Static(); |
|
585 } |
|
586 |
|
587 // ----------------------------------------------------------------------------- |
|
588 // Destructor |
|
589 // ----------------------------------------------------------------------------- |
|
590 // |
|
591 CGlxWaitDialogAttributeRetriever::~CGlxWaitDialogAttributeRetriever() |
|
592 { |
|
593 RemoveResourceFile(); |
|
594 delete iAttributeRetriever; |
|
595 } |
|
596 |
|
597 // ----------------------------------------------------------------------------- |
|
598 // CGlxWaitDialogAttributeRetriever::ConstructL |
|
599 // ----------------------------------------------------------------------------- |
|
600 // |
|
601 void CGlxWaitDialogAttributeRetriever::ConstructL() |
|
602 { |
|
603 iAttributeRetriever = new (ELeave) CGlxAttributeRetriever(*this); |
|
604 } |
|
605 |
|
606 // ----------------------------------------------------------------------------- |
|
607 // AddResourceFileL |
|
608 // ----------------------------------------------------------------------------- |
|
609 // |
|
610 void CGlxWaitDialogAttributeRetriever::AddResourceFileL() |
|
611 { |
|
612 if (!iResourceOffset) // Lazy construction - ensure that this is only run once |
|
613 { |
|
614 GLX_LOG_INFO("Adding attribute retriever resource file"); |
|
615 TParse parse; |
|
616 parse.Set(KGlxUiUtilitiesResource, &KDC_APP_RESOURCE_DIR, NULL); |
|
617 TFileName resourceFile; |
|
618 resourceFile.Append(parse.FullName()); |
|
619 CGlxResourceUtilities::GetResourceFilenameL(resourceFile); |
|
620 iResourceOffset = iCoeEnv->AddResourceFileL(resourceFile); |
|
621 } |
|
622 } |
|
623 |
|
624 // ----------------------------------------------------------------------------- |
|
625 // RemoveResourceFile |
|
626 // ----------------------------------------------------------------------------- |
|
627 // |
|
628 void CGlxWaitDialogAttributeRetriever::RemoveResourceFile() |
|
629 { |
|
630 if (iResourceOffset) // Check that the resource has been loaded |
|
631 { |
|
632 GLX_LOG_INFO("Removing attribute retriever resource file"); |
|
633 iCoeEnv->DeleteResourceFile( iResourceOffset ); |
|
634 iResourceOffset = 0; |
|
635 } |
|
636 } |
|
637 |
|
638 // ----------------------------------------------------------------------------- |
|
639 // CGlxSynchronousAttributeRetriever |
|
640 // ----------------------------------------------------------------------------- |
|
641 // |
|
642 |
|
643 // ----------------------------------------------------------------------------- |
|
644 // CGlxSynchronousAttributeRetriever::NewLC |
|
645 // ----------------------------------------------------------------------------- |
|
646 // |
|
647 CGlxSynchronousAttributeRetriever* CGlxSynchronousAttributeRetriever::NewLC() |
|
648 { |
|
649 CGlxSynchronousAttributeRetriever* self = new (ELeave) CGlxSynchronousAttributeRetriever(); |
|
650 CleanupStack::PushL(self); |
|
651 self->ConstructL(); |
|
652 return self; |
|
653 } |
|
654 |
|
655 |
|
656 // ----------------------------------------------------------------------------- |
|
657 // CGlxSynchronousAttributeRetriever::RetrieveL |
|
658 // ----------------------------------------------------------------------------- |
|
659 // |
|
660 TInt CGlxSynchronousAttributeRetriever::RetrieveL(const MGlxFetchContext* aContext, MGlxMediaList* aList) |
|
661 { |
|
662 iAttributeRetriever->RetrieveL(aContext,aList); |
|
663 iSchedulerWait->Start(); |
|
664 return iError; |
|
665 } |
|
666 |
|
667 // ----------------------------------------------------------------------------- |
|
668 // CGlxSynchronousAttributeRetriever::AttributeRetrievalCompleteL |
|
669 // ----------------------------------------------------------------------------- |
|
670 // |
|
671 void CGlxSynchronousAttributeRetriever::AttributeRetrievalCompleteL(TInt aError) |
|
672 { |
|
673 iError = aError; |
|
674 StopScheduler(); |
|
675 } |
|
676 |
|
677 // ----------------------------------------------------------------------------- |
|
678 // StopScheduler |
|
679 // ----------------------------------------------------------------------------- |
|
680 // |
|
681 void CGlxSynchronousAttributeRetriever::StopScheduler() |
|
682 { |
|
683 if (iSchedulerWait) |
|
684 { |
|
685 if (iSchedulerWait->IsStarted()) |
|
686 { |
|
687 iSchedulerWait->AsyncStop(); |
|
688 } |
|
689 } |
|
690 } |
|
691 |
|
692 // ----------------------------------------------------------------------------- |
|
693 // CGlxSynchronousAttributeRetriever::ConstructL |
|
694 // ----------------------------------------------------------------------------- |
|
695 // |
|
696 void CGlxSynchronousAttributeRetriever::ConstructL() |
|
697 { |
|
698 iSchedulerWait = new (ELeave) CActiveSchedulerWait(); |
|
699 iAttributeRetriever = new (ELeave) CGlxAttributeRetriever(*this); |
|
700 } |
|
701 |
|
702 // ----------------------------------------------------------------------------- |
|
703 // Destructor |
|
704 // ----------------------------------------------------------------------------- |
|
705 // |
|
706 CGlxSynchronousAttributeRetriever::~CGlxSynchronousAttributeRetriever() |
|
707 { |
|
708 delete iSchedulerWait; |
|
709 delete iAttributeRetriever; |
|
710 } |