|
1 // Copyright (c) 2004-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_CONNPROV.CPP |
|
18 */ |
|
19 |
|
20 #include <ss_std.h> |
|
21 #include <comms-infras/esockmessages.h> |
|
22 #include <comms-infras/ss_log.h> |
|
23 #include <es_ini.h> |
|
24 #include <ss_glob.h> |
|
25 #include "ss_connprov.h" |
|
26 #include <comms-infras/ss_nodemessages_factory.h> |
|
27 |
|
28 #include <elements/nm_signatures.h> |
|
29 #include <comms-infras/ss_nodemessages_legacy.h> |
|
30 |
|
31 #include <comms-infras/ss_commsprov.h> |
|
32 using namespace ESock; |
|
33 |
|
34 #ifdef _DEBUG |
|
35 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module |
|
36 // (if it could happen through user error then you should give it an explicit, documented, category + code) |
|
37 _LIT(KSpecAssert_ESockSSockscnprv, "ESockSSockscnprv"); |
|
38 #endif |
|
39 |
|
40 using namespace Messages; |
|
41 using namespace Factories; |
|
42 |
|
43 TConnectionInfo::TConnectionInfo(const TDesC8& /*aConnectionInfo*/ /*as passed to ::Bearer/::NoBearer*/) |
|
44 { |
|
45 } |
|
46 |
|
47 TBool TConnectionInfo::IsLocalBearer(const TDesC8& aConnectionInfo) |
|
48 { |
|
49 __ASSERT_DEBUG(aConnectionInfo.Length() >= KConnInfoPart, User::Panic(KSpecAssert_ESockSSockscnprv, 1)); |
|
50 |
|
51 TConnectionInfo info(0,0); |
|
52 TPckg<TConnectionInfo> infoBuf(info); |
|
53 |
|
54 return (infoBuf.Right(KConnInfoPart) == aConnectionInfo.Right(KConnInfoPart)); |
|
55 } |
|
56 |
|
57 EXPORT_C MFactoryQuery::TMatchResult XConnectionProviderInfoQuery::Match(TFactoryObjectInfo& aProviderInfo) |
|
58 { |
|
59 CConnectionProviderBase* prov = static_cast<CConnectionProviderBase*>(aProviderInfo.iInfo.iFactoryObject); |
|
60 const TProviderInfo& thePI = static_cast<const TProviderInfoExt&>(prov->AccessPointConfig().FindExtensionL( |
|
61 STypeId::CreateSTypeId(TProviderInfoExt::EUid, TProviderInfoExt::ETypeId))).iProviderInfo; |
|
62 TBool isMatch = (thePI.TierId() == iProviderInfo.TierId()) && (thePI.APId() == iProviderInfo.APId()); |
|
63 return (isMatch ? MFactoryQuery::EMatch : MFactoryQuery::EContinue); |
|
64 } |
|
65 |
|
66 |
|
67 EXPORT_C CConnectionFactoryContainer* CConnectionFactoryContainer::NewL() |
|
68 /** Create a new instance of a connection factory container |
|
69 |
|
70 @exception Leaves in out of memory conditions |
|
71 @return Pointer to new instance of a connection factory container |
|
72 */ |
|
73 { |
|
74 TCFLegacyMessage::RegisterL(); |
|
75 return new (ELeave) CConnectionFactoryContainer(); |
|
76 } |
|
77 |
|
78 CConnectionFactoryContainer::~CConnectionFactoryContainer() |
|
79 { |
|
80 TCFLegacyMessage::DeRegister(); |
|
81 |
|
82 LOG_NODE_DESTROY(KESockConnectionTag, CConnectionFactoryContainer); |
|
83 } |
|
84 |
|
85 CConnectionFactoryContainer::CConnectionFactoryContainer() |
|
86 :CCommsFactoryContainer((CCommsFactoryContainer::TContaineeType)CConnectionFactoryContainer::EId) |
|
87 /** Empty connection factory container constructor */ |
|
88 { |
|
89 LOG_NODE_CREATE(KESockConnectionTag, CConnectionFactoryContainer); |
|
90 } |
|
91 |
|
92 |
|
93 CConnectionProviderFactoryBase* CConnectionFactoryContainer::Factory( TInt aIndex ) const |
|
94 { |
|
95 return static_cast<CConnectionProviderFactoryBase*>(CCommsFactoryContainer::Factory(aIndex)); |
|
96 } |
|
97 |
|
98 |
|
99 void CConnectionFactoryContainer::ReceivedL(const TRuntimeCtxId& aSender, const TNodeId& /*aRecipient*/, TSignatureBase& aMessage) |
|
100 { |
|
101 |
|
102 if (aMessage.IsMessage<TCFFactory::TFindOrCreatePeer>()) |
|
103 { //rjl todo: inconsistency in this function across planes.. ensure that's intended |
|
104 ACommsFactoryNodeId* factoryObject = CreateFactoryObjectNodeL (aMessage); |
|
105 #ifndef __GCCXML__ |
|
106 RClientInterface::OpenPostMessageClose(Id(), aSender, TCFFactory::TPeerFoundOrCreated(factoryObject->Id(), 0).CRef()); |
|
107 #endif |
|
108 } |
|
109 else |
|
110 { |
|
111 NM_LOG_START_BLOCK(KESockMetaConnectionTag, _L8("CConnectionFactoryContainer::ReceivedL")); |
|
112 NM_LOG((KESockMetaConnectionTag, _L8("ERROR: KErrNotSupported [this=0x%08x]"), this)); |
|
113 NM_LOG_MESSAGE(KESockMetaConnectionTag, aMessage); |
|
114 NM_LOG_END_BLOCK(KESockMetaConnectionTag, _L8("CConnectionFactoryContainer::ReceivedL")); |
|
115 |
|
116 __ASSERT_DEBUG(EFalse, User::Panic(KSpecAssert_ESockSSockscnprv, 2)); //For debug configurations |
|
117 User::Leave(KErrNotSupported); //For release configurations |
|
118 } |
|
119 } |
|
120 |
|
121 |
|
122 //========================================================== |
|
123 |
|
124 EXPORT_C CConnectionProviderFactoryBase::~CConnectionProviderFactoryBase() |
|
125 /** Empty connection factory base destructor */ |
|
126 { |
|
127 } |
|
128 |
|
129 EXPORT_C CConnectionProviderFactoryBase::CConnectionProviderFactoryBase(TUid aFactoryId, CConnectionFactoryContainer& aParentContainer) |
|
130 /** connection provider factory constructor |
|
131 |
|
132 @param aFactoryId Unique Integer Identifier of the connection provider factory |
|
133 @param aParentContainer Container to add the factory to */ |
|
134 : CCommsFactoryBase(aFactoryId, aParentContainer) |
|
135 { |
|
136 } |
|
137 |
|
138 EXPORT_C ACommsFactoryNodeId* CConnectionProviderFactoryBase::DoFindOrCreateObjectL(TFactoryQueryBase& aQuery) |
|
139 { |
|
140 ACommsFactoryNodeId* provider = static_cast<ACommsFactoryNodeId*>(FindObject(aQuery)); |
|
141 return provider ? provider : CreateL(aQuery); |
|
142 } |
|
143 |
|
144 |
|
145 EXPORT_C ACommsFactoryNodeId* CConnectionProviderFactoryBase::CreateL(TFactoryQueryBase& aQuery) |
|
146 /** Create a new instance of connection provider |
|
147 |
|
148 @return Pointer to the created connection provider or NULL if there's a failure */ |
|
149 { |
|
150 CConnectionProviderBase* provider = static_cast<CConnectionProviderBase*>(DoCreateObjectL(aQuery)); |
|
151 CleanupStack::PushL(provider); |
|
152 |
|
153 const TDefaultConnectionFactoryQuery& query = static_cast<const TDefaultConnectionFactoryQuery&>(aQuery); |
|
154 provider->AddClientL(address_cast<TNodeId>(query.iMCprId), TClientType(TCFClientType::ECtrlProvider)); |
|
155 |
|
156 // Add the connectionProvider to it's factory |
|
157 AddManagedObjectL(*provider); |
|
158 |
|
159 CleanupStack::Pop(provider); |
|
160 return provider; |
|
161 } |
|
162 |
|
163 EXPORT_C ACommsFactoryNodeId* CConnectionProviderFactoryBase::DoCreateObjectL(TFactoryQueryBase& /* aQuery */) |
|
164 { |
|
165 __ASSERT_DEBUG(EFalse, User::Panic(KSpecAssert_ESockSSockscnprv, 3)); |
|
166 User::Leave(KErrNotSupported); |
|
167 return NULL; |
|
168 } |
|
169 |
|
170 //========================================================== |
|
171 |
|
172 |
|
173 EXPORT_C CConnectionProviderBase::CConnectionProviderBase(CConnectionProviderFactoryBase& aFactory, |
|
174 const MeshMachine::TNodeActivityMap& aActivityMap) |
|
175 : CMMCommsProviderBase( aFactory,aActivityMap ) |
|
176 /** Constructor for CConnectionProviderBase |
|
177 |
|
178 @param aFactory Parent container for the provider */ |
|
179 { |
|
180 LOG(ESockLog::Printf(KESockCtrlFactTag, _L("CConnectionProviderBase %08x:\tcreated [%d], factory Uid %08x"), |
|
181 this, sizeof(CConnectionProviderBase), Factory().Uid().iUid)); |
|
182 } |
|
183 |
|
184 EXPORT_C RNodeInterface* CConnectionProviderBase::NewClientInterfaceL(const TClientType& aClientType, TAny* aClientInfo) |
|
185 { |
|
186 if (aClientType.Type() & TCFClientType::ECtrl) |
|
187 { |
|
188 if (aClientInfo == NULL) |
|
189 { // This is not CPR, probably CConnection, use min priority. |
|
190 return new (ELeave) RCFNodePriorityInterface(KMaxTUint); |
|
191 } |
|
192 else |
|
193 { |
|
194 const TUint* priority = static_cast<const TUint*>(aClientInfo); |
|
195 return new (ELeave) RCFNodePriorityInterface(*priority); |
|
196 } |
|
197 } |
|
198 else |
|
199 { |
|
200 return MeshMachine::AMMNodeBase::NewClientInterfaceL(aClientType, aClientInfo); |
|
201 } |
|
202 } |
|
203 |
|
204 EXPORT_C CConnectionProviderBase::~CConnectionProviderBase() |
|
205 /** Destructor for CConnectionProviderBase. |
|
206 */ |
|
207 { |
|
208 LOG(ESockLog::Printf(KESockCtrlFactTag, _L("~CConnectionProviderBase %08x:\tfactory Uid %08x"), |
|
209 this, Factory().Uid().iUid)); |
|
210 } |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |