author | mikaruus <mika.a.ruuskanen@nokia.com> |
Thu, 14 Jan 2010 10:44:58 +0200 | |
changeset 5 | 8ccc39f9d787 |
parent 0 | 63b37f68c1ce |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* Copyright (c) 2009 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 <pn_eventmodem_extisi.h> // PNS_SUBSCRIBED_RESOURCES_EXTEND_IND_... |
|
21 |
#include <phonetisi.h> // For ISI_HEADER_SIZE |
|
22 |
#include <pn_const.h> // For PN_HEADER_SIZE |
|
23 |
#include "indicationhandler.h" |
|
24 |
#include "iadtrace.h" // For C_TRACE.. |
|
25 |
#include "router.h" // For DRouter |
|
26 |
#include "iadhelpers.h" |
|
27 |
#include "OstTraceDefinitions.h" |
|
28 |
#ifdef OST_TRACE_COMPILER_IN_USE |
|
29 |
#include "indicationhandlerTraces.h" |
|
30 |
#endif |
|
31 |
// For GET_RECEIVER |
|
32 |
||
33 |
DIndicationHandler::DIndicationHandler( |
|
34 |
DRouter& aRouter |
|
35 |
) |
|
36 |
: iRouter( aRouter ) |
|
37 |
{ |
|
38 |
OstTrace1( TRACE_NORMAL, DINDICATIONHANDLER_DINDICATIONHANDLER_ENTRY, ">DIndicationHandler::DIndicationHandler;aRouter=%x", ( TUint )&( aRouter ) ); |
|
39 |
||
40 |
C_TRACE( ( _T( "DIndicationHandler::DIndicationHandler 0x%x ->" ), &iRouter ) ); |
|
41 |
C_TRACE( ( _T( "DIndicationHandler::DIndicationHandler 0x%x <-" ), &iRouter ) ); |
|
42 |
||
43 |
OstTrace0( TRACE_NORMAL, DINDICATIONHANDLER_DINDICATIONHANDLER_EXIT, "<DIndicationHandler::DIndicationHandler" ); |
|
44 |
} |
|
45 |
||
46 |
DIndicationHandler::~DIndicationHandler( |
|
47 |
// None |
|
48 |
) |
|
49 |
{ |
|
50 |
OstTrace0( TRACE_NORMAL, DINDICATIONHANDLER_DINDICATIONHANDLER_DES_ENTRY, ">DIndicationHandler::~DIndicationHandler" ); |
|
51 |
||
52 |
C_TRACE( ( _T( "DIndicationHandler::~DIndicationHandler ->" ) ) ); |
|
53 |
C_TRACE( ( _T( "DIndicationHandler::~DIndicationHandler <-" ) ) ); |
|
54 |
||
55 |
OstTrace0( TRACE_NORMAL, DINDICATIONHANDLER_DINDICATIONHANDLER_DES_EXIT, "<DIndicationHandler::~DIndicationHandler" ); |
|
56 |
} |
|
57 |
||
58 |
||
59 |
void DIndicationHandler::Multicast( |
|
60 |
TDes8& aIndication |
|
61 |
) |
|
62 |
{ |
|
63 |
||
64 |
OstTrace1( TRACE_NORMAL, DINDICATIONHANDLER_MULTICAST_ENTRY, ">DIndicationHandler::Multicast;aIndication=%x", ( TUint )&( aIndication ) ); |
|
65 |
// TODO: ! NOTE ! This is run in commonrx dfc dfc queu, how long will this take? latency to dfc thread and commondfc switch to own dfc instead? |
|
66 |
C_TRACE( ( _T( "DIndicationHandler::Multicast 0x%x ->" ), &aIndication ) ); |
|
67 |
//TODO: change there const to offsets? |
|
68 |
const TUint8 KPnMsgExtendedType( 9 ); |
|
69 |
const TUint8 KPnMsgExtendedSubType( 10 ); |
|
70 |
TUint8* ptr = const_cast<TUint8*>( aIndication.Ptr() ); |
|
71 |
TUint32 resourceId( 0x00000000 ); |
|
72 |
if( ptr[ ISI_HEADER_OFFSET_RESOURCEID ] == PN_PREFIX ) |
|
73 |
{ |
|
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
74 |
TRACE_ASSERT_ALWAYS;// indications PN_PREFIX defined to PN_COMMGR see iscnokiadefinitions.h |
0 | 75 |
C_TRACE( ( _T( "DIndicationHandler::Multicast PN_PREFIX 0x%x" ), &aIndication ) ); |
76 |
OstTrace1( TRACE_NORMAL, DINDICATIONHANDLER_MULTICAST_PN_PREFIX, "DIndicationHandler::Multicast extended resource;aIndication=%x", (TUint)&(aIndication) ); |
|
77 |
||
78 |
ASSERT_RESET_ALWAYS( aIndication.Length() > KPnMsgExtendedType , EIADOverTheLimits | EIADFaultIdentifier40 << KFaultIdentifierShift ); |
|
79 |
resourceId = ( ptr [ KPnMsgExtendedSubType ] << 16 ) + ( ptr [ KPnMsgExtendedType ] << 8 ) + ( PN_PREFIX ); |
|
80 |
} |
|
81 |
else |
|
82 |
{ |
|
83 |
ASSERT_RESET_ALWAYS( aIndication.Length() > ISI_HEADER_OFFSET_RESOURCEID , EIADOverTheLimits | EIADFaultIdentifier41 << KFaultIdentifierShift ); |
|
84 |
resourceId = ptr[ ISI_HEADER_OFFSET_RESOURCEID ]; |
|
85 |
} |
|
86 |
TServerIdLink* serverLink = GetServerLink( resourceId ); |
|
87 |
TIndicationLink* indicationLink = NULL; |
|
88 |
TSubscriberLink* subscriberLink = NULL; |
|
89 |
||
90 |
if( serverLink ) |
|
91 |
{ |
|
92 |
indicationLink = GetIndicationLink( *serverLink, ptr[ ISI_HEADER_OFFSET_MESSAGEID ] ); |
|
93 |
} |
|
94 |
if( indicationLink ) |
|
95 |
{ |
|
96 |
SDblQueLink* subscriberAnchor = NULL; |
|
97 |
SDblQueLink* subscriberNext = NULL; |
|
98 |
subscriberAnchor = &indicationLink->iSubscriberQ.iA; |
|
99 |
subscriberNext = subscriberAnchor->iNext; |
|
100 |
while( subscriberAnchor != subscriberNext) |
|
101 |
{ |
|
102 |
subscriberLink = _LOFF( subscriberNext, TSubscriberLink, iSubscriberLink ); |
|
103 |
C_TRACE( ( _T("DIndicationHandler::Multicast Subscriber channel: 0x%x"), subscriberLink->iChannelId )); |
|
104 |
// Make a copy to another subscriber |
|
105 |
TDes8& tempPtr = iRouter.AllocateBlock( aIndication.Length() ); |
|
106 |
tempPtr.Copy( ptr, aIndication.Length() ); |
|
107 |
TUint8* ptr = const_cast<TUint8*>( tempPtr.Ptr() ); |
|
108 |
SET_RECEIVER_OBJ( ptr, subscriberLink->iChannelId ); |
|
109 |
ASSERT_RESET_ALWAYS( subscriberLink->iChannelId != KIADEventSubscriptionObjId, 0 ); |
|
110 |
iRouter.CheckRouting( iRouter, tempPtr ); |
|
111 |
subscriberNext = subscriberNext->iNext; |
|
112 |
} |
|
113 |
} |
|
114 |
C_TRACE( ( _T( "DIndicationHandler::Multicast 0x%x <-" ), &aIndication ) ); |
|
115 |
OstTrace0( TRACE_NORMAL, DINDICATIONHANDLER_MULTICAST_EXIT, "<DIndicationHandler::Multicast" ); |
|
116 |
} |
|
117 |
||
118 |
TInt DIndicationHandler::Subscribe( |
|
119 |
TDes8& anOrder, |
|
120 |
const TUint16 aCh, |
|
121 |
const TBool a32BitResource |
|
122 |
) |
|
123 |
{ |
|
124 |
OstTraceExt3( TRACE_NORMAL, DINDICATIONHANDLER_SUBSCRIBE_ENTRY, ">DIndicationHandler::Subscribe;anOrder=%x;aCh=%hx;a32BitResource=%d", ( TUint )&( anOrder ), aCh, a32BitResource ); |
|
125 |
||
126 |
C_TRACE( ( _T( "DIndicationHandler::Subscribe 0x%x ->" ), aCh ) ); |
|
127 |
RemoveSubscription( aCh ); |
|
128 |
TInt eventTableLength( anOrder.Length() ); |
|
129 |
TUint32 resourceId( 0x00000000 ); |
|
130 |
TUint8 extendedLength( a32BitResource ? 0x03 : 0x00 ); |
|
131 |
TUint8* orderPtr( const_cast<TUint8*>( anOrder.Ptr() ) ); |
|
132 |
||
133 |
TInt remove( 0 ); |
|
134 |
// Deorder of indication 8-bit { 0x00, 0x00 } and 32-bit { 0x00, 0x00, 0x00, 0x00, 0x00 } |
|
135 |
for( TInt i( 0 ); i < eventTableLength; ++i ) |
|
136 |
{ |
|
137 |
remove += ( orderPtr[ i ] == 0x00 ? 1 : 0 ); |
|
138 |
} |
|
139 |
eventTableLength = ( eventTableLength == remove ? 0 : eventTableLength ); |
|
140 |
C_TRACE( ( _T( "DIndicationHandler::Subscribe 0x%x length %d 32-bit %d" ), aCh, eventTableLength, a32BitResource ) ); |
|
141 |
||
142 |
OstTraceExt4( TRACE_NORMAL, DINDICATIONHANDLER_SUBSCRIBE, "DIndicationHandler::Subscribe;anOrder=%x;aCh=%hx;a32BitResource=%d;eventTableLength=%hhu", ( TUint )&( anOrder ), aCh, a32BitResource, eventTableLength ); |
|
143 |
||
144 |
||
145 |
/* |
|
146 |
for( TInt i( 0 ); i < anOrder.Length(); i++ ) |
|
147 |
{ |
|
148 |
Kern::Printf( "subscribe order[%d]0x%x", i, anOrder.Ptr()[ i ] ); |
|
149 |
} |
|
150 |
*/ |
|
151 |
||
152 |
for( TInt i( 0 ); i < eventTableLength; i += ( 2 + extendedLength ) ) |
|
153 |
{ |
|
154 |
if( a32BitResource ) |
|
155 |
{ |
|
156 |
ASSERT_RESET_ALWAYS( ( KErrNone == eventTableLength % 5 ), EIADWrongParameter | ( (TUint8)aCh << KChannelNumberShift ) | EIADFaultIdentifier1 << KFaultIdentifierShift ); |
|
157 |
resourceId = orderPtr[ i ] << 24 | orderPtr[ i + 1 ] << 16 | orderPtr[ i + 2 ] << 8 | orderPtr[ i + 3 ]; |
|
158 |
C_TRACE( ( _T("DIndicationHandler::Subscribe 32-bit Channel: 0x%x Server: 0x%x Indication 0x%x"), aCh, resourceId, orderPtr[ i + 4 ] ) ); |
|
159 |
OstTraceExt3( TRACE_DETAILED, DUP1_DINDICATIONHANDLER_SUBSCRIBE_32BIT, "DIndicationHandler::Subscribe 32bit;aCh=%hx;resourceId=%x;indication=%hhx", aCh, resourceId, orderPtr[ i + 4 ] ); |
|
160 |
} |
|
161 |
else |
|
162 |
{ |
|
163 |
ASSERT_RESET_ALWAYS( ( KErrNone == eventTableLength % 2 ), EIADWrongParameter | ( (TUint8)aCh << KChannelNumberShift ) | EIADFaultIdentifier2 << KFaultIdentifierShift ); |
|
164 |
resourceId = orderPtr[ i ]; |
|
165 |
C_TRACE( ( _T("DIndicationHandler::Subscribe Channel: 0x%x Server: 0x%x Indication 0x%x"), aCh, resourceId, orderPtr[ i + 1 ] ) ); |
|
166 |
OstTraceExt3( TRACE_DETAILED, DUP1_DINDICATIONHANDLER_SUBSCRIBE_8BIT, "DIndicationHandler::Subscribe 8bit;aCh=%hx;resourceId=%x;indication=%hhx", aCh, resourceId, orderPtr[ i + 1 ] ); |
|
167 |
} |
|
168 |
// TODO: Ensure that ownership is not given! If given leaks memory below in allocation..! |
|
169 |
TServerIdLink* serverLink = GetServerLink( resourceId ); |
|
170 |
if( !serverLink ) |
|
171 |
{ |
|
172 |
C_TRACE( ( _T("DIndicationHandler::Subscribe ServerIdLink not found yet -> create: 0x%x"), resourceId ) ); |
|
173 |
OstTrace1( TRACE_DETAILED, DINDICATIONHANDLER_SUBSCRIBE_SERVERLINK, "DIndicationHandler::Subscribe serverlink not yet created;resourceId=%x", resourceId ); |
|
174 |
||
175 |
serverLink = new TServerIdLink(); |
|
176 |
ASSERT_RESET_ALWAYS( serverLink, EIADMemoryAllocationFailure | EIADFaultIdentifier1 << KFaultIdentifierShift ); |
|
177 |
serverLink->iResourceId = resourceId; |
|
178 |
iServerQ.Add( &( serverLink->iServerLink ) ); |
|
179 |
} |
|
180 |
AddIndication( *serverLink, orderPtr[ i + ( 1 + extendedLength ) ], aCh ); |
|
181 |
} |
|
182 |
||
183 |
#ifdef _DEBUG |
|
184 |
#ifdef COMPONENT_TRACE |
|
185 |
PrintSubscriptions(); |
|
186 |
#endif // COMPONENT_TRACE |
|
187 |
#endif // _DEBUG |
|
188 |
C_TRACE( ( _T( "DIndicationHandler::Subscribe 0x%x <-" ), aCh ) ); |
|
189 |
TInt error = SendSubscription(); |
|
190 |
||
191 |
||
192 |
OstTrace1( TRACE_NORMAL, DUP1_DINDICATIONHANDLER_SUBSCRIBE, "DIndicationHandler::Subscribe<;error=%d", error ); |
|
193 |
return error; |
|
194 |
} |
|
195 |
||
196 |
void DIndicationHandler::AddIndication( |
|
197 |
TServerIdLink& aServerLink, |
|
198 |
const TUint8 aIndication, |
|
199 |
const TUint16 aCh |
|
200 |
) |
|
201 |
{ |
|
202 |
OstTraceExt3( TRACE_NORMAL, DINDICATIONHANDLER_ADDINDICATION_ENTRY, ">DIndicationHandler::AddIndication;aServerLink=%x;aIndication=%hhu;aCh=%hx", ( TUint )&( aServerLink ), aIndication, aCh ); |
|
203 |
||
204 |
C_TRACE( ( _T( "DIndicationHandler::AddIndication 0x%x 0x%x ->" ), aIndication, aCh ) ); |
|
205 |
||
206 |
// TODO: ownership given or not? |
|
207 |
TIndicationLink* indicationLink = GetIndicationLink( aServerLink, aIndication ); |
|
208 |
if( !indicationLink ) |
|
209 |
{ |
|
210 |
C_TRACE( ( _T("DIndicationHandler::AddIndication Indication: 0x%x not found, create"), aIndication )); |
|
211 |
OstTraceExt1( TRACE_NORMAL, DINDICATIONHANDLER_ADDINDICATION, "DIndicationHandler::AddIndication indicationLink not found -> create;aIndication=%hhx", aIndication ); |
|
212 |
||
213 |
indicationLink = new TIndicationLink(); |
|
214 |
ASSERT_RESET_ALWAYS( indicationLink, EIADMemoryAllocationFailure | EIADFaultIdentifier2 << KFaultIdentifierShift ); |
|
215 |
indicationLink->iIndication = aIndication; |
|
216 |
aServerLink.iIndicationQ.Add( &( indicationLink->iIndicationLink ) ); |
|
217 |
} |
|
218 |
AddSubscriber( *indicationLink, aCh ); |
|
219 |
C_TRACE( ( _T( "DIndicationHandler::AddIndication 0x%x 0x%x <-" ), aIndication, aCh ) ); |
|
220 |
||
221 |
OstTrace0( TRACE_NORMAL, DINDICATIONHANDLER_ADDINDICATION_EXIT, "<DIndicationHandler::AddIndication" ); |
|
222 |
} |
|
223 |
||
224 |
void DIndicationHandler::AddSubscriber( |
|
225 |
TIndicationLink& aIndicationLink, |
|
226 |
const TUint16 aCh |
|
227 |
) |
|
228 |
{ |
|
229 |
OstTraceExt2( TRACE_NORMAL, DINDICATIONHANDLER_ADDSUBSCRIBER_ENTRY, ">DIndicationHandler::AddSubscriber;aIndicationLink=%x;aCh=%hx", ( TUint )&( aIndicationLink ), aCh ); |
|
230 |
||
231 |
C_TRACE( ( _T( "DIndicationHandler::AddSubscriber 0x%x, 0x%x ->" ), &aIndicationLink, aCh ) ); |
|
232 |
TSubscriberLink* subscriberLink = GetSubscriberLink( aIndicationLink, aCh ); |
|
233 |
if( !subscriberLink ) |
|
234 |
{ |
|
235 |
C_TRACE( ( _T("DIndicationHandler::AddSubscriber Subscriber not found: 0x%x 0x%x"), aIndicationLink.iIndication, aCh ) ); |
|
236 |
OstTraceExt2( TRACE_NORMAL, DINDICATIONHANDLER_ADDSUBSCRIBER, "DIndicationHandler::AddSubscriber subscriber not found -> create;aIndicationLink.iIndication=%hhu;aCh=%hx", aIndicationLink.iIndication, aCh ); |
|
237 |
||
238 |
subscriberLink = new TSubscriberLink(); |
|
239 |
ASSERT_RESET_ALWAYS( subscriberLink, EIADMemoryAllocationFailure | EIADFaultIdentifier3 << KFaultIdentifierShift ); |
|
240 |
subscriberLink->iChannelId = aCh; |
|
241 |
aIndicationLink.iSubscriberQ.Add( &( subscriberLink->iSubscriberLink ) ); |
|
242 |
} |
|
243 |
else |
|
244 |
{ |
|
245 |
TRACE_ASSERT_INFO(0, (TUint8)aCh<<KChannelNumberShift); |
|
246 |
C_TRACE( ( _T( "DIndicationHandler::AddSubscriber double subscription 0x%x" ), aCh ) ); |
|
247 |
OstTraceExt1( TRACE_NORMAL, DINDICATIONHANDLER_ADDSUBSCRIBER_DOUBLE_SUB, "DIndicationHandler::AddSubscriber double subscription;aCh=%hx", aCh ); |
|
248 |
} |
|
249 |
C_TRACE( ( _T( "DIscIsiEventHandler::AddSubscriber <-" ) ) ); |
|
250 |
||
251 |
OstTrace0( TRACE_NORMAL, DINDICATIONHANDLER_ADDSUBSCRIBER_EXIT, "<DIndicationHandler::AddSubscriber" ); |
|
252 |
} |
|
253 |
||
254 |
DIndicationHandler::TServerIdLink* DIndicationHandler::GetServerLink( |
|
255 |
const TUint32 aResourceId |
|
256 |
) |
|
257 |
{ |
|
258 |
OstTrace1( TRACE_NORMAL, DINDICATIONHANDLER_GETSERVERLINK_ENTRY, ">DIndicationHandler::GetServerLink;aResourceId=%u", ( TUint )( aResourceId ) ); |
|
259 |
||
260 |
C_TRACE( ( _T( "DIndicationHandler::GetServerLink 0x%x ->" ), aResourceId ) ); |
|
261 |
||
262 |
TServerIdLink* serverLink = NULL; |
|
263 |
TServerIdLink* tmpServerLink = NULL; |
|
264 |
SDblQueLink* anchor = &iServerQ.iA; |
|
265 |
SDblQueLink* next = anchor->iNext; |
|
266 |
||
267 |
while( anchor != next ) // servers |
|
268 |
{ |
|
269 |
tmpServerLink = _LOFF( next, TServerIdLink, iServerLink ); |
|
270 |
C_TRACE( ( _T( "DIndicationHandler::GetServerLink Server: 0x%x"), tmpServerLink->iResourceId ) ); |
|
271 |
OstTrace1( TRACE_DETAILED, DINDICATIONHANDLER_GETSERVERLINK, "DIndicationHandler::GetServerLink;tmpServerLink->iResourceId=%u", ( TUint )( tmpServerLink->iResourceId ) ); |
|
272 |
if( tmpServerLink->iResourceId == aResourceId ) |
|
273 |
{ |
|
274 |
serverLink = tmpServerLink; |
|
275 |
break; |
|
276 |
} |
|
277 |
next = next->iNext; |
|
278 |
} |
|
279 |
C_TRACE( ( _T( "DIndicationHandler::GetServerLink 0x%x <-" ), serverLink ) ); |
|
280 |
||
281 |
OstTrace1( TRACE_NORMAL, DINDICATIONHANDLER_GETSERVERLINK_EXIT, "DIndicationHandler::GetServerLink<;serverLink=%x", serverLink ); |
|
282 |
return serverLink; |
|
283 |
} |
|
284 |
||
285 |
DIndicationHandler::TIndicationLink* DIndicationHandler::GetIndicationLink( |
|
286 |
TServerIdLink& aServerLink, |
|
287 |
const TUint8 aIndication |
|
288 |
) |
|
289 |
{ |
|
290 |
OstTraceExt2( TRACE_NORMAL, DINDICATIONHANDLER_GETINDICATIONLINK_ENTRY, ">DIndicationHandler::GetIndicationLink;aServerLink=%x;aIndication=%hhu", ( TUint )&( aServerLink ), aIndication ); |
|
291 |
||
292 |
C_TRACE( ( _T( "DIndicationHandler::GetIndicationLink 0x%x ->" ), aIndication ) ); |
|
293 |
TIndicationLink* indicationLink = NULL; |
|
294 |
TIndicationLink* tmpIndicationLink = NULL; |
|
295 |
||
296 |
SDblQueLink* anchor = &aServerLink.iIndicationQ.iA; |
|
297 |
SDblQueLink* next = anchor->iNext; |
|
298 |
||
299 |
while( anchor != next ) |
|
300 |
{ |
|
301 |
tmpIndicationLink = _LOFF( next, TIndicationLink, iIndicationLink ); |
|
302 |
if( tmpIndicationLink->iIndication == aIndication ) |
|
303 |
{ |
|
304 |
indicationLink = tmpIndicationLink; |
|
305 |
break; |
|
306 |
} |
|
307 |
next = next->iNext; |
|
308 |
} |
|
309 |
C_TRACE( ( _T( "DIndicationHandler::GetIndicationLink 0x%x <-" ), indicationLink ) ); |
|
310 |
||
311 |
||
312 |
OstTrace1( TRACE_NORMAL, DINDICATIONHANDLER_GETINDICATIONLINK_EXIT, "<DIndicationHandler::GetIndicationLink;indicationLink=%x", indicationLink ); |
|
313 |
return indicationLink; |
|
314 |
} |
|
315 |
||
316 |
DIndicationHandler::TSubscriberLink* DIndicationHandler::GetSubscriberLink( |
|
317 |
TIndicationLink& aIndicationLink, |
|
318 |
const TUint16 aCh |
|
319 |
) |
|
320 |
{ |
|
321 |
OstTraceExt2( TRACE_NORMAL, DINDICATIONHANDLER_GETSUBSCRIBERLINK_ENTRY, ">DIndicationHandler::GetSubscriberLink;aIndicationLink=%x;aCh=%hx", ( TUint )&( aIndicationLink ), aCh ); |
|
322 |
||
323 |
C_TRACE( ( _T( "DIndicationHandler::GetSubscriberLink 0x%x, 0x%x ->" ), &aIndicationLink, aCh ) ); |
|
324 |
TSubscriberLink* tmpSubscriberLink = NULL; |
|
325 |
TSubscriberLink* subscriberLink = NULL; |
|
326 |
||
327 |
SDblQueLink* anchor = &aIndicationLink.iSubscriberQ.iA; |
|
328 |
SDblQueLink* next = anchor->iNext; |
|
329 |
||
330 |
while( anchor != next ) |
|
331 |
{ |
|
332 |
tmpSubscriberLink= _LOFF( next, TSubscriberLink, iSubscriberLink ); |
|
333 |
if ( tmpSubscriberLink->iChannelId == aCh ) |
|
334 |
{ |
|
335 |
subscriberLink = tmpSubscriberLink; |
|
336 |
break; |
|
337 |
} |
|
338 |
next = next->iNext; |
|
339 |
} |
|
340 |
||
341 |
C_TRACE( ( _T( "DIndicationHandler::GetSubscriberLink 0x%x <-" ), subscriberLink ) ); |
|
342 |
||
343 |
OstTrace1( TRACE_NORMAL, DINDICATIONHANDLER_GETSUBSCRIBERLINK_EXIT, "<DIndicationHandler::GetSubscriberLink;subscriberLink=%x", subscriberLink ); |
|
344 |
return subscriberLink; |
|
345 |
} |
|
346 |
||
347 |
void DIndicationHandler::PrintSubscriptions( |
|
348 |
// None |
|
349 |
) |
|
350 |
{ |
|
351 |
OstTrace0( TRACE_NORMAL, DINDICATIONHANDLER_PRINTSUBSCRIPTIONS_ENTRY, ">DIndicationHandler::PrintSubscriptions" ); |
|
352 |
||
353 |
C_TRACE( ( _T( "DIndicationHandler::PrintSubscriptions ->" ) ) ); |
|
354 |
TServerIdLink* serverLink = NULL;//_LOFF(listElement, TServerIdLink, iServerLink); |
|
355 |
SDblQueLink* anchor = &iServerQ.iA; |
|
356 |
SDblQueLink* next = anchor->iNext; |
|
357 |
SDblQueLink* indicationAnchor = NULL; |
|
358 |
SDblQueLink* indicationNext = NULL; |
|
359 |
TIndicationLink* indicationLink = NULL; |
|
360 |
SDblQueLink* subscriberAnchor = NULL; |
|
361 |
SDblQueLink* subscriberNext = NULL; |
|
362 |
TSubscriberLink* subscriberLink = NULL; |
|
363 |
while( anchor != next ) // servers |
|
364 |
{ |
|
365 |
serverLink = _LOFF( next, TServerIdLink, iServerLink ); |
|
366 |
C_TRACE( ( _T("DIndicationHandler::PrintSubscriptions Server: 0x%x"), serverLink->iResourceId)); |
|
367 |
OstTrace1( TRACE_DETAILED, DINDICATIONHANDLER_PRINTSUBSCRIPTIONS, "DIndicationHandler::PrintSubscriptions;resource=%x", (TUint)(serverLink->iResourceId) );// todo check these prints |
|
368 |
||
369 |
indicationAnchor = &serverLink->iIndicationQ.iA; |
|
370 |
indicationNext = indicationAnchor->iNext; |
|
371 |
while( indicationAnchor != indicationNext ) |
|
372 |
{ |
|
373 |
indicationLink = _LOFF( indicationNext, TIndicationLink, iIndicationLink ); |
|
374 |
C_TRACE( ( _T("DIndicationHandler::PrintSubscriptions Indication: 0x%x"), indicationLink->iIndication ) ); |
|
375 |
OstTraceExt1( TRACE_DETAILED, DINDICATIONHANDLER_PRINTSUBSCRIPTIONS_INDICATION, "DIndicationHandler::PrintSubscriptions;indication=%hhx", indicationLink->iIndication ); |
|
376 |
||
377 |
subscriberAnchor = &indicationLink->iSubscriberQ.iA; |
|
378 |
subscriberNext = subscriberAnchor->iNext; |
|
379 |
while( subscriberAnchor != subscriberNext) |
|
380 |
{ |
|
381 |
subscriberLink = _LOFF( subscriberNext, TSubscriberLink, iSubscriberLink ); |
|
382 |
subscriberLink = subscriberLink; |
|
383 |
C_TRACE( ( _T("DIndicationHandler::PrintSubscriptions Channel: 0x%x"), subscriberLink->iChannelId ) ); |
|
384 |
OstTraceExt1( TRACE_DETAILED, DUP1_DINDICATIONHANDLER_PRINTSUBSCRIPTIONS_CHANNEL, "DIndicationHandler::PrintSubscriptions;subscriberLink->iChannelId=%hx", subscriberLink->iChannelId ); |
|
385 |
||
386 |
subscriberNext = subscriberNext->iNext; |
|
387 |
} |
|
388 |
indicationNext = indicationNext->iNext; |
|
389 |
} |
|
390 |
next = next->iNext; |
|
391 |
} |
|
392 |
C_TRACE( ( _T( "DIndicationHandler::PrintSubscriptions <-" ) ) ); |
|
393 |
||
394 |
OstTrace0( TRACE_DETAILED, DUP1_DINDICATIONHANDLER_PRINTSUBSCRIPTIONS_EXIT, "<DIndicationHandler::PrintSubscriptions" ); |
|
395 |
} |
|
396 |
||
397 |
||
398 |
void DIndicationHandler::RemoveSubscription( |
|
399 |
const TUint16 aCh |
|
400 |
) |
|
401 |
{ |
|
402 |
OstTraceExt1( TRACE_NORMAL, DINDICATIONHANDLER_REMOVESUBSCRIPTION_ENTRY, ">DIndicationHandler::RemoveSubscription;aCh=%hx", aCh ); |
|
403 |
||
404 |
C_TRACE( ( _T( "DIndicationHandler::RemoveSubscription 0x%x ->" ), aCh ) ); |
|
405 |
// enter semaphore |
|
406 |
||
407 |
SDblQueLink* serverAnchor = &iServerQ.iA; |
|
408 |
SDblQueLink* next = serverAnchor->iNext; |
|
409 |
TServerIdLink* serverLink = NULL; |
|
410 |
||
411 |
SDblQueLink* indicationAnchor = NULL; |
|
412 |
SDblQueLink* indicationNext = NULL; |
|
413 |
TIndicationLink* indicationLink = NULL; |
|
414 |
||
415 |
SDblQueLink* subscriberAnchor = NULL; |
|
416 |
SDblQueLink* subscriberNext = NULL; |
|
417 |
TSubscriberLink* subscriberLink = NULL; |
|
418 |
||
419 |
while( serverAnchor != next ) // servers |
|
420 |
{ |
|
421 |
serverLink = _LOFF( next, TServerIdLink, iServerLink ); |
|
422 |
C_TRACE( ( _T("DIndicationHandler::RemoveSubscription Server: 0x%x"), serverLink->iResourceId ) ); |
|
423 |
OstTrace1( TRACE_NORMAL, DINDICATIONHANDLER_REMOVESUBSCRIPTION, "DIndicationHandler::RemoveSubscription;resource=%x", serverLink->iResourceId ); |
|
424 |
||
425 |
indicationAnchor = &serverLink->iIndicationQ.iA; |
|
426 |
indicationNext = indicationAnchor->iNext; |
|
427 |
while( indicationAnchor != indicationNext ) |
|
428 |
{ |
|
429 |
indicationLink = _LOFF( indicationNext, TIndicationLink, iIndicationLink ); |
|
430 |
// get next link already in case if particular link is to be deleted |
|
431 |
indicationNext = indicationNext->iNext; |
|
432 |
subscriberAnchor = &indicationLink->iSubscriberQ.iA; |
|
433 |
subscriberNext = subscriberAnchor->iNext; |
|
434 |
while( subscriberAnchor != subscriberNext ) |
|
435 |
{ |
|
436 |
subscriberLink = _LOFF( subscriberNext, TSubscriberLink, iSubscriberLink ); |
|
437 |
C_TRACE( ( _T("DIndicationHandler::RemoveSubscription Subscriber channel: 0x%x"), subscriberLink->iChannelId )); |
|
438 |
OstTraceExt1( TRACE_NORMAL, DUP1_DINDICATIONHANDLER_REMOVESUBSCRIPTION_CHANNEL, "DIndicationHandler::RemoveSubscription;channelId=%hx", subscriberLink->iChannelId ); |
|
439 |
||
440 |
if( subscriberLink->iChannelId == aCh ) |
|
441 |
{ |
|
442 |
TBool onlySubscriber( subscriberLink->iSubscriberLink.Alone() ); |
|
443 |
subscriberLink->iSubscriberLink.Deque(); |
|
444 |
delete subscriberLink; |
|
445 |
subscriberLink = NULL; |
|
446 |
if( onlySubscriber ) |
|
447 |
{ |
|
448 |
indicationLink->iIndicationLink.Deque(); |
|
449 |
delete indicationLink; |
|
450 |
indicationLink = NULL; |
|
451 |
} |
|
452 |
// No need to go through rest of subscriberlinks since this one already found and deleted |
|
453 |
subscriberNext = subscriberAnchor; |
|
454 |
} |
|
455 |
else |
|
456 |
{ |
|
457 |
subscriberNext = subscriberNext->iNext; |
|
458 |
} |
|
459 |
} |
|
460 |
} |
|
461 |
indicationAnchor = &serverLink->iIndicationQ.iA; |
|
462 |
indicationNext = indicationAnchor->iNext; |
|
463 |
next = next->iNext; |
|
464 |
if( indicationAnchor == indicationNext ) |
|
465 |
{ |
|
466 |
// No more indications for the server -> server link can be deleted |
|
467 |
serverLink->iServerLink.Deque(); |
|
468 |
delete serverLink; |
|
469 |
serverLink = NULL; |
|
470 |
} |
|
471 |
} |
|
472 |
// exit semaphore |
|
473 |
C_TRACE( ( _T( "DIndicationHandler::RemoveSubscription 0x%x <-" ), aCh ) ); |
|
474 |
||
475 |
OstTraceExt1( TRACE_NORMAL, DINDICATIONHANDLER_REMOVESUBSCRIPTION_EXIT, "<DIndicationHandler::RemoveSubscription;aCh=%hx", aCh ); |
|
476 |
} |
|
477 |
||
478 |
||
479 |
TInt DIndicationHandler::SendSubscription( |
|
480 |
// None |
|
481 |
) |
|
482 |
{ |
|
483 |
OstTrace0( TRACE_NORMAL, DINDICATIONHANDLER_SENDSUBSCRIPTION_ENTRY, ">DIndicationHandler::SendSubscription" ); |
|
484 |
||
485 |
C_TRACE( ( _T( "DIndicationHandler::SendSubscription ->" ) ) ); |
|
486 |
const TInt KSubsriptionLength( 512 ); |
|
487 |
const TUint8 KPnsSubscribedResourcesExtendLength( 12 ); |
|
488 |
const TUint8 KIADEventSubscriptionObjId( 0xfc ); |
|
489 |
// TODO: Assertion to somewhere else? |
|
490 |
TDes8& desPtr = iRouter.AllocateBlock( KSubsriptionLength ); |
|
491 |
ASSERT_RESET_ALWAYS( KSubsriptionLength > ( ISI_HEADER_SIZE + PNS_SUBSCRIBED_RESOURCES_EXTEND_IND_OFFSET_RESOURCECOUNT ) , EIADOverTheLimits | EIADFaultIdentifier42 << KFaultIdentifierShift ); |
|
492 |
||
493 |
TUint8* ptr( const_cast<TUint8*>( desPtr.Ptr() ) ); |
|
494 |
ptr[ ISI_HEADER_OFFSET_MEDIA ] = PN_MEDIA_MODEM_HOST_IF; |
|
495 |
SET_RECEIVER_DEV( ptr, OTHER_DEVICE_1 ); |
|
496 |
SET_SENDER_DEV( ptr, THIS_DEVICE ); |
|
497 |
ptr[ ISI_HEADER_OFFSET_RESOURCEID ] = PN_COMMGR; |
|
498 |
SET_RECEIVER_OBJ( ptr, PN_OBJ_ROUTER ); |
|
499 |
||
500 |
SET_SENDER_OBJ( ptr, KIADEventSubscriptionObjId ); |
|
501 |
ptr[ ISI_HEADER_SIZE + PNS_SUBSCRIBED_RESOURCES_EXTEND_IND_OFFSET_TRANSACTIONID ] = 0x00; |
|
502 |
ptr[ ISI_HEADER_SIZE + PNS_SUBSCRIBED_RESOURCES_EXTEND_IND_OFFSET_MESSAGEID ] = PNS_SUBSCRIBED_RESOURCES_EXTEND_IND; |
|
503 |
desPtr.SetLength( KPnsSubscribedResourcesExtendLength ); |
|
504 |
||
505 |
TServerIdLink* serverLink = NULL; |
|
506 |
SDblQueLink* anchor = &iServerQ.iA; |
|
507 |
SDblQueLink* next = anchor->iNext; |
|
508 |
||
509 |
TUint8 serverIndex( 0x00 ); |
|
510 |
TUint8 resourceCount( 0x00 ); |
|
511 |
while( anchor != next ) // servers |
|
512 |
{ |
|
513 |
serverLink = _LOFF( next, TServerIdLink, iServerLink ); |
|
514 |
TUint32 resourceId = serverLink->iResourceId; |
|
515 |
C_TRACE( ( _T("DIndicationHandler::SendSubscription Server: 0x%08x"), resourceId ) ); |
|
516 |
OstTrace1( TRACE_DETAILED, DINDICATIONHANDLER_SENDSUBSCRIPTION, "DIndicationHandler::SendSubscription;resourceId=%x", resourceId ); |
|
517 |
||
518 |
desPtr.Append( static_cast<TUint8>( resourceId >> 24 ) ); |
|
519 |
desPtr.Append( static_cast<TUint8>( resourceId >> 16 ) ); |
|
520 |
desPtr.Append( static_cast<TUint8>( resourceId >> 8 ) ); |
|
521 |
desPtr.Append( static_cast<TUint8>( resourceId ) ); |
|
522 |
resourceCount++; |
|
523 |
next = next->iNext; |
|
524 |
serverIndex++; |
|
525 |
} |
|
526 |
ptr[ ISI_HEADER_SIZE + PNS_SUBSCRIBED_RESOURCES_EXTEND_IND_OFFSET_RESOURCECOUNT ] = resourceCount; |
|
527 |
||
528 |
TInt messageLength( ( resourceCount * 4 ) + KPnsSubscribedResourcesExtendLength ); |
|
529 |
while( messageLength % 4 != 0 ) |
|
530 |
{ |
|
531 |
TRACE_ASSERT_ALWAYS; |
|
532 |
messageLength++; |
|
533 |
} |
|
534 |
// TODO : does this work? setting of length after append? |
|
535 |
desPtr.SetLength( messageLength ); |
|
536 |
SET_LENGTH( ptr, messageLength - PN_HEADER_SIZE ); |
|
537 |
C_TRACE( ( _T( "DIndicationHandler::SendSubscription <-" ) ) ); |
|
538 |
TInt error = iRouter.SendMessage( desPtr, KIADEventSubscriptionObjId ); |
|
539 |
||
540 |
OstTrace1( TRACE_DETAILED, DINDICATIONHANDLER_SENDSUBSCRIPTION_EXIT, "<DIndicationHandler::SendSubscription<;error=%d", error ); |
|
541 |
return error; |
|
542 |
} |
|
543 |
||
544 |
||
545 |
// End of file. |
|
546 |
||
547 |