|
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 |
|
22 #include "agenttiermanagerselector.h" |
|
23 #include "agenttiermanagerfactory.h" |
|
24 |
|
25 #include <comms-infras/ss_log.h> |
|
26 #include <commsdattypesv1_1.h> |
|
27 #include <comms-infras/ss_tiermanagerutils.h> |
|
28 #include <es_connpref.h> //TConnIdList |
|
29 |
|
30 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
31 #include <commsdattypesv1_1_partner.h> |
|
32 #include <es_enum_internal.h> |
|
33 #endif |
|
34 |
|
35 #ifdef _DEBUG |
|
36 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module |
|
37 // (if it could happen through user error then you should give it an explicit, documented, category + code) |
|
38 _LIT(KSpecAssert_NifManAgtPrgntrm, "NifManAgtPrgntrm"); |
|
39 #endif |
|
40 |
|
41 #ifdef __CFLOG_ACTIVE |
|
42 #define KAgentTierMgrTag KESockMetaConnectionTag |
|
43 _LIT8(KAgentTierMgrSubTag, "agenttiermgr"); |
|
44 #endif // __CFLOG_ACTIVE |
|
45 |
|
46 |
|
47 using namespace ESock; |
|
48 using namespace CommsDat; |
|
49 |
|
50 //Panic codes |
|
51 _LIT(KAgentSelectorPanic, "AgentSelector"); |
|
52 enum TAgentSelectorPanic |
|
53 { |
|
54 EExpectedAccessPointAwareSystem = 0, // |
|
55 EUnExpectedSelectionPreferences = 1, |
|
56 }; |
|
57 |
|
58 |
|
59 // |
|
60 //CAgentProviderSelector |
|
61 class CAgentProviderSelector : public CBase, public ASimpleSelectorBase |
|
62 /** Link connection selector. |
|
63 Simple selector object for the link layer. |
|
64 |
|
65 @internalComponent |
|
66 @prototype |
|
67 */ |
|
68 { |
|
69 public: |
|
70 static const TUint KUid = 0x10283022; |
|
71 |
|
72 public: |
|
73 explicit CAgentProviderSelector(const Meta::SMetaData& aSelectionPreferences) |
|
74 : ASimpleSelectorBase(KUid, aSelectionPreferences) |
|
75 { |
|
76 } |
|
77 |
|
78 private: |
|
79 virtual void SelectL(ESock::ISelectionNotify& aSelectionNotify); |
|
80 //CMetaConnectionProviderBase* FindOrCreateProviderL(TUint aAccessPoint); |
|
81 }; |
|
82 |
|
83 |
|
84 void CAgentProviderSelector::SelectL(ISelectionNotify& aSelectionNotify) |
|
85 { |
|
86 __ASSERT_DEBUG(iDbs, User::Panic(KSpecAssert_NifManAgtPrgntrm, 1)); |
|
87 __ASSERT_DEBUG(iTierRecord, User::Panic(KSpecAssert_NifManAgtPrgntrm, 2)); |
|
88 TUint32 defaultAccessPoint = iTierRecord->iDefaultAccessPoint; |
|
89 |
|
90 //This selector deals only with the AccessPoint aware system! |
|
91 __ASSERT_DEBUG(defaultAccessPoint!=0,User::Panic(KAgentSelectorPanic,EExpectedAccessPointAwareSystem)); |
|
92 |
|
93 if (iSelectionPrefs.IsEmpty()) |
|
94 { |
|
95 //Implicit case on the new setup |
|
96 __CFLOG_VAR((KAgentTierMgrTag, KAgentTierMgrSubTag, _L8("CAgentProviderSelector %08x::\tSelectL() Using Default AP:%d"),this,defaultAccessPoint)); |
|
97 aSelectionNotify.SelectComplete(this,FindOrCreateProviderL(defaultAccessPoint)); |
|
98 aSelectionNotify.SelectComplete(this,NULL); |
|
99 return; |
|
100 } |
|
101 |
|
102 const TConnPref& prefs = iSelectionPrefs.Prefs(); |
|
103 if (prefs.ExtensionId() == TConnPref::EConnPrefProviderInfo) |
|
104 { |
|
105 __ASSERT_DEBUG(iSelectionPrefs.Scope() & TSelectionPrefs::ESelectFromExisting, User::Panic(KSpecAssert_NifManAgtPrgntrm, 3)); //This is always attach |
|
106 const TConnProviderInfo& connProvInfo = static_cast<const TConnProviderInfoPref&>(prefs).Info(); |
|
107 __CFLOG_VAR((KAgentTierMgrTag, KAgentTierMgrSubTag, _L8("CAgentProviderSelector %08x::\tSelectL() Using TConnProviderInfoPref, AP:%d"),this,connProvInfo.iInfo[1])); |
|
108 aSelectionNotify.SelectComplete(this,FindProviderL(connProvInfo.iInfo[1],(TAny*)connProvInfo.iInfo[2])); |
|
109 aSelectionNotify.SelectComplete(this,NULL); |
|
110 return; |
|
111 } |
|
112 |
|
113 if (prefs.ExtensionId() == TConnPref::EConnPrefSnap) |
|
114 { |
|
115 TUint accessPoint = static_cast<const TConnSnapPref&>(prefs).Snap(); |
|
116 __CFLOG_VAR((KAgentTierMgrTag, KAgentTierMgrSubTag, _L8("CAgentProviderSelector %08x::\tSelectL() Using TConnPrefSnap, AP:%d"),this,accessPoint)); |
|
117 aSelectionNotify.SelectComplete(this,FindOrCreateProviderL(accessPoint)); |
|
118 aSelectionNotify.SelectComplete(this,NULL); |
|
119 return; |
|
120 } |
|
121 |
|
122 if (prefs.ExtensionId() == TConnPref::EConnPrefIdList) |
|
123 { |
|
124 __CFLOG_VAR((KAgentTierMgrTag, KAgentTierMgrSubTag, _L8("CAgentProviderSelector %08x::\tSelectL() Using TConnIdList"),this)); |
|
125 const TConnIdList& list = static_cast<const TConnIdList&>(prefs); |
|
126 TInt count = list.Count(); |
|
127 for (TInt i = 0; i < count; i++) |
|
128 { |
|
129 aSelectionNotify.SelectComplete(this,FindOrCreateProviderL(list.Get(i))); |
|
130 } |
|
131 aSelectionNotify.SelectComplete(this,NULL); |
|
132 return; |
|
133 } |
|
134 |
|
135 //In this selector we _must_ have the new preferences, otherwise it means that |
|
136 //a critical, non-recoverable mistake has occured before when this selector has been picked. |
|
137 __CFLOG_VAR((KAgentTierMgrTag, KAgentTierMgrSubTag, _L8("ERROR: CAgentProviderSelector %08x::\tSelectL() Unexpected selection preferences"),this)); |
|
138 User::Panic(KAgentSelectorPanic,EUnExpectedSelectionPreferences); |
|
139 } |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 // |
|
145 // TAgentSelectorFactory::NewSelectorL - This fn matches a selector |
|
146 MProviderSelector* TAgentSelectorFactory::NewSelectorL(const Meta::SMetaData& aSelectionPreferences) |
|
147 { |
|
148 __CFLOG_VAR((KAgentTierMgrTag, KAgentTierMgrSubTag, _L8("CAgentMetaCprSelectorBase::\tNewL()"))); |
|
149 __ASSERT_DEBUG(aSelectionPreferences.IsTypeOf(TSelectionPrefs::TypeId()), User::Panic(KSpecAssert_NifManAgtPrgntrm, 4)); |
|
150 CMDBSession* dbs = CMDBSession::NewLC(KCDVersion1_2); |
|
151 ASimpleSelectorBase* self = new (ELeave) CAgentProviderSelector(aSelectionPreferences); |
|
152 CleanupStack::PushL(self); |
|
153 __ASSERT_DEBUG(self->iTierRecord==NULL, User::Panic(KSpecAssert_NifManAgtPrgntrm, 5)); |
|
154 self->iTierRecord = TierManagerUtils::LoadTierRecordL(TUid::Uid(CAgentTierManagerFactory::iUid),*dbs); |
|
155 CleanupStack::Pop(self); |
|
156 CleanupStack::Pop(dbs); |
|
157 __ASSERT_DEBUG(self->iDbs==NULL, User::Panic(KSpecAssert_NifManAgtPrgntrm, 6)); |
|
158 self->iDbs = dbs; |
|
159 return self; |
|
160 } |
|
161 |
|
162 |