|
1 /* |
|
2 * Copyright (c) 2002 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: Request used to write or read data |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <logger.h> |
|
21 #include "CMMAStreamRequest.h" |
|
22 #include "MMMAStreamRequestListener.h" |
|
23 |
|
24 CMMAStreamRequest* CMMAStreamRequest::NewLC(MMMAStreamRequestListener* aListener) |
|
25 { |
|
26 CMMAStreamRequest* self = new(ELeave)CMMAStreamRequest(aListener); |
|
27 CleanupStack::PushL(self); |
|
28 self->ConstructL(); |
|
29 return self; |
|
30 } |
|
31 |
|
32 CMMAStreamRequest::~CMMAStreamRequest() |
|
33 { |
|
34 Cancel(); |
|
35 delete iData; |
|
36 } |
|
37 |
|
38 TPtr8& CMMAStreamRequest::DataPtr() |
|
39 { |
|
40 return iDataPtr; |
|
41 } |
|
42 |
|
43 void CMMAStreamRequest::CompleteRead(TInt aError) |
|
44 { |
|
45 if (aError < KErrNone) |
|
46 { |
|
47 iListener->HandleError(this, aError); |
|
48 } |
|
49 else // OK |
|
50 { |
|
51 iListener->ReadComplete(this); |
|
52 } |
|
53 } |
|
54 |
|
55 void CMMAStreamRequest::SetActive() |
|
56 { |
|
57 CActive::SetActive(); |
|
58 } |
|
59 |
|
60 TPckgBuf< TInt >& CMMAStreamRequest::RequestBuffer() |
|
61 { |
|
62 return iRequestBuffer; |
|
63 } |
|
64 |
|
65 void CMMAStreamRequest::RunL() |
|
66 { |
|
67 if (iStatus.Int() == KErrNone) |
|
68 { |
|
69 // data is processed, set ready for reuse |
|
70 iDataPtr.SetLength(0); |
|
71 iListener->WriteComplete(this); |
|
72 } |
|
73 else // error |
|
74 { |
|
75 iListener->HandleError(this, iStatus.Int()); |
|
76 } |
|
77 } |
|
78 |
|
79 TInt CMMAStreamRequest::RunError(TInt aError) |
|
80 { |
|
81 iListener->HandleError(this, aError); |
|
82 return KErrNone; |
|
83 } |
|
84 |
|
85 void CMMAStreamRequest::DoCancel() |
|
86 { |
|
87 // Complete this request |
|
88 TRequestStatus* s = &iStatus; |
|
89 User::RequestComplete(s, KErrCancel); |
|
90 } |
|
91 |
|
92 CMMAStreamRequest::CMMAStreamRequest(MMMAStreamRequestListener* aListener): |
|
93 CActive(EPriorityStandard), |
|
94 iListener(aListener), |
|
95 iDataPtr(NULL, 0) |
|
96 { |
|
97 CActiveScheduler::Add(this); |
|
98 } |
|
99 |
|
100 void CMMAStreamRequest::ConstructL() |
|
101 { |
|
102 iData = HBufC8::NewL(KMMAStreamRequestBufferSize); |
|
103 iDataPtr.Set(iData->Des()); |
|
104 } |
|
105 |
|
106 // END OF FILE |