1 /* |
|
2 * Copyright (c) 2002-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: Handles GetChannelStatus command |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "MSatApi.h" |
|
22 #include "MSatUtils.h" |
|
23 #include "MSatBIPUtils.h" |
|
24 #include "MSatBIPDataChannel.h" |
|
25 #include "CGetChannelStatusHandler.h" |
|
26 #include "SatLog.h" |
|
27 |
|
28 // CONSTANTS |
|
29 // length of channel status info |
|
30 const TUint8 KChannelStatusLength = 2; |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CGetChannelStatusHandler::NewL |
|
36 // Two-phased constructor. |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CGetChannelStatusHandler* CGetChannelStatusHandler::NewL( MSatUtils* aUtils ) |
|
40 { |
|
41 LOG( SIMPLE, "GETCHANNELSTATUS: CGetChannelStatusHandler::NewL calling" ) |
|
42 CGetChannelStatusHandler* self = new( ELeave ) CGetChannelStatusHandler; |
|
43 |
|
44 CleanupStack::PushL( self ); |
|
45 self->BaseConstructL( aUtils ); |
|
46 // ConstructL not needed. |
|
47 CleanupStack::Pop( self ); |
|
48 |
|
49 LOG( SIMPLE, "GETCHANNELSTATUS: CGetChannelStatusHandler::NewL exiting" ) |
|
50 return self; |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CGetChannelStatusHandler::~CGetChannelStatusHandler |
|
55 // Destructor |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CGetChannelStatusHandler::~CGetChannelStatusHandler() |
|
59 { |
|
60 LOG( SIMPLE, "GETCHANNELSTATUS: CGetChannelStatusHandler::\ |
|
61 CGetChannelStatusHandler calling" ) |
|
62 |
|
63 Cancel(); |
|
64 |
|
65 LOG( SIMPLE, "GETCHANNELSTATUS: CGetChannelStatusHandler::\ |
|
66 ~CGetChannelStatusHandler exiting" ) |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CGetChannelStatusHandler::DoCancel |
|
71 // Cancels the sat request. |
|
72 // (other items were commented in a header). |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 void CGetChannelStatusHandler::DoCancel() |
|
76 { |
|
77 LOG( SIMPLE, "GETCHANNELSTATUS: CGetChannelStatusHandler::\ |
|
78 DoCancel calling" ) |
|
79 |
|
80 iUtils->USatAPI().NotifyGetChannelStatusCancel(); |
|
81 |
|
82 LOG( SIMPLE, "GETCHANNELSTATUS: CGetChannelStatusHandler::\ |
|
83 DoCancel exiting" ) |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CGetChannelStatusHandler::IssueUSATRequest |
|
88 // (other items were commented in a header). |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CGetChannelStatusHandler::IssueUSATRequest( TRequestStatus& aStatus ) |
|
92 { |
|
93 LOG( SIMPLE, |
|
94 "GETCHANNELSTATUS: CGetChannelStatusHandler::IssueUSATRequest calling" ) |
|
95 |
|
96 // Reset previously received data |
|
97 new (&iGetChannelData) RSat::TGetChannelStatusV2(); |
|
98 iUtils->USatAPI().NotifyGetChannelStatus( aStatus, iGetChannelDataPckg ); |
|
99 |
|
100 LOG( SIMPLE, |
|
101 "GETCHANNELSTATUS: CGetChannelStatusHandler::IssueUSATRequest exiting" ) |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CGetChannelStatusHandler::CommandAllowed |
|
106 // (other items were commented in a header). |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 TBool CGetChannelStatusHandler::CommandAllowed() |
|
110 { |
|
111 LOG( SIMPLE, "GETCHANNELSTATUS: CGetChannelStatusHandler::CommandAllowed \ |
|
112 calling - exiting" ) |
|
113 // Get channel status command is always allowed |
|
114 return ETrue; |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CGetChannelStatusHandler::NeedUiSession |
|
119 // (other items were commented in a header). |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 TBool CGetChannelStatusHandler::NeedUiSession() |
|
123 { |
|
124 LOG( SIMPLE, "GETCHANNELSTATUS: CGetChannelStatusHandler::NeedUiSession\ |
|
125 calling - exiting" ) |
|
126 // This command doesn't need UI |
|
127 return EFalse; |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CGetChannelStatusHandler::HandleCommand |
|
132 // (other items were commented in a header). |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void CGetChannelStatusHandler::HandleCommand() |
|
136 { |
|
137 LOG( SIMPLE, |
|
138 "GETCHANNELSTATUS: CGetChannelStatusHandler::HandleCommand calling" ) |
|
139 |
|
140 iUtils->NotifyEvent( MSatUtils::EGetChannelStatusExecuting ); |
|
141 // Get data channels from BIP Utils |
|
142 CArrayPtrFlat<MSatBIPDataChannel>* dataChannels( |
|
143 iUtils->BipUtils().DataChannels() ); |
|
144 |
|
145 // Get number of data channels |
|
146 const TInt channelCount( dataChannels->Count() ); |
|
147 |
|
148 // Create IPC package |
|
149 iGetChannelRsp.SetPCmdNumber( iGetChannelData.PCmdNumber() ); |
|
150 |
|
151 // Check that count is more than 0 |
|
152 if ( channelCount > 0 ) |
|
153 { |
|
154 LOG( NORMAL, "GETCHANNELSTATUS: CGetChannelStatusHandler::HandleCommand\ |
|
155 Gathering channel statuses" ) |
|
156 |
|
157 TRAPD( err, GetChannelStatusesL( channelCount ) ); |
|
158 if ( KErrNone == err ) |
|
159 { |
|
160 // Result is success |
|
161 iGetChannelRsp.iInfoType = RSat::KChannelStatusInfo; |
|
162 iGetChannelRsp.iGeneralResult = RSat::KSuccess; |
|
163 } |
|
164 else |
|
165 { |
|
166 LOG2( NORMAL, "GETCHANNELSTATUS: CGetChannelStatusHandler::\ |
|
167 HandleCommand with error: %i", err ) |
|
168 // Error |
|
169 iGetChannelRsp.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
170 iGetChannelRsp.iInfoType = RSat::KMeProblem; |
|
171 iGetChannelRsp.iAdditionalInfo.SetLength( 1 ); |
|
172 iGetChannelRsp.iAdditionalInfo[0] = RSat::KNoSpecificMeProblem; |
|
173 } |
|
174 } |
|
175 else |
|
176 { |
|
177 LOG( NORMAL, "GETCHANNELSTATUS: CGetChannelStatusHandler::HandleCommand\ |
|
178 No data channels" ) |
|
179 // No data channels available, return one empty ChannelStatus object |
|
180 iGetChannelRsp.iInfoType = RSat::KChannelStatusInfo; |
|
181 iGetChannelRsp.iGeneralResult = RSat::KSuccess; |
|
182 // No channels, return ChannelStatusInfo 00 00 |
|
183 iGetChannelRsp.iAdditionalInfo.SetLength( KChannelStatusLength ); |
|
184 iGetChannelRsp.iAdditionalInfo[0] = 0x00; |
|
185 iGetChannelRsp.iAdditionalInfo[1] = 0x00; |
|
186 } |
|
187 |
|
188 // Send terminal response |
|
189 TerminalRsp( RSat::EGetChannelStatus, iGetChannelRspPckg ); |
|
190 |
|
191 LOG( SIMPLE, |
|
192 "GETCHANNELSTATUS: CGetChannelStatusHandler::HandleCommand exiting" ) |
|
193 } |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // CGetChannelStatusHandler::UiLaunchFailed |
|
197 // (other items were commented in a header). |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 void CGetChannelStatusHandler::UiLaunchFailed() |
|
201 { |
|
202 LOG( SIMPLE, "GETCHANNELSTATUS: CGetChannelStatusHandler::UiLaunchFailed \ |
|
203 calling-exiting" ) |
|
204 } |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CGetChannelStatusHandler::GetChannelStatusesL |
|
208 // (other items were commented in a header). |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 void CGetChannelStatusHandler::GetChannelStatusesL( const TInt aChannelCount ) |
|
212 { |
|
213 LOG( SIMPLE, "GETCHANNELSTATUS: CGetChannelStatusHandler::\ |
|
214 GetChannelStatuses calling" ) |
|
215 |
|
216 // Get data channels from BIP Utils |
|
217 CArrayPtrFlat<MSatBIPDataChannel>* dataChannels( |
|
218 iUtils->BipUtils().DataChannels() ); |
|
219 |
|
220 // Each data channel needs 2 slots in additional info |
|
221 iGetChannelRsp.iAdditionalInfo.SetLength( |
|
222 aChannelCount * KChannelStatusLength ); |
|
223 |
|
224 TInt addInfoIndex = 0; |
|
225 LOG2( SIMPLE, "GETCHANNELSTATUS: CGetChannelStatusHandler::\ |
|
226 GetChannelStatusesL aChannelCount: %d", aChannelCount ) |
|
227 // Loop data channels |
|
228 if ( dataChannels->Count() >= aChannelCount ) |
|
229 { |
|
230 LOG( SIMPLE, "GETCHANNELSTATUS: CGetChannelStatusHandler::\ |
|
231 GetChannelStatusesL dataChannels->Count() >= aChannelCount" ) |
|
232 for ( TInt i = 0; i < aChannelCount; i++ ) |
|
233 { |
|
234 // Get data channel from array |
|
235 MSatBIPDataChannel* channel = dataChannels->At( i ); |
|
236 // Generate TChannelStatus |
|
237 RSat::TChannelStatus status( |
|
238 iUtils->BipUtils().GenerateChannelStatusL( |
|
239 channel->ChannelId(), channel->Status() ) ); |
|
240 |
|
241 // Add first byte (channel ID and context activation state) |
|
242 iGetChannelRsp.iAdditionalInfo[addInfoIndex++] = status[0]; |
|
243 // Add second byte (channel status) |
|
244 iGetChannelRsp.iAdditionalInfo[addInfoIndex++] = status[1]; |
|
245 } |
|
246 } |
|
247 |
|
248 LOG( SIMPLE, "GETCHANNELSTATUS: CGetChannelStatusHandler::\ |
|
249 GetChannelStatuses exiting" ) |
|
250 } |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // CGetChannelStatusHandler::CGetChannelStatusHandler |
|
254 // C++ default constructor can NOT contain any code, that |
|
255 // might leave. |
|
256 // ----------------------------------------------------------------------------- |
|
257 // |
|
258 CGetChannelStatusHandler::CGetChannelStatusHandler() : |
|
259 CSatCommandHandler(), |
|
260 iGetChannelData(), |
|
261 iGetChannelDataPckg( iGetChannelData ), |
|
262 iGetChannelRsp(), |
|
263 iGetChannelRspPckg( iGetChannelRsp ) |
|
264 { |
|
265 LOG( SIMPLE, |
|
266 "GETCHANNELSTATUS: CGetChannelStatusHandler::\ |
|
267 CGetChannelStatusHandler calling - exiting" ) |
|
268 } |
|
269 |
|
270 // End of File |
|