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