|
1 /* |
|
2 * Copyright (c) 2006-2007 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 |
|
20 |
|
21 // INCLUDES |
|
22 #include "mccqoseventmonitor.h" |
|
23 #include "mccqoseventobserver.h" |
|
24 #include "mccqoslogging.h" |
|
25 |
|
26 // Constants for subconnection events. Need to define them here, because |
|
27 // we cannot include cs_subconevents.h as that leads to unfrozen exports |
|
28 // in this DLL. This will be fixed later. |
|
29 const TUint32 KSubConGenericEventParamsGranted = 0x1; |
|
30 const TUint32 KSubConGenericEventDataClientJoined = 0x2; |
|
31 const TUint32 KSubConGenericEventDataClientLeft = 0x4; |
|
32 const TUint32 KSubConGenericEventSubConDown = 0x8; |
|
33 const TUint32 KSubConGenericEventParamsChanged = 0x10; |
|
34 const TUint32 KSubConGenericEventParamsRejected = 0x20; |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS ============================= |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // CMccQosEventMonitor::CMccQosEventMonitor |
|
40 // C++ default constructor can NOT contain any code, that might leave. |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 CMccQosEventMonitor::CMccQosEventMonitor( MMccQosEventObserver& aObserver, |
|
44 RSubConnection& aSubConnection ) : CActive( EPriorityStandard ), |
|
45 iEventObserver( aObserver ), iSubConnection( aSubConnection ) |
|
46 { |
|
47 CActiveScheduler::Add( this ); |
|
48 } |
|
49 |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CMccQosEventMonitor::NewL |
|
53 // Two-phased constructor. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CMccQosEventMonitor* CMccQosEventMonitor::NewL( MMccQosEventObserver& |
|
57 aObserver, RSubConnection& aSubConnection ) |
|
58 { |
|
59 __QOSLOG( "CMccQosEventMonitor::NewL" ) |
|
60 |
|
61 CMccQosEventMonitor* self( |
|
62 CMccQosEventMonitor::NewLC( aObserver, aSubConnection ) ); |
|
63 |
|
64 CleanupStack::Pop( self ); |
|
65 return self; |
|
66 } |
|
67 |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CMccQosEventMonitor::NewLC |
|
71 // Two-phased constructor. |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CMccQosEventMonitor* CMccQosEventMonitor::NewLC( MMccQosEventObserver& |
|
75 aObserver, RSubConnection& aSubConnection ) |
|
76 { |
|
77 __QOSLOG( "CMccQosEventMonitor::NewLC" ) |
|
78 |
|
79 CMccQosEventMonitor* self = new ( ELeave ) CMccQosEventMonitor( aObserver, |
|
80 aSubConnection ); |
|
81 |
|
82 CleanupStack::PushL( self ); |
|
83 self->ConstructL(); |
|
84 return self; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CMccQosEventMonitor::ConstructL |
|
89 // Symbian 2nd phase constructor can leave. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CMccQosEventMonitor::ConstructL() |
|
93 { |
|
94 __QOSLOG( "CMccQosEventMonitor::ConstructL" ) |
|
95 |
|
96 StartListenL(); |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CMccQosEventMonitor::~CMccQosEventMonitor |
|
101 // Destructor |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 CMccQosEventMonitor::~CMccQosEventMonitor() |
|
105 { |
|
106 __QOSLOG("CMccQosEventMonitor::~CMccQosEventMonitor") |
|
107 |
|
108 // Calls DoCancel() if active |
|
109 Cancel(); |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CMccQosEventMonitor::StartListen() |
|
115 // Sets active object active and issues listening |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void CMccQosEventMonitor::StartListenL() |
|
119 { |
|
120 __QOSLOG_INT1( "CMccQosEventMonitor::StartListen iLastError: ", iLastError ) |
|
121 __QOSLOG_INT1( "CMccQosEventMonitor::StartListen IsActive: ", IsActive() ) |
|
122 |
|
123 if ( !IsActive() ) |
|
124 { |
|
125 if ( KErrInUse != iLastError || |
|
126 KErrCancel != iLastError || |
|
127 KErrAbort != iLastError ) |
|
128 { |
|
129 __QOSLOG( "CMccQosEventMonitor::StartListen -> EventNotification") |
|
130 |
|
131 iSubConnection.EventNotification( iQoSNotifBuffer, |
|
132 EFalse, iStatus ); |
|
133 SetActive(); |
|
134 } |
|
135 } |
|
136 else |
|
137 { |
|
138 __QOSLOG( "CMccQosEventMonitor::StartListen KErrNotReady") |
|
139 |
|
140 User::Leave( KErrNotReady ); |
|
141 } |
|
142 } |
|
143 |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // CMccQosEventMonitor::DoCancel |
|
147 // Cancel any outstanding operation. |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 void CMccQosEventMonitor::DoCancel() |
|
151 { |
|
152 __QOSLOG( "CMccQosEventMonitor::DoCancel" ) |
|
153 |
|
154 iSubConnection.CancelEventNotification(); |
|
155 } |
|
156 |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CMccQosEventMonitor::RunL |
|
160 // Handle completion of asynchronous requests to RSubConnection |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 void CMccQosEventMonitor::RunL() |
|
164 { |
|
165 iLastError = iStatus.Int(); |
|
166 const TUint32 notifyId( iQoSNotifBuffer.Id() ); |
|
167 |
|
168 StartListenL(); |
|
169 |
|
170 __QOSLOG_INT1( "CMccQosEventMonitor::RunL iLastError: ", iLastError ) |
|
171 |
|
172 #ifdef __QOSLOG |
|
173 |
|
174 switch( notifyId ) |
|
175 { |
|
176 // Parameters related |
|
177 case KSubConGenericEventParamsGranted: |
|
178 __QOSLOG( "CMccQosEventMonitor::RunL GRANTED" ) |
|
179 break; |
|
180 |
|
181 case KSubConGenericEventParamsChanged: |
|
182 __QOSLOG( "CMccQosEventMonitor::RunL CHANGED" ) |
|
183 break; |
|
184 |
|
185 case KSubConGenericEventParamsRejected: |
|
186 __QOSLOG( "CMccQosEventMonitor::RunL REJECTED" ) |
|
187 break; |
|
188 |
|
189 case KSubConGenericEventDataClientJoined: |
|
190 __QOSLOG( "CMccQosEventMonitor::RunL DATACLIENT JOINED" ) |
|
191 break; |
|
192 |
|
193 case KSubConGenericEventDataClientLeft: |
|
194 __QOSLOG( "CMccQosEventMonitor::RunL DATACLIENT LEFT" ) |
|
195 break; |
|
196 |
|
197 case KSubConGenericEventSubConDown: |
|
198 __QOSLOG( "CMccQosEventMonitor::RunL SUBCON DOWN" ) |
|
199 break; |
|
200 |
|
201 default: |
|
202 __QOSLOG_INT1("CMccQosEventMonitor::RunL UNKNOWN: ", |
|
203 iQoSNotifBuffer.Id() ) |
|
204 break; |
|
205 } |
|
206 #endif |
|
207 |
|
208 iEventObserver.QoSParamEvent( iLastError, notifyId ); |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CMccQosEventMonitor::RunError |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 TInt CMccQosEventMonitor::RunError( TInt aError ) |
|
216 { |
|
217 __QOSLOG_INT1( "CMccQosEventMonitor::RunError aError: ", aError ) |
|
218 |
|
219 if ( KErrNoMemory == aError ) |
|
220 { |
|
221 return aError; |
|
222 } |
|
223 else |
|
224 { |
|
225 #ifdef _DEBUG |
|
226 |
|
227 return aError; |
|
228 |
|
229 #else // UREL |
|
230 |
|
231 return KErrNone; |
|
232 |
|
233 #endif // _DEBUG |
|
234 } |
|
235 } |
|
236 |