|
1 /* |
|
2 * Copyright (c) 2009-2010 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 * Initial Contributors: |
|
9 * Nokia Corporation - initial contribution. |
|
10 * Contributors: |
|
11 * |
|
12 * Description: |
|
13 * MSRP Implementation |
|
14 * |
|
15 */ |
|
16 |
|
17 // INCLUDES |
|
18 |
|
19 // CLASS HEADER |
|
20 #include "CMSRPReader.h" |
|
21 #include "MSRPCommon.h" |
|
22 |
|
23 // ----------------------------------------------------------------------------- |
|
24 // CMSRPReader::NewL |
|
25 // Static constructor |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 /*static*/MMSRPReader* CMSRPReader::NewL(RSocket& aSocket, MMSRPReaderObserver& aConnection) |
|
29 { |
|
30 MSRPLOG( "CMSRPReader::NewL enter" ) |
|
31 CMSRPReader* self = new (ELeave) CMSRPReader( aSocket, aConnection ); |
|
32 CleanupStack::PushL(self); |
|
33 self->ConstructL(); |
|
34 CleanupStack::Pop(self); |
|
35 MSRPLOG( "CMSRPReader::NewL exit" ) |
|
36 return self; |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CMSRPReader::CMSRPReader |
|
41 // Constructor |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CMSRPReader::CMSRPReader(RSocket& aSocket, MMSRPReaderObserver& aConnection) |
|
45 : CActive(CActive::EPriorityStandard), iConnection( aConnection ), iSocket(aSocket) |
|
46 { |
|
47 CActiveScheduler::Add(this); |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CMSRPReader::~CMSRPReader |
|
52 // Destructor |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CMSRPReader::~CMSRPReader() |
|
56 { |
|
57 MSRPLOG( "CMSRPReader::~CMSRPReader enter" ) |
|
58 Cancel(); |
|
59 delete iBuf; |
|
60 MSRPLOG( "CMSRPReader::~CMSRPReader exit" ) |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CMSRPReader::ConstructL |
|
65 // 2nd phase constructor |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void CMSRPReader::ConstructL() |
|
69 { |
|
70 //iState = EIdle; |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CMSRPReader::DoCancel |
|
75 // Cancels outstanding request. |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 void CMSRPReader::DoCancel() |
|
79 { |
|
80 MSRPLOG( "CMSRPReader::DoCancel enter" ) |
|
81 iSocket.CancelRecv(); |
|
82 MSRPLOG( "CMSRPReader::DoCancel exit" ) |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CMSRPReader::Connect |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CMSRPReader::StartReceivingL(RMsrpBuf aBuf) |
|
90 { |
|
91 MSRPLOG( "CMSRPReader::StartReceivingL enter" ) |
|
92 //claim ownership, |
|
93 delete iBuf; |
|
94 iBuf = NULL; |
|
95 iBuf = new (ELeave) RMsrpBuf(aBuf); |
|
96 //make sure that iBuf' ptr length is updated and not some local copy |
|
97 iSocket.RecvOneOrMore( *iBuf, 0, iStatus, iNumberOfBytesRead ); |
|
98 SetActive(); |
|
99 MSRPLOG( "CMSRPReader::StartReceivingL exit" ) |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CMSRPReader::IsMessageMSRPReport |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 /*void CMSRPReader::CancelReceiving() |
|
107 { |
|
108 Cancel(); |
|
109 }*/ |
|
110 |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CMSRPReader::RunL |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void CMSRPReader::RunL() |
|
117 { |
|
118 MSRPLOG( "CMSRPReader::RunL enter" ) |
|
119 Deque(); |
|
120 CActiveScheduler::Add(this); |
|
121 iConnection.ReadStatusL(*iBuf, iStatus.Int()); |
|
122 MSRPLOG( "CMSRPReader::RunL exit" ) |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CMSRPReader::RunError |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 TInt CMSRPReader::RunError(TInt /*aError*/) |
|
130 { |
|
131 MSRPLOG( "CMSRPReader::RunError enter" ) |
|
132 MSRPLOG( "CMSRPReader::RunError exit" ) |
|
133 //iBuf cud b invalid, if iBuf alloc leaves |
|
134 //iConnection.ReadStatus(/**iBuf*/, aError); |
|
135 return KErrNone; |
|
136 } |
|
137 |
|
138 |
|
139 // End of File |
|
140 |