|
1 /* |
|
2 * Copyright (c) 2008-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 "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: S60 IP TM selector implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 /** |
|
19 @file s60tiermanagerselector.cpp |
|
20 S60 IP TM selector implementation |
|
21 */ |
|
22 |
|
23 #include <comms-infras/ss_log.h> |
|
24 #include <comms-infras/ss_tiermanagerutils.h> |
|
25 #include <commsdattypesv1_1.h> // CommsDat |
|
26 #include <es_connpref.h> //TConnIdList |
|
27 #include <commdbconnpref.h> |
|
28 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
29 #include <commsdattypeinfov1_1_internal.h> |
|
30 #include <commsdattypesv1_1_partner.h> |
|
31 #endif |
|
32 #include <extendedconnpref.h> |
|
33 |
|
34 #include "s60extendedtmselector.h" |
|
35 #include "s60tiermanagerfactory.h" |
|
36 #include "s60mcpr.h" |
|
37 |
|
38 #include <comms-infras/esock_params_internal.h> |
|
39 |
|
40 |
|
41 using namespace ESock; |
|
42 using namespace CommsDat; |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // IpProto Tier Manager's UID. |
|
46 // Since meaning of the selection policy id changes with |
|
47 // the legacy flavor it is difficult to derive the next layer |
|
48 // tier's id dynamically when supporting all of the legacy scenarios. |
|
49 // At the same time it is known that for all of these legacy |
|
50 // setups this is and always will be the only next layer tier manager. |
|
51 // ----------------------------------------------------------------------------- |
|
52 static const TUid KLegacyNextLayerTierId = { 0x10281DF0 }; //CIPProtoTierManagerFactory::iUid |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CExtendedS60SelectorBase::CExtendedS60SelectorBase |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CExtendedS60SelectorBase::CExtendedS60SelectorBase( TUid aTierId, const ESock::RConnPrefList& aConnPrefList ) |
|
59 : ASimpleSelectorBase( ) |
|
60 { |
|
61 iTierId = aTierId; |
|
62 iConnPrefList = aConnPrefList; |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CExtendedS60SelectorBase::~CExtendedS60SelectorBase |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CExtendedS60SelectorBase::~CExtendedS60SelectorBase() |
|
70 { |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CExtendedS60SelectorBase::SelectL |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CExtendedS60SelectorBase::SelectL(ISelectionNotify& aSelectionNotify) |
|
78 { |
|
79 //This code doesn't need to be in a seperate selector. It could be moved to |
|
80 //a transition if the method FindOrCreateProviderL was re-created in |
|
81 //another file (it is currently inherited from ASimpleSelectorBase) |
|
82 |
|
83 CMDBSession* dbs = CMDBSession::NewLC(KCDVersion1_2); |
|
84 |
|
85 iTierRecord = TierManagerUtils::LoadTierRecordL(iTierId,*dbs); |
|
86 CleanupStack::Pop(); |
|
87 iDbs = dbs; |
|
88 |
|
89 //__ASSERT_DEBUG(iDbs, User::Panic(KSpecAssert_ESockCrPrvTMSelC, 1)); |
|
90 //__ASSERT_DEBUG(iTierRecord, User::Panic(KSpecAssert_ESockCrPrvTMSelC, 2)); |
|
91 |
|
92 TUint accessPoint = 0; |
|
93 CCDAccessPointRecord* apRec; |
|
94 TUid tierId; |
|
95 TUint selected = 0; |
|
96 |
|
97 // Get sub session unique id |
|
98 ESock::RConnPrefList::TIter<TConnCSRPref> iterCSR = iConnPrefList.getIter<TConnCSRPref>(); |
|
99 |
|
100 // If no prefs in list return error |
|
101 if (iterCSR.IsEnd()) |
|
102 { |
|
103 User::Leave(KErrArgument); |
|
104 } |
|
105 |
|
106 //This iterator runs through all the instances of TConnCSRPref |
|
107 while(!iterCSR.IsEnd()) |
|
108 { |
|
109 iSubSessionUniqueId = iterCSR->SubSessionUniqueId(); |
|
110 iterCSR++; |
|
111 } |
|
112 |
|
113 //This iterator links to all the elements of TExtendedConnPref that exist in the list |
|
114 ESock::RConnPrefList::TIter<TExtendedConnPref> iterAP = iConnPrefList.getIter<TExtendedConnPref>(); |
|
115 |
|
116 // If no prefs in list return error |
|
117 if (iterAP.IsEnd()) |
|
118 { |
|
119 User::Leave(KErrArgument); |
|
120 } |
|
121 |
|
122 //This iterator runs through all the instances of TExtendedConnPref |
|
123 while(!iterAP.IsEnd()) |
|
124 { |
|
125 accessPoint = iTierRecord->iDefaultAccessPoint; |
|
126 //The access point record that that access point represents is retrived |
|
127 apRec = TierManagerUtils::LoadAccessPointRecordL(accessPoint,*iDbs); |
|
128 tierId = TierManagerUtils::MapElementIdToTagId(apRec->iTier, *iDbs); |
|
129 |
|
130 delete apRec; |
|
131 // If the access point is related to this tier manager the provider |
|
132 // is created |
|
133 if(iTierId == tierId) |
|
134 { |
|
135 aSelectionNotify.SelectComplete(this, FindOrCreateProviderL(accessPoint)); |
|
136 ++selected; |
|
137 iterAP++; |
|
138 // For now we accept only one instance of TExtendedConnPref |
|
139 break; |
|
140 } |
|
141 else |
|
142 { |
|
143 LOG_DETAILED( ESockLog::Printf(KCoreTMgrSelSupSubTag, _L("CCoreProviderSelectorSuper %08x:\t AP %d not in tier %08x"), this, accessPoint, iTierId) ); |
|
144 iterAP++; |
|
145 } |
|
146 } |
|
147 |
|
148 if (selected == 0) |
|
149 { |
|
150 LOG_DETAILED( ESockLog::Printf(KCoreTMgrSelSupSubTag, _L("CCoreProviderSelectorSuper %08x:\t No APs selected [Tier: %08x]"), this, iTierId) ); |
|
151 User::Leave(KErrArgument); |
|
152 } |
|
153 |
|
154 aSelectionNotify.SelectComplete(this, NULL); |
|
155 return; |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CExtendedS60SelectorBase::FindOrCreateProviderL |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 CMetaConnectionProviderBase* CExtendedS60SelectorBase::FindOrCreateProviderL( TUint aAccessPoint ) |
|
163 { |
|
164 ASSERT(aAccessPoint); //Should not be 0 now. |
|
165 |
|
166 //Find factory |
|
167 TUid mCprUid = TierManagerUtils::ReadMCprUidL( aAccessPoint, *iDbs ); |
|
168 CMetaConnectionProviderFactoryBase* factory = |
|
169 static_cast<CMetaConnectionProviderFactoryBase*>(iMetaContainer.FindOrCreateFactoryL( mCprUid )); |
|
170 |
|
171 //Create the provider |
|
172 TUid tierId = TUid::Uid( iTierRecord->iRecordTag ); |
|
173 TProviderInfo providerInfo( tierId, aAccessPoint ); |
|
174 TUid tierImplUid = TierManagerUtils::MapTierIdtoTierImplIdL(tierId,*iDbs); |
|
175 TMetaConnectionFactoryQuery query( providerInfo, tierImplUid ); |
|
176 |
|
177 //We are not looking for an existing provider, we always create a new one. |
|
178 //This is the legacy selection (can also be the legacy attach, one layer deep selection) |
|
179 CMetaConnectionProviderBase* provider = static_cast<CMetaConnectionProviderBase*>( factory->CreateObjectL( query )); |
|
180 CS60MetaConnectionProvider* prov = static_cast<CS60MetaConnectionProvider*>( provider ); |
|
181 |
|
182 CleanupStack::PushL( provider ); |
|
183 |
|
184 // Provision selection preferences to S60 NetMCPR. |
|
185 prov->SetConnPrefList( iConnPrefList ); |
|
186 prov->SetSubSessionUniqueId( iSubSessionUniqueId ); |
|
187 |
|
188 // Change the provider info so that this provider is never found by other selections |
|
189 const TProviderInfo& pi = provider->ProviderInfo(); |
|
190 provider->SetProviderInfo( TProviderInfo( pi.TierId(), pi.APId(), provider )); //This provider will never be found |
|
191 |
|
192 // Override the selection policy as we always do for legacy prefs |
|
193 ASSERT(provider->AccessPointConfig().FindExtension(TOverridenSelectionPrefsExt::TypeId())==NULL); |
|
194 |
|
195 RMetaExtensionContainer mec; |
|
196 mec.Open(provider->AccessPointConfig()); |
|
197 CleanupClosePushL(mec); |
|
198 |
|
199 TOverridenSelectionPrefsExt* ext = new (ELeave) TOverridenSelectionPrefsExt( KLegacyNextLayerTierId, iSelectionPrefs ); |
|
200 CleanupStack::PushL( ext ); |
|
201 mec.AppendExtensionL( ext ); //The ownership of the extension goes to AccessPointConfig now. |
|
202 CleanupStack::Pop( ext ); |
|
203 |
|
204 provider->AccessPointConfig().Close(); |
|
205 provider->AccessPointConfig().Open(mec); |
|
206 CleanupStack::PopAndDestroy(&mec); |
|
207 |
|
208 CleanupStack::Pop( provider ); |
|
209 provider->IncrementBlockingDestroy(); |
|
210 return provider; |
|
211 } |
|
212 |
|
213 |