|
1 // Copyright (c) 2007-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 // This is part of an ECOM plug-in |
|
15 // SIP TierManagerSelector class used to Find or Create SIP MCPR |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent |
|
22 */ |
|
23 |
|
24 #include "siptiermanagerselector.h" |
|
25 #include "siptiermanagerfactory.h" |
|
26 #include <comms-infras/ss_log.h> |
|
27 #include <ss_glob.h> |
|
28 #include <comms-infras/ss_metaconnprov.h> |
|
29 #include <commsdattypesv1_1.h> |
|
30 #include <es_connpref.h> |
|
31 #include <commdbconnpref.h> |
|
32 #include <comms-infras/ss_tiermanagerutils.h> |
|
33 #include <sipconnpref.h> |
|
34 #include <commsdattypesv1_1_partner.h> |
|
35 |
|
36 |
|
37 #ifdef __CFLOG_ACTIVE |
|
38 #define KSipTierMgrTag KESockMetaConnectionTag |
|
39 _LIT8(KSipTierMgrSubTag, "siptiermanager"); |
|
40 #endif |
|
41 |
|
42 using namespace ESock; |
|
43 using namespace CommsDat; |
|
44 |
|
45 enum TSipSelectorPanic |
|
46 { |
|
47 EExpectedAccessPointAwareSystem = 0, // |
|
48 EExpectedDifferentSelectionPreferences = 1, |
|
49 ESipMcprNotFound = 2, |
|
50 }; |
|
51 |
|
52 |
|
53 //This fn performs a pre-selection decision to match a proper selector. |
|
54 MProviderSelector* CSipMetaCprSelector::NewL(const Meta::SMetaData& aSelectionPreferences) |
|
55 { |
|
56 CSipMetaCprSelector* self = new (ELeave) CSipMetaCprSelector(); |
|
57 CleanupStack::PushL(self); |
|
58 self->ConstructL(aSelectionPreferences); |
|
59 CleanupStack::Pop(); |
|
60 return self; |
|
61 } |
|
62 |
|
63 void CSipMetaCprSelector::ConstructL(const Meta::SMetaData& aSelectionPreferences) |
|
64 { |
|
65 ASSERT(aSelectionPreferences.IsTypeOf(TSelectionPrefs::TypeId())); |
|
66 iDbs = CMDBSession::NewLC(KCDVersion1_2); |
|
67 CleanupStack::Pop(iDbs); |
|
68 iTierRecord = TierManagerUtils::LoadTierRecordL(TUid::Uid(CSipTierManagerFactory::iUid),*iDbs); |
|
69 iSelectionPrefs.Copy(aSelectionPreferences); |
|
70 } |
|
71 |
|
72 CSipMetaCprSelector::CSipMetaCprSelector() |
|
73 : iMetaContainer(*(SockManGlobals::Get()->iMetaConnectionFactories)) |
|
74 |
|
75 { |
|
76 __CFLOG_VAR((KSipTierMgrTag, KSipTierMgrSubTag, _L8("CSipMetaCprSelector [this=%08x]:\tCSipMetaCprSelector"), this)); |
|
77 } |
|
78 |
|
79 CSipMetaCprSelector::~CSipMetaCprSelector() |
|
80 { |
|
81 __CFLOG_VAR((KSipTierMgrTag, KSipTierMgrSubTag, _L8("CSipMetaCprSelector [this=%08x]:\t ~CSipMetaCprSelector"), this)); |
|
82 Cancel(); |
|
83 delete iProvisionInfo; |
|
84 iProvisionInfo = NULL; |
|
85 delete iDbs; |
|
86 } |
|
87 |
|
88 void CSipMetaCprSelector::Cancel() |
|
89 { |
|
90 } |
|
91 |
|
92 void CSipMetaCprSelector::SelectL(ISelectionNotify& aSelectionNotify) |
|
93 { |
|
94 // In the case of SIP the selector selects the MCPR and sets the |
|
95 // appUid, profileId and ptr to CTransitionEngineMgr which form the |
|
96 // provisioning info that'll be passd to the CPR by the MCPR |
|
97 // |
|
98 __CFLOG_VAR((KSipTierMgrTag, KSipTierMgrSubTag, _L8("CSipMetaCprSelector %08x:\tSelectL()"), this)); |
|
99 |
|
100 ASSERT(iDbs); |
|
101 ASSERT(iTierRecord); |
|
102 |
|
103 TSecureId sid; |
|
104 ASubSessionPlatsecApiExt platsecext(iSelectionPrefs.SubSessionUniqueId()); |
|
105 platsecext.SecureId(sid); |
|
106 TUid appUid = sid.operator TUid(); |
|
107 TUint32 profileId = KSIPDefaultProfileId; |
|
108 TUint32 defaultAccessPoint = iTierRecord->iDefaultAccessPoint; |
|
109 |
|
110 if (iSelectionPrefs.IsEmpty()) |
|
111 { |
|
112 ASSERT(iSelectionPrefs.Flags()==0); |
|
113 __CFLOG_VAR((KSipTierMgrTag, KSipTierMgrSubTag, _L8("CSipMetaCprSelector %08x::\tSelectL() Using Default AP:%d"),this,defaultAccessPoint)); |
|
114 aSelectionNotify.SelectComplete(this,FindOrCreateProviderL(defaultAccessPoint, profileId, appUid)); |
|
115 aSelectionNotify.SelectComplete(this,NULL); |
|
116 return; |
|
117 } |
|
118 |
|
119 const TConnPref& prefs = iSelectionPrefs.Prefs(); |
|
120 |
|
121 if (prefs.ExtensionId() == TConnPref::EConnPrefSip) |
|
122 { |
|
123 TSipConnPref sipPref = TSipConnPref::Cast(prefs); |
|
124 TUint32 profileId = sipPref.GetProfileId(); |
|
125 CMetaConnectionProviderBase* mcpr = FindOrCreateProviderL(defaultAccessPoint,profileId,appUid); |
|
126 __ASSERT_ALWAYS(mcpr!=NULL, User::Leave(KErrNotFound)); |
|
127 |
|
128 aSelectionNotify.SelectComplete(this, mcpr); |
|
129 aSelectionNotify.SelectComplete(this,NULL); |
|
130 } |
|
131 } |
|
132 |
|
133 |
|
134 CMetaConnectionProviderBase* CSipMetaCprSelector::FindOrCreateProviderL(TUint aAccessPoint, TUint32 aProfileId, TUid aAppUid) |
|
135 { |
|
136 __CFLOG_VAR((KSipTierMgrTag, KSipTierMgrSubTag, _L8("CSipMetaCprSelector %08x:\tFindOrCreateProviderL()"), this)); |
|
137 |
|
138 //Find MCPR factory |
|
139 TUid mCprUid = TierManagerUtils::ReadMCprUidL(aAccessPoint, *iDbs); |
|
140 |
|
141 CMetaConnectionProviderFactoryBase* factory = static_cast<CMetaConnectionProviderFactoryBase*>(iMetaContainer.FindOrCreateFactoryL(mCprUid)); |
|
142 |
|
143 //Create the provider |
|
144 TUid tierId = TUid::Uid(iTierRecord->iRecordTag); |
|
145 // Adding the tier implementation id |
|
146 TUid tierImplId = TUid::Uid(iTierRecord->iTierImplUid); |
|
147 // Send Transition Engine Mgr, AppUid and ProfileID in provision to CPR |
|
148 iProvisionInfo = new (ELeave) TSipMcprProvisionInfo(); |
|
149 iProvisionInfo->iProfileId = aProfileId; |
|
150 iProvisionInfo->iAppUid = aAppUid; |
|
151 iProvisionInfo->iTransitionEngineMgr = iTierManager->TransitionEngineManager(); |
|
152 |
|
153 TProviderInfo providerInfo(tierId,aAccessPoint,reinterpret_cast<TAny*>(iProvisionInfo)); |
|
154 XSIPFindTheSamePrefsCPRQuery cprQuery(aAppUid, aProfileId, providerInfo, tierImplId); |
|
155 return static_cast<CMetaConnectionProviderBase*>(factory->FindOrCreateObjectL(cprQuery)); |
|
156 } |
|
157 |
|
158 void CSipMetaCprSelector::SetTierManager(CSipTierManager* aTierManager) |
|
159 { |
|
160 iTierManager = aTierManager; |
|
161 } |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 //-========================================================= |
|
167 // XSIPFindTheSamePrefsCPRQuery |
|
168 //-========================================================= |
|
169 |
|
170 Factories::MFactoryQuery::TMatchResult XSIPFindTheSamePrefsCPRQuery::Match( Factories::TFactoryObjectInfo& aProviderInfo ) |
|
171 { |
|
172 |
|
173 CSipMetaConnectionProvider* prov = static_cast<CSipMetaConnectionProvider*>(aProviderInfo.iInfo.iFactoryObject); |
|
174 |
|
175 // match the profile Ids and App Uids. |
|
176 // a match for the both the profileId and appUid indicates that the same app has started the same profile again |
|
177 // it can share the MCPR (and the CPR, since MCPR : CPR is a 1:1 ralation ) |
|
178 |
|
179 if (prov->AppUid() != iAppUid) |
|
180 { |
|
181 //uids dont match. They are different apps and cannot share an MCPR |
|
182 return EContinue; |
|
183 } |
|
184 if (prov->ProfileId() == iProfileId) |
|
185 { |
|
186 //the profile id also matches. Hence the same MCPR |
|
187 return EMatch; |
|
188 } |
|
189 |
|
190 return EContinue; |
|
191 } |
|
192 |