|
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 LOG( EJavaMMAPI, EInfo, "MMA::CMMAStreamRequest::NewLC +"); |
|
27 CMMAStreamRequest* self = new(ELeave)CMMAStreamRequest(aListener); |
|
28 CleanupStack::PushL(self); |
|
29 self->ConstructL(); |
|
30 LOG( EJavaMMAPI, EInfo, "MMA::CMMAStreamRequest::NewLC -"); |
|
31 return self; |
|
32 } |
|
33 |
|
34 CMMAStreamRequest::~CMMAStreamRequest() |
|
35 { |
|
36 LOG( EJavaMMAPI, EInfo, "MMA::CMMAStreamRequest::~CMMAStreamRequest +"); |
|
37 delete iData; |
|
38 LOG( EJavaMMAPI, EInfo, "MMA::CMMAStreamRequest::~CMMAStreamRequest -"); |
|
39 } |
|
40 |
|
41 TPtr8& CMMAStreamRequest::DataPtr() |
|
42 { |
|
43 return iDataPtr; |
|
44 } |
|
45 |
|
46 void CMMAStreamRequest::CompleteRead(TInt aError) |
|
47 { |
|
48 LOG( EJavaMMAPI, EInfo, "MMA::CMMAStreamRequest::CompleteRead +"); |
|
49 if (aError < KErrNone) |
|
50 { |
|
51 iListener->HandleError(this, aError); |
|
52 } |
|
53 else // OK |
|
54 { |
|
55 iListener->ReadComplete(this); |
|
56 } |
|
57 LOG( EJavaMMAPI, EInfo, "MMA::CMMAStreamRequest::CompleteRead -"); |
|
58 } |
|
59 |
|
60 void CMMAStreamRequest::SetActive(TBool aActive) |
|
61 { |
|
62 iActive = aActive; |
|
63 } |
|
64 |
|
65 TBool CMMAStreamRequest::IsActive() |
|
66 { |
|
67 return iActive; |
|
68 } |
|
69 |
|
70 TPckgBuf< TInt >& CMMAStreamRequest::RequestBuffer() |
|
71 { |
|
72 return iRequestBuffer; |
|
73 } |
|
74 |
|
75 void CMMAStreamRequest::WriteRequestComplete(TInt Err) |
|
76 { |
|
77 LOG( EJavaMMAPI, EInfo, "MMA::CMMAStreamRequest::WriteRequestComplete +"); |
|
78 if (Err == KErrNone) |
|
79 { |
|
80 // data is processed, set ready for reuse |
|
81 iDataPtr.SetLength(0); |
|
82 iListener->WriteComplete(this); |
|
83 } |
|
84 else // error |
|
85 { |
|
86 iListener->HandleError(this, Err); |
|
87 } |
|
88 LOG( EJavaMMAPI, EInfo, "MMA::CMMAStreamRequest::WriteRequestComplete -"); |
|
89 } |
|
90 |
|
91 CMMAStreamRequest::CMMAStreamRequest(MMMAStreamRequestListener* aListener): |
|
92 iListener(aListener), |
|
93 iDataPtr(NULL, 0),iActive(EFalse) |
|
94 { |
|
95 //Do Nothing |
|
96 } |
|
97 |
|
98 void CMMAStreamRequest::ConstructL() |
|
99 { |
|
100 LOG( EJavaMMAPI, EInfo, "MMA::CMMAStreamRequest::ConstructL +"); |
|
101 iData = HBufC8::NewL(KMMAStreamRequestBufferSize); |
|
102 iDataPtr.Set(iData->Des()); |
|
103 LOG( EJavaMMAPI, EInfo, "MMA::CMMAStreamRequest::ConstructL -"); |
|
104 } |
|
105 |
|
106 // END OF FILE |