author | mikaruus <mika.a.ruuskanen@nokia.com> |
Wed, 21 Apr 2010 14:29:55 +0300 | |
changeset 8 | 6295dc2169f3 |
parent 5 | 8ccc39f9d787 |
child 9 | 8486d82aef45 |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* Copyright (c) 2007-2008 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 the License "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 |
// INCLUDE FILES |
|
21 |
#include <tisi.h> |
|
22 |
#include "cmmphonetsender.h" |
|
23 |
#include "cmmphonetreceiver.h" |
|
24 |
#include <ctsy/serviceapi/mmtsy_defaults.h> |
|
25 |
#include "tsylogger.h" // for logging purposes |
|
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
26 |
#include "OstTraceDefinitions.h" |
0 | 27 |
#ifdef OST_TRACE_COMPILER_IN_USE |
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
28 |
#include "cmmphonetsenderTraces.h" |
0 | 29 |
#endif |
30 |
||
31 |
// EXTERNAL DATA STRUCTURES |
|
32 |
// None |
|
33 |
||
34 |
// EXTERNAL FUNCTION PROTOTYPES |
|
35 |
// None |
|
36 |
||
37 |
// CONSTANTS |
|
38 |
#ifdef OST_TRACE_COMPILER_IN_USE |
|
39 |
const TUint8 KBufferForOSTTracing = 100; |
|
40 |
#endif |
|
41 |
#ifdef TF_LOGGING_ENABLED |
|
42 |
const TUint8 KBufferForTFLogging = 130; |
|
43 |
#endif |
|
44 |
||
45 |
// MACROS |
|
46 |
// None |
|
47 |
||
48 |
// LOCAL CONSTANTS AND MACROS |
|
49 |
// None |
|
50 |
||
51 |
// MODULE DATA STRUCTURES |
|
52 |
// None |
|
53 |
||
54 |
// LOCAL FUNCTION PROTOTYPES |
|
55 |
// None |
|
56 |
||
57 |
// FORWARD DECLARATIONS |
|
58 |
// None |
|
59 |
||
60 |
// ============================= LOCAL FUNCTIONS =============================== |
|
61 |
||
62 |
// ----------------------------------------------------------------------------- |
|
63 |
// TFLOG_PRINT_ISIMESSAGE |
|
64 |
// local function for priting ISI message contents |
|
65 |
// ----------------------------------------------------------------------------- |
|
66 |
// |
|
67 |
#if defined (TF_LOGGING_ENABLED) || defined (OST_TRACE_COMPILER_IN_USE) |
|
68 |
static void TFLOG_PRINT_ISIMESSAGE( const TDesC8& aBuf ) |
|
69 |
{ |
|
70 |
_LIT( KTraceSpace, " " ); |
|
71 |
||
72 |
// Get the length of the ISI message |
|
73 |
TInt length = aBuf.Length(); |
|
74 |
||
75 |
#ifdef TF_LOGGING_ENABLED |
|
76 |
TBuf<KBufferForTFLogging> msg; |
|
77 |
_LIT( KTracePhonetSender, "TSY:Phonet Sender: [ " ); |
|
78 |
_LIT( KTraceBracketClose, "]" ); |
|
79 |
||
80 |
msg.Append( KTracePhonetSender ); |
|
81 |
||
82 |
if ( 250 < length ) |
|
83 |
{ |
|
84 |
// Print only 250 first bytes |
|
85 |
length = 250; |
|
86 |
} |
|
87 |
||
88 |
for ( TInt i = 0; i < length; i++ ) |
|
89 |
{ |
|
90 |
msg.AppendNumFixedWidthUC( aBuf[i], EHex, 2 ); |
|
91 |
msg.Append( KTraceSpace ); |
|
92 |
if ( KLogSizeOfBuffer-10 < msg.Length() ) |
|
93 |
{ |
|
94 |
if ( i == ( length - 1 ) ) |
|
95 |
{ |
|
96 |
// Last number, append "]" character |
|
97 |
msg.Append( KTraceBracketClose ); |
|
98 |
} |
|
99 |
||
100 |
TFLOGTEXT( msg ); |
|
101 |
msg.SetLength( 0 ); |
|
102 |
} |
|
103 |
} |
|
104 |
||
105 |
if ( 0 < msg.Length() ) |
|
106 |
{ |
|
107 |
// Buffer contains data. Print also last line |
|
108 |
msg.Append( KTraceBracketClose ); |
|
109 |
TFLOGTEXT( msg ); |
|
110 |
} |
|
111 |
#endif // TF_LOGGING_ENABLED |
|
112 |
||
113 |
// Ost tracing |
|
114 |
#ifdef OST_TRACE_COMPILER_IN_USE |
|
115 |
TBuf8<KBufferForOSTTracing> trace_msg; |
|
116 |
TUint8 counter = 1; |
|
117 |
TBool firstTime = ETrue; |
|
118 |
for ( TInt i = 0; i < length; i++ ) |
|
119 |
{ |
|
120 |
trace_msg.AppendNumFixedWidthUC( aBuf[i], EHex, 2 ); |
|
121 |
trace_msg.Append( KTraceSpace ); |
|
122 |
||
123 |
if ( ( counter > 24 ) || // 25 bytes / line |
|
124 |
( ( i + 1 ) == length ) ) // All bytes collected |
|
125 |
{ |
|
126 |
if ( ( firstTime ) && |
|
127 |
( ( i + 1 ) == length ) ) // All bytes collected and traced |
|
128 |
{ |
|
129 |
firstTime = EFalse; |
|
130 |
OstTraceExt1( TRACE_NORMAL, _TFLOG_PRINT_ISIMESSAGE, "Phonet Sender: [ %s]", trace_msg ); |
|
131 |
trace_msg.SetLength( 0 ); |
|
132 |
} |
|
133 |
else if ( firstTime ) // 1st line of the trace |
|
134 |
{ |
|
135 |
firstTime = EFalse; |
|
136 |
OstTraceExt1( TRACE_NORMAL, DUP1__TFLOG_PRINT_ISIMESSAGE, "Phonet Sender: [ %s", trace_msg ); |
|
137 |
trace_msg.SetLength( 0 ); |
|
138 |
} |
|
139 |
else if ( ( i + 1 ) == length ) // The last line |
|
140 |
{ |
|
141 |
OstTraceExt1( TRACE_NORMAL, DUP4__TFLOG_PRINT_ISIMESSAGE, "Phonet Sender: %s]", trace_msg ); |
|
142 |
trace_msg.SetLength( 0 ); |
|
143 |
} |
|
144 |
else // just print bytes |
|
145 |
{ |
|
146 |
OstTraceExt1( TRACE_NORMAL, DUP5__TFLOG_PRINT_ISIMESSAGE, "Phonet Sender: %s", trace_msg ); |
|
147 |
trace_msg.SetLength( 0 ); |
|
148 |
} |
|
149 |
counter = 0; |
|
150 |
} |
|
151 |
counter++; |
|
152 |
} |
|
153 |
#endif // OST_TRACE_COMPILER_IN_USE |
|
154 |
} |
|
155 |
||
156 |
#else // TF_LOGGING_ENABLED || OST_TRACE_COMPILER_IN_USE |
|
157 |
||
158 |
#define TFLOG_PRINT_ISIMESSAGE(x) |
|
159 |
||
160 |
#endif // TF_LOGGING_ENABLED || OST_TRACE_COMPILER_IN_USE |
|
161 |
||
162 |
// ============================ MEMBER FUNCTIONS =============================== |
|
163 |
||
164 |
// ----------------------------------------------------------------------------- |
|
165 |
// CMmPhoNetSender::CMmPhoNetSender |
|
166 |
// C++ default constructor can NOT contain any code, that might leave. |
|
167 |
// ----------------------------------------------------------------------------- |
|
168 |
// |
|
169 |
CMmPhoNetSender::CMmPhoNetSender() |
|
170 |
:iSendBuffer( NULL ), |
|
171 |
iSendBufferPtr( 0,0 ) |
|
172 |
{ |
|
173 |
TFLOGSTRING("TSY: CMmPhoNetSender::CMmPhoNetSender"); |
|
174 |
OstTrace0( TRACE_NORMAL, CMMPHONETSENDER_CMMPHONETSENDER, "CMmPhoNetSender::CMmPhoNetSender" ); |
|
175 |
} |
|
176 |
||
177 |
// ----------------------------------------------------------------------------- |
|
178 |
// CMmPhoNetSender::~CMmPhoNetSender |
|
179 |
// Destructor, deletes all allocated resources. |
|
180 |
// ----------------------------------------------------------------------------- |
|
181 |
// |
|
182 |
CMmPhoNetSender::~CMmPhoNetSender() |
|
183 |
{ |
|
184 |
TFLOGSTRING("TSY: CMmPhoNetSender::~CMmPhoNetSender"); |
|
185 |
OstTrace0( TRACE_NORMAL, DUP1_CMMPHONETSENDER_CMMPHONETSENDER, "CMmPhoNetSender::~CMmPhoNetSender" ); |
|
186 |
delete iSendBuffer; |
|
187 |
} |
|
188 |
||
189 |
// ----------------------------------------------------------------------------- |
|
190 |
// CMmPhoNetSender::NewL |
|
191 |
// Two-phased constructor. |
|
192 |
// ----------------------------------------------------------------------------- |
|
193 |
// |
|
194 |
CMmPhoNetSender* CMmPhoNetSender::NewL |
|
195 |
( |
|
196 |
RIscApi* aPn // Pointer to the IscApi |
|
197 |
) |
|
198 |
{ |
|
199 |
TFLOGSTRING("TSY: CMmPhoNetSender::NewL"); |
|
200 |
OstTrace0( TRACE_NORMAL, CMMPHONETSENDER_NEWL, "CMmPhoNetSender::NewL" ); |
|
201 |
||
202 |
CMmPhoNetSender* phoNetSender = NULL; |
|
203 |
||
204 |
if ( NULL != aPn ) |
|
205 |
{ |
|
206 |
phoNetSender = new( ELeave ) CMmPhoNetSender(); |
|
207 |
CleanupStack::PushL( phoNetSender ); |
|
208 |
phoNetSender->iPhoNet = aPn; |
|
209 |
phoNetSender->ConstructL(); |
|
210 |
CleanupStack::Pop( phoNetSender ); |
|
211 |
} |
|
212 |
||
213 |
return phoNetSender; |
|
214 |
} |
|
215 |
||
216 |
// ----------------------------------------------------------------------------- |
|
217 |
// CMmPhoNetSender::ConstructL |
|
218 |
// Symbian 2nd phase constructor can leave. |
|
219 |
// ----------------------------------------------------------------------------- |
|
220 |
// |
|
221 |
void CMmPhoNetSender::ConstructL() |
|
222 |
{ |
|
223 |
TFLOGSTRING("TSY: CMmPhoNetSender::ConstructL"); |
|
224 |
OstTrace0( TRACE_NORMAL, CMMPHONETSENDER_CONSTRUCTL, "CMmPhoNetSender::ConstructL" ); |
|
225 |
iSendBuffer = HBufC8::NewL( KMaxSendBufferSize ); |
|
226 |
iSendBufferPtr.Set( iSendBuffer->Des() ); |
|
227 |
||
228 |
TFLOGSTRING2("TSY: iSendBuffer len=%d", iSendBuffer->Length()); |
|
229 |
OstTrace1( TRACE_NORMAL, DUP1_CMMPHONETSENDER_CONSTRUCTL, "CMmPhoNetSender::ConstructL;iSendBuffer->Length=%d", iSendBuffer->Length() ); |
|
230 |
TFLOGSTRING3("TSY: iSendBufferPtr len=%d maxlen=%d", |
|
231 |
iSendBufferPtr.Length(), |
|
232 |
iSendBufferPtr.MaxLength()); |
|
233 |
OstTrace1( TRACE_NORMAL, DUP2_CMMPHONETSENDER_CONSTRUCTL, "CMmPhoNetSender::ConstructL;iSendBufferPtr.MaxLength=%d", iSendBufferPtr.MaxLength() ); |
|
234 |
} |
|
235 |
||
236 |
// ----------------------------------------------------------------------------- |
|
237 |
// CMmPhoNetSender::SendBufferDes |
|
238 |
// Description: Returns pointer to buffer for ISI message construction |
|
239 |
// (other items were commented in a header). |
|
240 |
// ----------------------------------------------------------------------------- |
|
241 |
// |
|
242 |
TDes8& CMmPhoNetSender::SendBufferDes() |
|
243 |
{ |
|
244 |
OstTrace0( TRACE_NORMAL, CMMPHONETSENDER_SENDBUFFERDES, "CMmPhoNetSender::SendBufferDes" ); |
|
245 |
return iSendBufferPtr; |
|
246 |
} |
|
247 |
||
248 |
// ----------------------------------------------------------------------------- |
|
249 |
// CMmPhoNetSender::Send |
|
250 |
// Sends a message to the PhoNet if PhonetSender is not blocked |
|
251 |
// for example by the object of type CMmPhoneTsy (out of memory situation). |
|
252 |
// (other items were commented in a header). |
|
253 |
// ----------------------------------------------------------------------------- |
|
254 |
// |
|
255 |
TInt CMmPhoNetSender::Send |
|
256 |
( |
|
257 |
const TDesC8& aMsg // ISI message to be sent to Phonet |
|
258 |
) |
|
259 |
{ |
|
260 |
TFLOGSTRING("TSY: CMmPhoNetSender::Send"); |
|
261 |
OstTrace0( TRACE_NORMAL, CMMPHONETSENDER_SEND, "CMmPhoNetSender::Send" ); |
|
262 |
||
263 |
TInt ret( KErrServerBusy ); |
|
264 |
||
265 |
ret = iPhoNet->Send( aMsg ); |
|
266 |
||
267 |
// If sending failed |
|
268 |
if ( KErrNone != ret ) |
|
269 |
{ |
|
270 |
// Return general error value to client hiding the real Phonet |
|
271 |
// problem. There is no need to identify the problem more clearly |
|
272 |
// above MM API. |
|
273 |
ret = KErrGeneral; |
|
274 |
} |
|
275 |
||
276 |
TFLOG_PRINT_ISIMESSAGE( aMsg ); |
|
277 |
||
278 |
return ret; |
|
279 |
} |
|
280 |
||
281 |
// ----------------------------------------------------------------------------- |
|
282 |
// CMmPhoNetSender::Send |
|
283 |
// Send ISI message, given resource, transaction message id and contents |
|
284 |
// (other items were commented in a header). |
|
285 |
// ----------------------------------------------------------------------------- |
|
286 |
// |
|
287 |
TInt CMmPhoNetSender::Send |
|
288 |
( |
|
289 |
TInt aResource, // ISI resource (server) |
|
290 |
TInt aTransactionId, // ISI transaction ID |
|
291 |
TInt aMessageId, // ISI message ID |
|
292 |
const TDesC8& aData // Data part of ISI message |
|
293 |
) |
|
294 |
{ |
|
295 |
TFLOGSTRING("TSY: CMmPhoNetSender::Send (resource+transaction+data)"); |
|
296 |
OstTrace0( TRACE_NORMAL, DUP1_CMMPHONETSENDER_SEND, "CMmPhoNetSender::Send (resource+transaction+data)" ); |
|
297 |
||
298 |
// We shall use send buffer |
|
299 |
TDes8& buffer( SendBufferDes() ); |
|
300 |
buffer.Zero(); |
|
301 |
const TInt header_size( 10 ); // Header + transaction id + message id |
|
302 |
TIsiSend msg( buffer, header_size + aData.Length() ); |
|
303 |
msg.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, aResource ); |
|
304 |
msg.Set8bit( ISI_HEADER_OFFSET_MESSAGEID, aMessageId ); |
|
305 |
msg.Set8bit( ISI_HEADER_OFFSET_TRANSID, aTransactionId ); |
|
306 |
msg.CopyData( header_size, aData ); |
|
307 |
||
308 |
// Add padding |
|
309 |
while ( buffer.Length() % 4 ) |
|
310 |
{ |
|
311 |
buffer.Append( 0x00 ); |
|
312 |
} |
|
313 |
||
314 |
return Send( msg.Complete() ); |
|
315 |
} |
|
316 |
||
317 |
// ----------------------------------------------------------------------------- |
|
318 |
// CMmPhoNetSender::EventSend |
|
319 |
// |
|
320 |
// ----------------------------------------------------------------------------- |
|
321 |
// |
|
322 |
TInt CMmPhoNetSender::EventSend |
|
323 |
( |
|
324 |
const TDesC8& aEvent |
|
325 |
) |
|
326 |
{ |
|
327 |
TFLOGSTRING("TSY: CMmPhoNetSender::EventSend"); |
|
328 |
OstTrace0( TRACE_NORMAL, CMMPHONETSENDER_EVENTSEND, "CMmPhoNetSender::EventSend" ); |
|
329 |
||
330 |
return iPhoNet->CustomFunction( EIscNokiaEventSend, (TDes8*)&aEvent ); |
|
331 |
} |
|
332 |
||
333 |
// ----------------------------------------------------------------------------- |
|
334 |
// CMmPhoNetSender::SubscribeEvents |
|
335 |
// |
|
336 |
// ----------------------------------------------------------------------------- |
|
337 |
// |
|
338 |
TInt CMmPhoNetSender::SubscribeEvents |
|
339 |
( |
|
340 |
const TDesC8& aEvents // Events to be subscribed |
|
341 |
) |
|
342 |
{ |
|
343 |
TFLOGSTRING("TSY: CMmPhoNetSender::SubscribeEvents"); |
|
344 |
OstTrace0( TRACE_NORMAL, CMMPHONETSENDER_SUBSCRIBEEVENTS, "CMmPhoNetSender::SubscribeEvents" ); |
|
345 |
||
346 |
return iPhoNet->CustomFunction( EIscNokiaEventSubscribe, (TDes8*)&aEvents ); |
|
347 |
} |
|
348 |
||
349 |
// ----------------------------------------------------------------------------- |
|
350 |
// CMmPhoNetSender::GetChannelInfo |
|
351 |
// |
|
352 |
// ----------------------------------------------------------------------------- |
|
353 |
// |
|
354 |
TInt CMmPhoNetSender::GetChannelInfo |
|
355 |
( |
|
356 |
const TUint16 aChannel, |
|
357 |
TDes8& aInfo |
|
358 |
) |
|
359 |
{ |
|
360 |
TFLOGSTRING("TSY: CMmPhoNetSender::GetChannelInfo"); |
|
361 |
OstTrace0( TRACE_NORMAL, CMMPHONETSENDER_GETCHANNELINFO, "CMmPhoNetSender::GetChannelInfo" ); |
|
362 |
||
363 |
return iPhoNet->GetChannelInfo( aChannel, aInfo ); |
|
364 |
} |
|
365 |
||
366 |
// ==================== OTHER EXPORTED FUNCTIONS =============================== |
|
367 |
// None |
|
368 |
||
369 |
// End of File |
|
370 |
||
371 |
||
372 |