|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file SS_NODEINTERFACES.CPP |
|
18 */ |
|
19 |
|
20 #include <comms-infras/ss_log.h> |
|
21 #include <comms-infras/ss_dispatchers.h> |
|
22 #include <comms-infras/ss_nodemessages.h> |
|
23 #include <comms-infras/ss_api_ext.h> |
|
24 #include <elements/interfacetable.h> |
|
25 #include <elements/metatype.h> |
|
26 |
|
27 |
|
28 #ifdef _DEBUG |
|
29 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module |
|
30 // (if it could happen through user error then you should give it an explicit, documented, category + code) |
|
31 _LIT(KSpecAssert_ESockSSocksndntr, "ESockSSocksndntr"); |
|
32 #endif |
|
33 |
|
34 using namespace ESock; |
|
35 using namespace Messages; |
|
36 using namespace MeshMachine; |
|
37 |
|
38 EXPORT_C void TCFItfExt::ForwardMessageL(const TRuntimeCtxId& aSender, |
|
39 TSignalBase& aMessage, |
|
40 Messages::ANode& aNode, |
|
41 const TClientType& aClientType, |
|
42 const TClientType& aClientTypeExclude) |
|
43 { |
|
44 NetInterfaces::TInterfaceControl* ic = NULL; |
|
45 ic = aNode.FetchNodeInterfaceControlL(AMMNodeBase::KInterfaceId); |
|
46 MeshMachine::AMMNodeBase* nodeBase = reinterpret_cast<MeshMachine::AMMNodeBase*>(ic->FetchInterfaceL(AMMNodeBase::KInterfaceId)); |
|
47 |
|
48 RNodeInterface* recp; |
|
49 if(aClientType.Type() == TCFClientType::ECtrl) |
|
50 { |
|
51 recp = nodeBase->GetFirstClient<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EServProvider),aClientTypeExclude); |
|
52 } |
|
53 else |
|
54 { |
|
55 recp = nodeBase->GetFirstClient<TDefaultClientMatchPolicy>(TClientType(TCFClientType::ECtrlProvider),aClientTypeExclude); |
|
56 } |
|
57 |
|
58 if(recp) |
|
59 { |
|
60 recp->PostMessage(aSender, aMessage); |
|
61 } |
|
62 else |
|
63 { |
|
64 User::Leave(KErrNotFound); |
|
65 } |
|
66 } |
|
67 |
|
68 |
|
69 EXPORT_C TAny* TCFItfExt::FetchInterfaceL(Messages::ANode& aNode, TInt aInterface) |
|
70 { |
|
71 NetInterfaces::TInterfaceControl* ic = NULL; |
|
72 ic = aNode.FetchNodeInterfaceControlL(aInterface); |
|
73 |
|
74 return ic->FetchInterfaceL(aInterface); |
|
75 } |
|
76 |
|
77 |
|
78 EXPORT_C TAny* TCFItfExt::FetchInterfaceOrForwardMsgL(const TRuntimeCtxId& aSender, |
|
79 TSignalBase& aMessage, |
|
80 Messages::ANode& aNode, |
|
81 TInt aInterface, |
|
82 const TClientType& aClientType, |
|
83 const TClientType& aClientTypeExclude) |
|
84 { |
|
85 TAny* itf = NULL; |
|
86 TRAPD(ret, itf = FetchInterfaceL(aNode, aInterface)); |
|
87 |
|
88 switch(ret) |
|
89 { |
|
90 case KErrNone: |
|
91 return itf; |
|
92 |
|
93 case KErrInterfaceNotSupported: |
|
94 ForwardMessageL(aSender, aMessage, aNode, aClientType, aClientTypeExclude); |
|
95 break; |
|
96 |
|
97 default: |
|
98 __ASSERT_DEBUG(EFalse, User::Panic(KSpecAssert_ESockSSocksndntr, 1)); //unreachable |
|
99 User::Leave(ret); |
|
100 break; |
|
101 } |
|
102 |
|
103 //Never gets here |
|
104 return NULL; |
|
105 } |
|
106 |
|
107 |
|
108 EXPORT_C NetInterfaces::TInterfaceControl* TCFItfExt::FetchInterfaceControlOrForwardMsgL(const TRuntimeCtxId& aSender, |
|
109 TSignalBase& aMessage, |
|
110 Messages::ANode& aNode, |
|
111 TInt aInterface, |
|
112 const TClientType& aClientType, |
|
113 const TClientType& aClientTypeExclude) |
|
114 { |
|
115 NetInterfaces::TInterfaceControl* ic = NULL; |
|
116 TRAPD(ret, ic = aNode.FetchNodeInterfaceControlL(aInterface)); |
|
117 |
|
118 switch(ret) |
|
119 { |
|
120 case KErrNone: |
|
121 return ic; |
|
122 |
|
123 case KErrInterfaceNotSupported: |
|
124 ForwardMessageL(aSender, aMessage, aNode, aClientType, aClientTypeExclude); |
|
125 break; |
|
126 |
|
127 default: |
|
128 User::Leave(ret); |
|
129 __ASSERT_DEBUG(EFalse, User::Panic(KSpecAssert_ESockSSocksndntr, 2)); //unreachable |
|
130 break; |
|
131 } |
|
132 |
|
133 //Never gets here |
|
134 return NULL; |
|
135 } |
|
136 |
|
137 EXPORT_C void TCFSigRMessage2Ext::Error(const TRuntimeCtxId& /*aSender*/, const TRuntimeCtxId& /*aRecipient*/, TInt aError) |
|
138 { |
|
139 LOG( ESockLog::Printf(KESockDCMsgs, _L8( "TCFSigRMessage2Ext:\tError(): completing message (%08X) with %d" ), |
|
140 iMessage.Handle(), aError) ); |
|
141 |
|
142 if ( !iMessage.IsNull() ) |
|
143 { |
|
144 iMessage.Complete(aError); |
|
145 } |
|
146 } |
|
147 |
|
148 EXPORT_START_ATTRIBUTE_TABLE_AND_FN( TCFSigRMessage2Ext, 0, 0 ) //has to be derived from |
|
149 REGISTER_ATTRIBUTE( TCFSigRMessage2Ext, iMessage, TMeta<RMessage2> ) |
|
150 END_ATTRIBUTE_TABLE_BASE(TSignalBase, 0) |
|
151 |
|
152 |