|
1 /* |
|
2 * Copyright (c) 2007-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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "catalogsasyncmediator.h" |
|
20 #include "catalogsdebug.h" |
|
21 |
|
22 CCatalogsAsyncMediator::CCatalogsAsyncMediator( |
|
23 TRequestStatus& aStatus, |
|
24 TCallBack aCallback ) |
|
25 : CActive( EPriorityStandard ), |
|
26 iClientStatus( aStatus ), |
|
27 iCallback( aCallback ) |
|
28 { |
|
29 CActiveScheduler::Add( this ); |
|
30 aStatus = KRequestPending; |
|
31 } |
|
32 |
|
33 |
|
34 CCatalogsAsyncMediator::~CCatalogsAsyncMediator() |
|
35 { |
|
36 DLTRACEIN(("")); |
|
37 Cancel(); |
|
38 } |
|
39 |
|
40 void CCatalogsAsyncMediator::Activate() |
|
41 { |
|
42 DLTRACEIN(("")); |
|
43 SetActive(); |
|
44 } |
|
45 |
|
46 void CCatalogsAsyncMediator::RunL() |
|
47 { |
|
48 DLTRACEIN(("iStatus: %d, calling Callback", iStatus.Int() )) |
|
49 // CallBack may lead to deletion of this object so |
|
50 // we take local copies of the variables |
|
51 TRequestStatus* status = &iClientStatus; |
|
52 TInt ownError = iStatus.Int(); |
|
53 |
|
54 TInt err = iCallback.CallBack(); |
|
55 |
|
56 if ( err == KErrNone ) |
|
57 { |
|
58 err = ownError; |
|
59 } |
|
60 |
|
61 DLTRACE(("Complete client status: %x", status )); |
|
62 |
|
63 User::RequestComplete( status, ownError ); |
|
64 } |
|
65 |
|
66 |
|
67 void CCatalogsAsyncMediator::DoCancel() |
|
68 { |
|
69 DLTRACEIN(("")); |
|
70 // Please, don't cancel before the real request |
|
71 // has been completed |
|
72 } |
|
73 |
|
74 |
|
75 TInt CCatalogsAsyncMediator::RunError( TInt aError ) |
|
76 { |
|
77 DLTRACEIN(("aError: %d", aError)); |
|
78 return aError; |
|
79 } |