|
1 /* |
|
2 * Copyright (c) 2006 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: Implementation of ReadRequestAO class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <mmfdatabuffer.h> |
|
20 #include "ReadWriteRequestAO.h" |
|
21 #include "CacheSource.h" |
|
22 |
|
23 CReadWriteRequestAO::CReadWriteRequestAO(CCacheSource& aSource,TRequestType aType ) |
|
24 : CActive(CActive::EPriorityStandard), |
|
25 iSource(aSource), |
|
26 iType(aType), |
|
27 iError(KErrNone) |
|
28 { |
|
29 CActiveScheduler::Add(this); |
|
30 } |
|
31 |
|
32 CReadWriteRequestAO::~CReadWriteRequestAO() |
|
33 { |
|
34 Cancel(); |
|
35 } |
|
36 |
|
37 CReadWriteRequestAO* CReadWriteRequestAO::NewL( CCacheSource& aSource,TRequestType aType ) |
|
38 { |
|
39 CReadWriteRequestAO* self = new (ELeave)CReadWriteRequestAO( aSource,aType ); |
|
40 CleanupStack::PushL( self ); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop( self ); |
|
43 return self; |
|
44 } |
|
45 |
|
46 void CReadWriteRequestAO::ConstructL() |
|
47 { |
|
48 } |
|
49 |
|
50 void CReadWriteRequestAO::SetActive() |
|
51 { |
|
52 if (!IsActive()) |
|
53 { |
|
54 CActive::SetActive(); |
|
55 } |
|
56 } |
|
57 |
|
58 TInt CReadWriteRequestAO::Error() |
|
59 { |
|
60 return iError; |
|
61 } |
|
62 |
|
63 // From CActive |
|
64 void CReadWriteRequestAO::RunL() |
|
65 { |
|
66 // Save the error code |
|
67 iError = iStatus.Int(); |
|
68 // Signal the observer that this request is serviced |
|
69 iSource.ReadRequestComplete(this,iStatus); |
|
70 } |
|
71 |
|
72 void CReadWriteRequestAO::DoCancel() |
|
73 { |
|
74 if(iStatus.Int() != KErrNone) |
|
75 { |
|
76 TRequestStatus* status = &iStatus; |
|
77 User::RequestComplete(status,KErrCancel); |
|
78 } |
|
79 } |
|
80 |
|
81 TInt CReadWriteRequestAO::RunError( TInt /*aError*/ ) |
|
82 { |
|
83 return KErrNone; |
|
84 } |
|
85 |
|
86 CMMFDataBuffer* CReadWriteRequestAO::Buffer() |
|
87 { |
|
88 return static_cast<CMMFDataBuffer*>(iBuffer); |
|
89 } |
|
90 |
|
91 TInt CReadWriteRequestAO::SetBuffer(CMMFBuffer* aBuffer) |
|
92 { |
|
93 iBuffer = aBuffer; |
|
94 return KErrNone; |
|
95 } |
|
96 |
|
97 CReadWriteRequestAO::TRequestType CReadWriteRequestAO::RequestType() |
|
98 { |
|
99 return iType; |
|
100 } |
|
101 |
|
102 // End of File |
|
103 |