26
|
1 |
/*
|
34
|
2 |
* Copyright (c) 2001-2010 Nokia Corporation and/or its subsidiary(-ies).
|
26
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "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 |
*
|
34
|
14 |
* Description: Tools for plugin handling on Symbian.
|
26
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
/*
|
49
|
19 |
* %version: 21 %
|
26
|
20 |
*/
|
|
21 |
|
|
22 |
#include <EapTraceSymbian.h>
|
|
23 |
#include <EapTypePlugin.h>
|
|
24 |
#include <ecom.h>
|
|
25 |
|
34
|
26 |
#include "EapPluginTools.h"
|
|
27 |
#include "EapAutomatic.h"
|
|
28 |
|
26
|
29 |
/** @file */
|
|
30 |
|
|
31 |
// ----------------------------------------------------------------------
|
|
32 |
|
|
33 |
EXPORT_C EapPluginTools::EapPluginTools()
|
|
34 |
{
|
|
35 |
EAP_TRACE_DEBUG_SYMBIAN((_L("EapPluginTools::EapPluginTools(): this=0x%08x.\n"),
|
|
36 |
this));
|
|
37 |
EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapPluginTools::EapPluginTools()"));
|
|
38 |
}
|
|
39 |
|
|
40 |
// ----------------------------------------------------------------------
|
|
41 |
|
|
42 |
EXPORT_C EapPluginTools::~EapPluginTools()
|
|
43 |
{
|
|
44 |
EAP_TRACE_DEBUG_SYMBIAN((_L("EapPluginTools::~EapPluginTools(): this=0x%08x.\n"),
|
|
45 |
this));
|
|
46 |
EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapPluginTools::~EapPluginTools()"));
|
|
47 |
}
|
|
48 |
|
|
49 |
// ----------------------------------------------------------------------
|
|
50 |
|
|
51 |
EXPORT_C void EapPluginTools::CleanupImplArray( TAny* aAny )
|
|
52 |
{
|
|
53 |
RImplInfoPtrArray* implArray =
|
|
54 |
reinterpret_cast<RImplInfoPtrArray*>( aAny );
|
|
55 |
|
|
56 |
implArray->ResetAndDestroy();
|
|
57 |
implArray->Close();
|
|
58 |
}
|
|
59 |
|
|
60 |
// ----------------------------------------------------------------------
|
|
61 |
|
34
|
62 |
EXPORT_C void EapPluginTools::ListAllEapPluginsL(const TIndexType aIndexType, const TEapExpandedType & aTunnelingEapType, RPointerArray<TEapExpandedType> & aPlugins)
|
26
|
63 |
{
|
|
64 |
EAP_TRACE_DEBUG_SYMBIAN((_L("EapPluginTools::ListAllEapPluginsL(): this=0x%08x, aTunnelingEapType=0xfe%06x%08x.\n"),
|
|
65 |
this,
|
|
66 |
aTunnelingEapType.GetVendorId(),
|
|
67 |
aTunnelingEapType.GetVendorType()));
|
|
68 |
EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapPluginTools::ListAllEapPluginsL()"));
|
|
69 |
|
|
70 |
aPlugins.Reset(); // Reset this first
|
|
71 |
|
|
72 |
RImplInfoPtrArray aEapArray;
|
|
73 |
|
|
74 |
CleanupStack::PushL( TCleanupItem( CleanupImplArray, &aEapArray ) );
|
|
75 |
|
|
76 |
REComSession::ListImplementationsL( KEapTypeInterfaceUid, aEapArray );
|
|
77 |
|
34
|
78 |
// Checks which plugins are allowed inside the tunneling EAP-methods and which are allowed outer most EAP-methods.
|
26
|
79 |
for( TInt counter = 0; counter < aEapArray.Count(); counter++ )
|
|
80 |
{
|
|
81 |
TEapExpandedType plugin_type(aEapArray[counter]->DataType());
|
|
82 |
|
|
83 |
EAP_TRACE_DEBUG_SYMBIAN((_L("EapPluginTools::ListAllEapPluginsL(): aEapArray[%d] EAP-type=0xfe%06x%08x\n"),
|
|
84 |
counter,
|
|
85 |
plugin_type.GetVendorId(),
|
|
86 |
plugin_type.GetVendorType()));
|
|
87 |
|
49
|
88 |
TBool aAllowed(ETrue);
|
26
|
89 |
|
34
|
90 |
if (aIndexType == ELan
|
|
91 |
&& aTunnelingEapType == (*EapExpandedTypeNone.GetType()))
|
26
|
92 |
{
|
34
|
93 |
// Filter out the EAP types which are NOT allowed outside PEAP, TTLS or FAST on WLAN.
|
26
|
94 |
if( CEapTypePlugin::IsDisallowedOutsidePEAP( *aEapArray[counter] ) )
|
|
95 |
{
|
|
96 |
EAP_TRACE_DEBUG_SYMBIAN((_L("EapPluginTools::ListAllEapPluginsL(): aEapArray[%d] EAP-type=0xfe%06x%08x, IsDisallowedOutsidePEAP()\n"),
|
|
97 |
counter,
|
|
98 |
plugin_type.GetVendorId(),
|
|
99 |
plugin_type.GetVendorType()));
|
|
100 |
|
49
|
101 |
aAllowed = EFalse;
|
26
|
102 |
}
|
|
103 |
}
|
|
104 |
else if (aTunnelingEapType == (*EapExpandedTypePeap.GetType())
|
|
105 |
|| aTunnelingEapType == (*EapExpandedTypeFast.GetType()))
|
|
106 |
{
|
|
107 |
// Filter out the EAP types which are NOT allowed inside PEAP or FAST.
|
|
108 |
if( CEapTypePlugin::IsDisallowedInsidePEAP( *aEapArray[counter] ) )
|
|
109 |
{
|
|
110 |
EAP_TRACE_DEBUG_SYMBIAN((_L("EapPluginTools::ListAllEapPluginsL(): aEapArray[%d] EAP-type=0xfe%06x%08x, IsDisallowedInsidePEAP()\n"),
|
|
111 |
counter,
|
|
112 |
plugin_type.GetVendorId(),
|
|
113 |
plugin_type.GetVendorType()));
|
|
114 |
|
49
|
115 |
aAllowed = EFalse;
|
26
|
116 |
}
|
|
117 |
}
|
|
118 |
else if (aTunnelingEapType == (*EapExpandedTypeTtls.GetType()))
|
|
119 |
{
|
|
120 |
// Filter out the EAP types which are NOT allowed inside TTLS.
|
|
121 |
if( CEapTypePlugin::IsDisallowedInsideTTLS( *aEapArray[counter] ) )
|
|
122 |
{
|
|
123 |
EAP_TRACE_DEBUG_SYMBIAN((_L("EapPluginTools::ListAllEapPluginsL(): aEapArray[%d] EAP-type=0xfe%06x%08x, IsDisallowedInsideTTLS()\n"),
|
|
124 |
counter,
|
|
125 |
plugin_type.GetVendorId(),
|
|
126 |
plugin_type.GetVendorType()));
|
|
127 |
|
49
|
128 |
aAllowed = EFalse;
|
26
|
129 |
}
|
|
130 |
}
|
49
|
131 |
else if (aTunnelingEapType != (*EapExpandedTypeNone.GetType()))
|
|
132 |
{
|
|
133 |
EAP_TRACE_DEBUG_SYMBIAN((_L("EapPluginTools::ListAllEapPluginsL(): aEapArray[%d] EAP-type=0xfe%06x%08x is NOT allowed inside EAP-type=0xfe%06x%08x\n"),
|
|
134 |
counter,
|
|
135 |
plugin_type.GetVendorId(),
|
|
136 |
plugin_type.GetVendorType(),
|
|
137 |
aTunnelingEapType.GetVendorId(),
|
|
138 |
aTunnelingEapType.GetVendorType()));
|
26
|
139 |
|
49
|
140 |
aAllowed = EFalse;
|
|
141 |
}
|
|
142 |
|
|
143 |
if (!aAllowed)
|
26
|
144 |
{
|
|
145 |
EAP_TRACE_DEBUG_SYMBIAN((_L("EapPluginTools::ListAllEapPluginsL(): Removes EAP-plugin aEapArray[%d] EAP-type=0xfe%06x%08x\n"),
|
|
146 |
counter,
|
|
147 |
plugin_type.GetVendorId(),
|
|
148 |
plugin_type.GetVendorType()));
|
|
149 |
|
|
150 |
// Delete the EAP type, which isn't allowed here from the array.
|
|
151 |
delete aEapArray[counter];
|
|
152 |
aEapArray.Remove( counter );
|
|
153 |
|
|
154 |
// One item removed from the array. So reduce the item counter.
|
|
155 |
counter--;
|
|
156 |
}
|
|
157 |
}
|
|
158 |
|
34
|
159 |
// Adds allowed EAP-methods to an array.
|
26
|
160 |
for (TInt ind = 0; ind < aEapArray.Count(); ind++ )
|
|
161 |
{
|
|
162 |
TEapExpandedType * eap_type = new TEapExpandedType;
|
|
163 |
if (eap_type != 0)
|
|
164 |
{
|
|
165 |
*eap_type = aEapArray[ind]->DataType();
|
|
166 |
|
|
167 |
EAP_TRACE_DEBUG_SYMBIAN((_L("EapPluginTools::ListAllEapPluginsL(): aEapArray[%d] EAP-type=0xfe%06x%08x\n"),
|
|
168 |
ind,
|
|
169 |
eap_type->GetVendorId(),
|
|
170 |
eap_type->GetVendorType()));
|
|
171 |
|
|
172 |
User::LeaveIfError( aPlugins.Append( eap_type ) );
|
|
173 |
}
|
|
174 |
}
|
|
175 |
|
|
176 |
CleanupStack::PopAndDestroy(&aEapArray);
|
|
177 |
}
|
|
178 |
|
|
179 |
// ----------------------------------------------------------------------
|
|
180 |
|
|
181 |
EXPORT_C void EapPluginTools::GetPrivatePathL(
|
|
182 |
RFs& aFileServerSession,
|
|
183 |
TFileName& aPrivateDatabasePathName)
|
|
184 |
{
|
34
|
185 |
// Reads the private folder. Caller must connect file server before calling this function.
|
26
|
186 |
|
34
|
187 |
CleanupClosePushL(aFileServerSession);
|
26
|
188 |
|
|
189 |
EAP_TRACE_DEBUG_SYMBIAN((_L("EapPluginTools::GetPrivatePathL(): - calls aFileServerSession.PrivatePath()\n")));
|
|
190 |
|
|
191 |
aPrivateDatabasePathName.SetLength(0);
|
|
192 |
|
34
|
193 |
TInt error = aFileServerSession.PrivatePath(aPrivateDatabasePathName);
|
26
|
194 |
|
|
195 |
EAP_TRACE_DEBUG_SYMBIAN((_L("EapPluginTools::GetPrivatePathL(): - aFileServerSession.PrivatePath(), error=%d\n"), error));
|
|
196 |
|
|
197 |
User::LeaveIfError(error);
|
|
198 |
|
|
199 |
EAP_TRACE_DATA_DEBUG_SYMBIAN(("aPrivateDatabasePathName",
|
|
200 |
aPrivateDatabasePathName.Ptr(),
|
|
201 |
aPrivateDatabasePathName.Size()));
|
34
|
202 |
|
|
203 |
CleanupStack::Pop(&aFileServerSession);
|
26
|
204 |
}
|
|
205 |
|
|
206 |
// ----------------------------------------------------------------------
|
|
207 |
|
|
208 |
EXPORT_C void EapPluginTools::GetPrivatePathL(
|
|
209 |
TFileName& aPrivateDatabasePathName)
|
|
210 |
{
|
|
211 |
// Reads the private folder.
|
|
212 |
|
|
213 |
RFs aFileServerSession;
|
|
214 |
|
34
|
215 |
EAP_TRACE_DEBUG_SYMBIAN((_L("EapPluginTools::GetPrivatePathL(): - calls aFileServerSession.Connect()\n")));
|
|
216 |
|
|
217 |
TInt error = aFileServerSession.Connect();
|
|
218 |
|
|
219 |
EAP_TRACE_DEBUG_SYMBIAN((_L("EapPluginTools::GetPrivatePathL(): - aFileServerSession.Connect(), error=%d\n"), error));
|
|
220 |
|
|
221 |
User::LeaveIfError(error);
|
|
222 |
|
26
|
223 |
EapPluginTools::GetPrivatePathL(
|
|
224 |
aFileServerSession,
|
|
225 |
aPrivateDatabasePathName);
|
34
|
226 |
|
|
227 |
aFileServerSession.Close();
|
26
|
228 |
}
|
|
229 |
|
|
230 |
// ----------------------------------------------------------------------
|
|
231 |
|
|
232 |
EXPORT_C void EapPluginTools::CreateDatabaseLC(
|
|
233 |
RDbNamedDatabase& aDatabase,
|
|
234 |
RFs& aFileServerSession,
|
|
235 |
TInt& error,
|
|
236 |
const TDesC& aDatabaseName,
|
|
237 |
TFileName& aPrivateDatabasePathName)
|
|
238 |
{
|
34
|
239 |
// Caller must connect file server before calling this function.
|
26
|
240 |
|
|
241 |
// aDatabase is pushed to the cleanup stack even though they may be member
|
|
242 |
// variables of the calling class and would be closed in the destructor anyway. This ensures
|
|
243 |
// that if they are not member variables they will be closed. Closing the handle twice
|
|
244 |
// does no harm.
|
34
|
245 |
CleanupClosePushL(aFileServerSession);
|
|
246 |
CleanupClosePushL(aDatabase);
|
26
|
247 |
|
|
248 |
// Create the private database in the private folder of EAP-server.
|
|
249 |
|
|
250 |
EapPluginTools::GetPrivatePathL(
|
|
251 |
aFileServerSession,
|
|
252 |
aPrivateDatabasePathName);
|
|
253 |
|
|
254 |
EAP_TRACE_DEBUG_SYMBIAN((_L("EapPluginTools::CreateDatabaseLC(): - calls aPrivateDatabasePathName.Append()\n")));
|
|
255 |
|
|
256 |
aPrivateDatabasePathName.Append(aDatabaseName);
|
|
257 |
|
|
258 |
EAP_TRACE_DATA_DEBUG_SYMBIAN(("aPrivateDatabasePathName",
|
|
259 |
aPrivateDatabasePathName.Ptr(),
|
|
260 |
aPrivateDatabasePathName.Size()));
|
|
261 |
|
|
262 |
User::LeaveIfError(error);
|
|
263 |
|
|
264 |
EAP_TRACE_DEBUG_SYMBIAN((_L("EapPluginTools::CreateDatabaseLC(): - calls aDatabase.Create()\n")));
|
|
265 |
|
|
266 |
error = aDatabase.Create(aFileServerSession, aPrivateDatabasePathName);
|
|
267 |
|
49
|
268 |
EAP_TRACE_DEBUG_SYMBIAN((_L("EapPluginTools::CreateDatabaseLC(): - Created private DB for %S. error=%d, (%d is KErrAlreadyExists, %d is KErrInUse)\n"),
|
26
|
269 |
&aDatabaseName,
|
|
270 |
error,
|
49
|
271 |
KErrAlreadyExists,
|
|
272 |
KErrInUse));
|
26
|
273 |
}
|
|
274 |
|
|
275 |
// ----------------------------------------------------------------------
|
|
276 |
// End
|