24
|
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
|
|
18 |
@internalComponent
|
|
19 |
*/
|
|
20 |
|
|
21 |
#include "pdptiermanagerselector.h"
|
|
22 |
#include "pdptiermanagerfactory.h"
|
|
23 |
|
|
24 |
#include <comms-infras/ss_log.h>
|
|
25 |
#include <commsdattypesv1_1.h>
|
|
26 |
#include <commsdattypesv1_1_partner.h>
|
|
27 |
#include <comms-infras/ss_tiermanagerutils.h>
|
|
28 |
#include <es_connpref.h> //TConnIdList
|
|
29 |
#include <es_enum_internal.h>
|
|
30 |
|
|
31 |
#ifdef __CFLOG_ACTIVE
|
|
32 |
#define KPdpTierMgrTag KESockTierTag
|
|
33 |
_LIT8(KPdpTierMgrSubTag, "pdptiermgr");
|
|
34 |
#endif // __CFLOG_ACTIVE
|
|
35 |
|
|
36 |
using namespace ESock;
|
|
37 |
using namespace CommsDat;
|
|
38 |
|
|
39 |
|
|
40 |
//Panic codes
|
|
41 |
_LIT(KPdpSelectorPanic, "PdpSelector");
|
|
42 |
enum TPdpSelectorPanic
|
|
43 |
{
|
|
44 |
EExpectedAccessPointAwareSystem = 0,
|
|
45 |
EUnExpectedSelectionPreferences = 1
|
|
46 |
};
|
|
47 |
|
|
48 |
//
|
|
49 |
//CPdpProviderSelector
|
|
50 |
class CPdpProviderSelector : public CBase, public ASimpleSelectorBase
|
|
51 |
/** Link connection selector.
|
|
52 |
Simple selector object for the link layer.
|
|
53 |
|
|
54 |
@internalComponent
|
|
55 |
@prototype
|
|
56 |
*/
|
|
57 |
{
|
|
58 |
public:
|
|
59 |
explicit CPdpProviderSelector(const Meta::SMetaData& aSelectionPreferences)
|
|
60 |
: ASimpleSelectorBase(aSelectionPreferences)
|
|
61 |
{
|
|
62 |
}
|
|
63 |
|
|
64 |
private:
|
|
65 |
virtual void SelectL(ESock::ISelectionNotify& aSelectionNotify);
|
|
66 |
};
|
|
67 |
|
|
68 |
void CPdpProviderSelector::SelectL(ISelectionNotify& aSelectionNotify)
|
|
69 |
{
|
|
70 |
ASSERT(iDbs);
|
|
71 |
ASSERT(iTierRecord);
|
|
72 |
TUint32 defaultAccessPoint = iTierRecord->iDefaultAccessPoint;
|
|
73 |
|
|
74 |
//This selector deals only with the AccessPoint aware system!
|
|
75 |
__ASSERT_DEBUG(defaultAccessPoint!=0,User::Panic(KPdpSelectorPanic,EExpectedAccessPointAwareSystem));
|
|
76 |
|
|
77 |
if (iSelectionPrefs.IsEmpty())
|
|
78 |
{
|
|
79 |
//Implicit case on the new setup
|
|
80 |
__CFLOG_VAR((KPdpTierMgrTag, KPdpTierMgrSubTag, _L8("CPdpProviderSelector %08x::\tSelectL() Using Default AP:%d"),this,defaultAccessPoint));
|
|
81 |
aSelectionNotify.SelectComplete(this,FindOrCreateProviderL(defaultAccessPoint));
|
|
82 |
aSelectionNotify.SelectComplete(this,NULL);
|
|
83 |
return;
|
|
84 |
}
|
|
85 |
|
|
86 |
const TConnPref& prefs = iSelectionPrefs.Prefs();
|
|
87 |
if (prefs.ExtensionId() == TConnPref::EConnPrefProviderInfo)
|
|
88 |
{
|
|
89 |
ASSERT(iSelectionPrefs.Scope() & TSelectionPrefs::ESelectFromExisting); //This is always attach
|
|
90 |
const TConnProviderInfo& connProvInfo = static_cast<const TConnProviderInfoPref&>(prefs).Info();
|
|
91 |
__CFLOG_VAR((KPdpTierMgrTag, KPdpTierMgrSubTag, _L8("CPdpProviderSelector %08x::\tSelectL() Using TConnProviderInfoPref, AP:%d"),this,connProvInfo.iInfo[1]));
|
|
92 |
aSelectionNotify.SelectComplete(this,FindProviderL(connProvInfo.iInfo[1],(TAny*)connProvInfo.iInfo[2]));
|
|
93 |
aSelectionNotify.SelectComplete(this,NULL);
|
|
94 |
return;
|
|
95 |
}
|
|
96 |
|
|
97 |
if (prefs.ExtensionId() == TConnPref::EConnPrefSnap)
|
|
98 |
{
|
|
99 |
TUint accessPoint = static_cast<const TConnSnapPref&>(prefs).Snap();
|
|
100 |
__CFLOG_VAR((KPdpTierMgrTag, KPdpTierMgrSubTag, _L8("CPdpProviderSelector %08x::\tSelectL() Using TConnPrefSnap, AP:%d"),this,accessPoint));
|
|
101 |
aSelectionNotify.SelectComplete(this,FindOrCreateProviderL(accessPoint));
|
|
102 |
aSelectionNotify.SelectComplete(this,NULL);
|
|
103 |
return;
|
|
104 |
}
|
|
105 |
|
|
106 |
if (prefs.ExtensionId() == TConnPref::EConnPrefIdList)
|
|
107 |
{
|
|
108 |
__CFLOG_VAR((KPdpTierMgrTag, KPdpTierMgrSubTag, _L8("CPdpProviderSelector %08x::\tSelectL() Using TConnIdList"),this));
|
|
109 |
const TConnIdList& list = static_cast<const TConnIdList&>(prefs);
|
|
110 |
TInt count = list.Count();
|
|
111 |
for (TInt i = 0; i < count; i++)
|
|
112 |
{
|
|
113 |
aSelectionNotify.SelectComplete(this,FindOrCreateProviderL(list.Get(i)));
|
|
114 |
}
|
|
115 |
aSelectionNotify.SelectComplete(this,NULL);
|
|
116 |
return;
|
|
117 |
}
|
|
118 |
|
|
119 |
//In this selector we _must_ have the new preferences, otherwise it means that
|
|
120 |
//a critical, non-recoverable mitsake has occured before when this selector has been picked.
|
|
121 |
__CFLOG_VAR((KPdpTierMgrTag, KPdpTierMgrSubTag, _L8("ERROR: CPdpProviderSelector %08x::\tSelectL() Unexpected selection preferences"),this));
|
|
122 |
User::Panic(KPdpSelectorPanic,EUnExpectedSelectionPreferences);
|
|
123 |
}
|
|
124 |
|
|
125 |
//
|
|
126 |
// TPdpSelectorFactory::NewSelectorL - This fn matches a selector
|
|
127 |
MProviderSelector* TPdpSelectorFactory::NewSelectorL(const Meta::SMetaData& aSelectionPreferences)
|
|
128 |
{
|
|
129 |
__CFLOG_VAR((KPdpTierMgrTag, KPdpTierMgrSubTag, _L8("CPdpMetaCprSelectorBase::\tNewL()")));
|
|
130 |
ASSERT(aSelectionPreferences.IsTypeOf(TSelectionPrefs::TypeId()));
|
|
131 |
CMDBSession* dbs = CMDBSession::NewLC(KCDVersion1_2);
|
|
132 |
CPdpProviderSelector* self = new (ELeave) CPdpProviderSelector(aSelectionPreferences);
|
|
133 |
CleanupStack::PushL(self);
|
|
134 |
ASSERT(self->iTierRecord==NULL);
|
|
135 |
self->iTierRecord = TierManagerUtils::LoadTierRecordL(TUid::Uid(CPDPTierManagerFactory::EUid),*dbs);
|
|
136 |
CleanupStack::Pop(self);
|
|
137 |
CleanupStack::Pop(dbs);
|
|
138 |
ASSERT(self->iDbs==NULL);
|
|
139 |
self->iDbs = dbs;
|
|
140 |
return self;
|
|
141 |
}
|
|
142 |
|