|
1 |
|
2 /* |
|
3 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
4 * All rights reserved. |
|
5 * This component and the accompanying materials are made available |
|
6 * under the terms of "Eclipse Public License v1.0" |
|
7 * which accompanies this distribution, and is available |
|
8 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 * |
|
10 * Initial Contributors: |
|
11 * Nokia Corporation - initial contribution. |
|
12 * |
|
13 * Contributors: |
|
14 * |
|
15 * Description: Class for loading and handling the plugins |
|
16 * |
|
17 */ |
|
18 |
|
19 #include <e32def.h> |
|
20 #include <centralrepository.h> |
|
21 |
|
22 #include <mccaparentcleaner.h> |
|
23 #include <mccapluginfactory.h> |
|
24 |
|
25 #include "Phonebook2PrivateCRKeys.h" |
|
26 #include "ccappheaders.h" |
|
27 #include "tccapluginsorderinfo.h" |
|
28 #include "ccapluginfactoryowner.h" |
|
29 #include "../../ccadetailsviewplugin/inc/ccappdetailsviewpluginuids.hrh" |
|
30 #include "../../ccacommlauncherplugin/inc/ccappcommlauncherpluginuids.hrh" |
|
31 |
|
32 // ======== CONSTANTS ============== |
|
33 const TInt KMaxPlugins = 255; |
|
34 //TODO: put these to common header |
|
35 _LIT8( KCcaOpaqueNameDelimiter, "\t" ); //Name=value pairs separated by tabs |
|
36 _LIT8( KCcaOpaqueValueDelimiter, "=" ); //Names and values separated by = |
|
37 _LIT8( KCcaOpaqueTABP, "TABP" ); //Tab position |
|
38 |
|
39 // ======== LOCAL FUNCTIONS ======== |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // OrderOfPlugins (local function) |
|
43 // |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 TInt OrderOfPlugins( const CImplementationInformation& aFirst, |
|
47 const CImplementationInformation& aSecond ) |
|
48 { |
|
49 TInt firstVal = KMaxPlugins; |
|
50 TInt secondVal = KMaxPlugins; |
|
51 |
|
52 TLex8 lex( aFirst.OpaqueData() ); |
|
53 lex.Val( firstVal ); |
|
54 |
|
55 lex = aSecond.OpaqueData(); |
|
56 lex.Val( secondVal ); |
|
57 |
|
58 if( firstVal < secondVal ) |
|
59 { |
|
60 return -1; |
|
61 } |
|
62 else if( firstVal == secondVal ) |
|
63 { |
|
64 return 0; |
|
65 } |
|
66 else |
|
67 { |
|
68 return 1; |
|
69 } |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // CleanupResetAndDestroy (local function) |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 void CleanupResetAndDestroy(TAny* aObj) |
|
77 { |
|
78 if (aObj) |
|
79 { |
|
80 static_cast<RImplInfoPtrArray*>(aObj)->ResetAndDestroy(); |
|
81 } |
|
82 } |
|
83 |
|
84 // ======== MEMBER FUNCTIONS ======== |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // CCCAppPluginLoader::CCCAppPluginLoader |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 CCCAppPluginLoader::CCCAppPluginLoader(MCCAppEngine* aAppEngine) : iAppEngine(aAppEngine) |
|
91 { |
|
92 CCA_DP( KCCAppLogFile, CCA_L("CCCAppPluginData::CCCAppPluginLoader")); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // CCCAppPluginLoader::~CCCAppPluginLoader |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 CCCAppPluginLoader::~CCCAppPluginLoader() |
|
100 { |
|
101 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppPluginData::~CCCAppPluginLoader")); |
|
102 |
|
103 //Nullify pointer to AppEngine in plugins as otherwise it will point to object |
|
104 //that doesn't exist anymore at this point of execution (because views are |
|
105 //deleted after AppEngine). |
|
106 for(TInt i = 0; i < PluginsCount(); i++) |
|
107 { |
|
108 CCCAppViewPluginBase& plugin(iPluginDataArray[i]->Plugin()); |
|
109 plugin.SetAppEngine(NULL); |
|
110 } |
|
111 |
|
112 iPluginDataArray.ResetAndDestroy(); |
|
113 delete iFactoryTempPtr; |
|
114 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::~CCCAppPluginLoader")); |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CCCAppPluginLoader::NewL |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 CCCAppPluginLoader* CCCAppPluginLoader::NewL( |
|
122 MCCAppEngine* aAppEngine, |
|
123 const TDesC8& aPluginProperties, |
|
124 const TDesC8& aTypeFilter ) |
|
125 { |
|
126 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppPluginData::NewL")); |
|
127 |
|
128 CCCAppPluginLoader* self = new( ELeave ) CCCAppPluginLoader(aAppEngine); |
|
129 CleanupStack::PushL( self ); |
|
130 self->ConstructL(aPluginProperties, aTypeFilter ); |
|
131 CleanupStack::Pop( self ); |
|
132 |
|
133 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::NewL")); |
|
134 return self; |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // CCCAppPluginLoader::ConstructL |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 void CCCAppPluginLoader::ConstructL( |
|
142 const TDesC8& aPluginProperties, |
|
143 const TDesC8& aTypeFilter ) |
|
144 { |
|
145 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppPluginData::ConstructL")); |
|
146 |
|
147 //PERFORMANCE LOGGING: 3. Loading plugins |
|
148 WriteToPerfLog(); |
|
149 |
|
150 RPointerArray<CImplementationInformation> oldImplInfoArray; |
|
151 CleanupStack::PushL(TCleanupItem(CleanupResetAndDestroy, &oldImplInfoArray)); |
|
152 RPointerArray<CImplementationInformation> newImplInfoArray; |
|
153 CleanupStack::PushL(TCleanupItem(CleanupResetAndDestroy, &newImplInfoArray)); |
|
154 |
|
155 FeatureManager::InitializeLibL(); |
|
156 const TBool myCardSupported( |
|
157 FeatureManager::FeatureSupported( KFeatureIdffContactsMycard ) ); |
|
158 FeatureManager::UnInitializeLib(); |
|
159 |
|
160 // A. List legacy and new implementations |
|
161 if( myCardSupported && |
|
162 aTypeFilter.Length() > 0 ) |
|
163 { |
|
164 TEComResolverParams params; |
|
165 params.SetDataType( aTypeFilter ); |
|
166 |
|
167 REComSession::ListImplementationsL( |
|
168 TUid::Uid(KCCAppViewPluginBaseInterfaceUID), |
|
169 params, oldImplInfoArray ); |
|
170 REComSession::ListImplementationsL( KCCAppViewFactoryInterfaceUID, |
|
171 params, newImplInfoArray ); |
|
172 } |
|
173 else |
|
174 { |
|
175 REComSession::ListImplementationsL( |
|
176 TUid::Uid(KCCAppViewPluginBaseInterfaceUID), |
|
177 oldImplInfoArray ); |
|
178 REComSession::ListImplementationsL( KCCAppViewFactoryInterfaceUID, |
|
179 newImplInfoArray ); |
|
180 } |
|
181 |
|
182 if ( !myCardSupported && |
|
183 !oldImplInfoArray.Count() ) //At least one legacy plugin needed |
|
184 {// no plugins, nothing can be done |
|
185 CCA_DP( KCCAppLogFile, CCA_L( "::ConstructL - no plugins found!")); |
|
186 User::Leave( KErrNotFound ); |
|
187 } |
|
188 |
|
189 // B. Sort implementations into same order as are in Phonebook |
|
190 // each stores pluginInfo (from oldImplInfoArray) address and order |
|
191 RArray<TCCAPluginsOrderInfo> pluginOrderArray; |
|
192 CleanupClosePushL( pluginOrderArray ); |
|
193 RArray<TPtrC> nameArray; // stores phonebooksXPExtension plugins name |
|
194 CleanupClosePushL(nameArray); |
|
195 |
|
196 // store phonebook mainview sXPExtension's name from CenRep to nameArray |
|
197 CRepository* repository = CRepository::NewLC( TUid::Uid(KCRUidPhonebook)); |
|
198 HBufC* names = HBufC::NewLC(NCentralRepositoryConstants::KMaxUnicodeStringLength); |
|
199 TPtr namesPtr = names->Des(); |
|
200 |
|
201 // get key value, which stores phonebook sXPExtension Plugins name |
|
202 TInt error = repository->Get(KPhonebooksXPExtensionPluginsName, namesPtr); |
|
203 |
|
204 // e.g if the bey value is "MSN|Ovi|Sonera|....",then MSN, Ovi and Sonera |
|
205 // will be appended to aPbksXPExtesionNamesArray |
|
206 GetPbksXPExtesionNamesL(nameArray, *names); //parses names to namearray |
|
207 |
|
208 |
|
209 // copy CImplementationInformation's address from oldImplInfoArray to pluginOrderArray |
|
210 GetPluginsInfoL(pluginOrderArray, nameArray, oldImplInfoArray, newImplInfoArray); |
|
211 |
|
212 SortPluginsOrderInfoL( pluginOrderArray, nameArray ); |
|
213 |
|
214 // C. Load implementations in defined order |
|
215 LoadAllPlugins(pluginOrderArray, aPluginProperties); |
|
216 |
|
217 CleanupStack::PopAndDestroy(names); |
|
218 CleanupStack::PopAndDestroy(repository); |
|
219 |
|
220 CleanupStack::PopAndDestroy(); //nameArray |
|
221 CleanupStack::PopAndDestroy(); //pluginOrderArray |
|
222 CleanupStack::PopAndDestroy(&newImplInfoArray); |
|
223 CleanupStack::PopAndDestroy(&oldImplInfoArray); |
|
224 //PERFORMANCE LOGGING: 4. Plugins loaded |
|
225 WriteToPerfLog(); |
|
226 |
|
227 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::ConstructL")); |
|
228 } |
|
229 |
|
230 // --------------------------------------------------------------------------- |
|
231 // CCCAppPluginLoader::LoadOneMultiViewPluginL |
|
232 // --------------------------------------------------------------------------- |
|
233 // |
|
234 void CCCAppPluginLoader::LoadOneMultiViewPluginL( |
|
235 CImplementationInformation* aImplementationInformation) |
|
236 { |
|
237 __ASSERT_DEBUG(!iFactoryTempPtr, User::Panic(_L("CCCAppPluginLoad"), KErrAlreadyExists)); |
|
238 iFactoryTempPtr = CcaPluginFactoryOwner::NewL(aImplementationInformation); |
|
239 CcaPluginFactoryOwner* factory = iFactoryTempPtr; |
|
240 |
|
241 for(TInt j=0; j < factory->Factory().TabViewCount(); j++) |
|
242 { |
|
243 CCCAppViewPluginBase* plugin = factory->Factory().CreateTabViewL(j); |
|
244 CleanupStack::PushL(plugin); |
|
245 CCCAppPluginData* data = CCCAppPluginData::NewLC(*plugin); //Handles plugin ownership |
|
246 CleanupStack::Pop(2, plugin); |
|
247 CleanupStack::PushL(data); |
|
248 iPluginDataArray.AppendL( data ); |
|
249 CleanupStack::Pop(data); |
|
250 data->SetPluginVisibility( CCCAppPluginData::EPluginHidden ); |
|
251 |
|
252 //Hand over ownership of factoryOwner (shared ownership among tabs created by factory) |
|
253 factory->AddedChild(); |
|
254 plugin->TakeSharedOwnerShip( factory ); |
|
255 iFactoryTempPtr = NULL; //ownership given |
|
256 } |
|
257 |
|
258 //If ownership was not given |
|
259 delete iFactoryTempPtr; |
|
260 iFactoryTempPtr = NULL; |
|
261 } |
|
262 |
|
263 // --------------------------------------------------------------------------- |
|
264 // CCCAppPluginLoader::LoadAllPlugins |
|
265 // --------------------------------------------------------------------------- |
|
266 // |
|
267 void CCCAppPluginLoader::LoadAllPlugins( |
|
268 const RArray<TCCAPluginsOrderInfo>& aPluginOrderInfoArray, const TDesC8& aPluginProperties ) |
|
269 { |
|
270 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppPluginData::LoadAllPlugins")); |
|
271 |
|
272 const TInt count = aPluginOrderInfoArray.Count(); |
|
273 CCA_DP( KCCAppLogFile, CCA_L("::LoadAllPlugins - plugin count: %d"), count ); |
|
274 for ( TInt i = 0; i < count; ++i ) |
|
275 { |
|
276 /* If problems with plugin loading, that plugin is |
|
277 * not included to the plugin array. Just continuing |
|
278 * and trying to load the next one. */ |
|
279 TRAP_IGNORE( CheckAndLoadPluginL( |
|
280 aPluginOrderInfoArray[i], aPluginProperties )); |
|
281 } |
|
282 |
|
283 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::LoadAllPlugins")); |
|
284 } |
|
285 |
|
286 // --------------------------------------------------------------------------- |
|
287 // CCCAppPluginLoader::CheckAndLoadPluginL |
|
288 // --------------------------------------------------------------------------- |
|
289 // |
|
290 void CCCAppPluginLoader::CheckAndLoadPluginL( |
|
291 const TCCAPluginsOrderInfo& aPluginsOrderInfo, |
|
292 const TDesC8& aPluginProperties ) |
|
293 { |
|
294 HBufC8* match = GetmachingPropertiesLC( |
|
295 aPluginsOrderInfo.iPluginInfor->OpaqueData(), |
|
296 aPluginProperties, |
|
297 EFalse ); |
|
298 TBool loadThis = match->Length() > 0; |
|
299 CleanupStack::PopAndDestroy(match); |
|
300 |
|
301 //Fallback1 for old plugins that provide only number in opaque data: load them always |
|
302 //The below if{} can be removed when legacy plugins support new format of OpaqueData |
|
303 if(!loadThis) |
|
304 { |
|
305 loadThis = OpaqueValueFrom( *aPluginsOrderInfo.iPluginInfor ) > 0; |
|
306 } |
|
307 |
|
308 if( loadThis ) |
|
309 { |
|
310 TUid uid = aPluginsOrderInfo.iPluginInfor->ImplementationUid(); |
|
311 |
|
312 if( aPluginsOrderInfo.iOldInterFaceType ) |
|
313 { |
|
314 LoadPluginL(uid); //lecacy implementations |
|
315 } |
|
316 else |
|
317 { |
|
318 LoadOneMultiViewPluginL( aPluginsOrderInfo.iPluginInfor ); //New implementations |
|
319 } |
|
320 CCA_DP( KCCAppLogFile, CCA_L("::LoadAllPlugins - plugin loaded uid: %d"), uid.iUid ); |
|
321 } |
|
322 } |
|
323 |
|
324 // --------------------------------------------------------------------------- |
|
325 // CCCAppPluginLoader::LoadPluginL |
|
326 // --------------------------------------------------------------------------- |
|
327 // |
|
328 void CCCAppPluginLoader::LoadPluginL( |
|
329 TUid aImplementationUid ) |
|
330 { |
|
331 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppPluginData::LoadPluginL")); |
|
332 |
|
333 CCCAppViewPluginBase* plugin = |
|
334 CCCAppViewPluginBase::NewL( aImplementationUid ); |
|
335 plugin->SetAppEngine(iAppEngine); |
|
336 CCA_DP( KCCAppLogFile, CCA_L("::LoadPluginL - plugin created")); |
|
337 CleanupStack::PushL( plugin ); |
|
338 User::LeaveIfError( aImplementationUid == plugin->Id() ? KErrNone : KErrArgument ); |
|
339 CCCAppPluginData* data = CCCAppPluginData::NewLC( *plugin ); |
|
340 data->SetPluginVisibility( CCCAppPluginData::EPluginHidden ); |
|
341 iPluginDataArray.AppendL( data ); |
|
342 CCA_DP( KCCAppLogFile, CCA_L("::LoadPluginL - plugin added to iPluginDataArray")); |
|
343 CleanupStack::Pop( 2, plugin );// data, plugin |
|
344 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::LoadPluginL")); |
|
345 } |
|
346 |
|
347 // --------------------------------------------------------------------------- |
|
348 // CCCAppPluginLoader::NextPlugin |
|
349 // --------------------------------------------------------------------------- |
|
350 // |
|
351 CCCAppPluginData* CCCAppPluginLoader::NextPlugin( TBool aOnlyVisiblePlugins ) |
|
352 { |
|
353 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppPluginData::NextPlugin")); |
|
354 CCA_DP( KCCAppLogFile, CCA_L("::NextPlugin - iCurrentPlugin: %d"), iCurrentPlugin ); |
|
355 |
|
356 for(TInt i = iCurrentPlugin+1; i < PluginsCount(); i++) |
|
357 { |
|
358 if( !aOnlyVisiblePlugins ) |
|
359 { |
|
360 return iPluginDataArray[iCurrentPlugin = i]; |
|
361 } |
|
362 else if( iPluginDataArray[i]->PluginVisibility() == CCCAppPluginData::EPluginVisible ) |
|
363 { |
|
364 return iPluginDataArray[iCurrentPlugin = i]; |
|
365 } |
|
366 } |
|
367 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::NextPlugin - no next")); |
|
368 return NULL; |
|
369 } |
|
370 |
|
371 // --------------------------------------------------------------------------- |
|
372 // CCCAppPluginLoader::PreviousPlugin |
|
373 // --------------------------------------------------------------------------- |
|
374 // |
|
375 CCCAppPluginData* CCCAppPluginLoader::PreviousPlugin( TBool aOnlyVisiblePlugins ) |
|
376 { |
|
377 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppPluginData::PreviousPlugin")); |
|
378 CCA_DP( KCCAppLogFile, CCA_L("::PreviousPlugin - iCurrentPlugin: %d"), iCurrentPlugin ); |
|
379 |
|
380 for(TInt i = iCurrentPlugin-1; i >= 0; i--) |
|
381 { |
|
382 if( !aOnlyVisiblePlugins ) |
|
383 { |
|
384 return iPluginDataArray[iCurrentPlugin = i]; |
|
385 } |
|
386 else if( iPluginDataArray[i]->PluginVisibility() == CCCAppPluginData::EPluginVisible ) |
|
387 { |
|
388 return iPluginDataArray[iCurrentPlugin = i]; |
|
389 } |
|
390 } |
|
391 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::PreviousPlugin - no previous")); |
|
392 return NULL; |
|
393 } |
|
394 |
|
395 // --------------------------------------------------------------------------- |
|
396 // CCCAppPluginLoader::SetPluginInFocus |
|
397 // --------------------------------------------------------------------------- |
|
398 // |
|
399 TInt CCCAppPluginLoader::SetPluginInFocus( const TUid aUid ) |
|
400 { |
|
401 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppPluginData::SetPluginInFocus")); |
|
402 CCA_DP( KCCAppLogFile, CCA_L("::SetPluginInFocus - searching aUid: %d"), aUid ); |
|
403 |
|
404 TInt index = KErrNotFound; |
|
405 // no need to search if no uid provided |
|
406 if ( TUid::Null() == aUid ) |
|
407 return index; |
|
408 |
|
409 const TInt count = iPluginDataArray.Count(); |
|
410 CCA_DP( KCCAppLogFile, CCA_L("::SetPluginInFocus - plugin count: %d"), count ); |
|
411 for ( TInt i = 0; i < count; ++i ) |
|
412 { |
|
413 TUid uid( iPluginDataArray[i]->Plugin().Id() ); |
|
414 CCA_DP( KCCAppLogFile, CCA_L("::SetPluginInFocus - uid: %d found"), uid ); |
|
415 if( aUid == uid ) |
|
416 { |
|
417 index = i; |
|
418 iCurrentPlugin = i; |
|
419 break;// found, no need to loop all through |
|
420 } |
|
421 } |
|
422 CCA_DP( KCCAppLogFile, CCA_L("::SetPluginInFocus - index after searching the array %d"), index ); |
|
423 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::SetPluginInFocus")); |
|
424 return index; |
|
425 } |
|
426 |
|
427 // --------------------------------------------------------------------------- |
|
428 // CCCAppPluginLoader::PluginInFocus |
|
429 // --------------------------------------------------------------------------- |
|
430 // |
|
431 CCCAppPluginData* CCCAppPluginLoader::PluginInFocus( ) |
|
432 { |
|
433 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppPluginData::PluginInFocus")); |
|
434 CCA_DP( KCCAppLogFile, CCA_L("::PluginInFocus - iCurrentPlugin: %d"), iCurrentPlugin ); |
|
435 |
|
436 if ( 0 > iCurrentPlugin || iCurrentPlugin > PluginsCount()-1 ) |
|
437 { |
|
438 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::PluginInFocus - not in range")); |
|
439 return NULL; |
|
440 } |
|
441 else |
|
442 { |
|
443 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::PluginInFocus - found in range")); |
|
444 return iPluginDataArray[ iCurrentPlugin ]; |
|
445 } |
|
446 } |
|
447 |
|
448 // --------------------------------------------------------------------------- |
|
449 // CCCAppPluginLoader::PluginsCount |
|
450 // --------------------------------------------------------------------------- |
|
451 // |
|
452 TInt CCCAppPluginLoader::PluginsCount( ) const |
|
453 { |
|
454 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppPluginData::PluginsCount")); |
|
455 const TInt count = iPluginDataArray.Count(); |
|
456 CCA_DP( KCCAppLogFile, CCA_L("::PluginsCount - count %d"), count ); |
|
457 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::PluginsCount")); |
|
458 return count; |
|
459 } |
|
460 |
|
461 // --------------------------------------------------------------------------- |
|
462 // CCCAppPluginLoader::VisiblePluginCount |
|
463 // --------------------------------------------------------------------------- |
|
464 // |
|
465 TInt CCCAppPluginLoader::VisiblePluginCount( ) const |
|
466 { |
|
467 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppPluginData::VisiblePluginCount")); |
|
468 TInt count(0); |
|
469 for(TInt i = 0; i < iPluginDataArray.Count(); i++ ) |
|
470 { |
|
471 CCCAppPluginData* dta = iPluginDataArray[i]; |
|
472 if( dta->PluginVisibility() == CCCAppPluginData::EPluginVisible) |
|
473 { |
|
474 count++; |
|
475 } |
|
476 } |
|
477 |
|
478 CCA_DP( KCCAppLogFile, CCA_L("::VisiblePluginCount - count %d"), count ); |
|
479 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::VisiblePluginCount")); |
|
480 return count; |
|
481 } |
|
482 |
|
483 |
|
484 // --------------------------------------------------------------------------- |
|
485 // CCCAppPluginLoader::VisiblePlugin |
|
486 // --------------------------------------------------------------------------- |
|
487 // |
|
488 CCCAppPluginData* CCCAppPluginLoader::VisiblePlugin( TInt aIndex, TBool aChangefocus ) |
|
489 { |
|
490 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppPluginData::VisiblePluginAt")); |
|
491 CCA_DP( KCCAppLogFile, CCA_L("::VisiblePluginAt - aIndex %d"), aIndex ); |
|
492 TInt visiblePlugin(KErrNotFound); |
|
493 |
|
494 for(TInt i = 0; i < PluginsCount(); i++) |
|
495 { |
|
496 if( iPluginDataArray[i]->PluginVisibility() == CCCAppPluginData::EPluginVisible ) |
|
497 { |
|
498 visiblePlugin++; |
|
499 } |
|
500 if( visiblePlugin == aIndex ) |
|
501 { |
|
502 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::VisiblePluginAt - found in range")); |
|
503 return PluginAt( i, aChangefocus ); |
|
504 } |
|
505 } |
|
506 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::VisiblePluginAt - not in visible range")); |
|
507 return NULL; |
|
508 } |
|
509 |
|
510 |
|
511 // --------------------------------------------------------------------------- |
|
512 // CCCAppPluginLoader::PluginAt |
|
513 // --------------------------------------------------------------------------- |
|
514 // |
|
515 CCCAppPluginData* CCCAppPluginLoader::PluginAt( TInt aIndex, TBool aChangefocus ) |
|
516 { |
|
517 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppPluginData::PluginAt")); |
|
518 CCA_DP( KCCAppLogFile, CCA_L("::PluginAt - aIndex %d"), aIndex ); |
|
519 |
|
520 const TInt count = PluginsCount(); |
|
521 if ( 0 == count || 0 > aIndex || (count - 1) < aIndex ) |
|
522 { |
|
523 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::PluginAt - not in range")); |
|
524 return NULL; |
|
525 } |
|
526 else |
|
527 { |
|
528 CCA_DP( KCCAppLogFile, CCA_L("<-CCCAppPluginData::PluginAt - found in range")); |
|
529 if ( aChangefocus ) |
|
530 iCurrentPlugin = aIndex; |
|
531 return iPluginDataArray[ aIndex ]; |
|
532 } |
|
533 } |
|
534 |
|
535 // --------------------------------------------------------------------------- |
|
536 // CCCAppPluginLoader::RemovePlugin |
|
537 // --------------------------------------------------------------------------- |
|
538 // |
|
539 void CCCAppPluginLoader::RemovePlugin( TUid aPlugin ) |
|
540 { |
|
541 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppPluginData::RemovePlugin")); |
|
542 CCA_DP( KCCAppLogFile, CCA_L("::RemovePlugin - aPlugin %d"), aPlugin ); |
|
543 |
|
544 TInt count = PluginsCount(); |
|
545 |
|
546 for ( TInt i = 0; i < count; ++i ) |
|
547 { |
|
548 TUid id = iPluginDataArray[ i ]->Plugin().Id(); |
|
549 if( aPlugin == id ) |
|
550 { |
|
551 // delete |
|
552 delete iPluginDataArray[ i ]; |
|
553 iPluginDataArray.Remove( i ); |
|
554 break; |
|
555 } |
|
556 } |
|
557 } |
|
558 |
|
559 // --------------------------------------------------------------------------- |
|
560 // CCCAppPluginLoader::Plugin |
|
561 // --------------------------------------------------------------------------- |
|
562 // |
|
563 CCCAppViewPluginBase* CCCAppPluginLoader::Plugin( TUid aPlugin ) |
|
564 { |
|
565 CCA_DP( KCCAppLogFile, CCA_L("->CCCAppPluginData::Plugin")); |
|
566 CCA_DP( KCCAppLogFile, CCA_L("::Plugin - aPlugin %d"), aPlugin ); |
|
567 |
|
568 TInt count = PluginsCount(); |
|
569 |
|
570 for ( TInt i = 0; i < count; ++i ) |
|
571 { |
|
572 TUid id = iPluginDataArray[ i ]->Plugin().Id(); |
|
573 if( aPlugin == id ) |
|
574 { |
|
575 return &(iPluginDataArray[ i ]->Plugin()); |
|
576 } |
|
577 } |
|
578 return NULL; |
|
579 } |
|
580 |
|
581 // --------------------------------------------------------------------------- |
|
582 // CCCAppPluginLoader::SetPluginVisibility |
|
583 // --------------------------------------------------------------------------- |
|
584 // |
|
585 TBool CCCAppPluginLoader::SetPluginVisibility( |
|
586 TUid aPlugin, |
|
587 TInt aVisibility) |
|
588 { |
|
589 TBool ret(EFalse); |
|
590 const TInt count = iPluginDataArray.Count(); |
|
591 CCA_DP( KCCAppLogFile, CCA_L("::SetPluginVisibility - plugin count: %d"), count ); |
|
592 for ( TInt i = 0; i < count; i++ ) |
|
593 { |
|
594 TUid uid( iPluginDataArray[i]->Plugin().Id() ); |
|
595 if( aPlugin == uid ) |
|
596 { |
|
597 if( aVisibility != iPluginDataArray[i]->PluginVisibility() ) |
|
598 { |
|
599 iPluginDataArray[i]->SetPluginVisibility( aVisibility ); |
|
600 ret = ETrue; |
|
601 } |
|
602 |
|
603 break; |
|
604 } |
|
605 } |
|
606 return ret; |
|
607 } |
|
608 |
|
609 // --------------------------------------------------------------------------- |
|
610 // CCCAppPluginLoader::SetPluginVisibility |
|
611 // --------------------------------------------------------------------------- |
|
612 // |
|
613 TInt CCCAppPluginLoader::PluginVisibility( |
|
614 TUid aPlugin, TInt& aTabNbr ) |
|
615 { |
|
616 TInt visibility(KErrNotFound); |
|
617 TInt tabNbr(KErrNotFound); |
|
618 const TInt count = iPluginDataArray.Count(); |
|
619 CCA_DP( KCCAppLogFile, CCA_L("::SetPluginVisibility - plugin count: %d"), count ); |
|
620 |
|
621 for ( TInt i = 0; i < count; i++ ) |
|
622 { |
|
623 if(iPluginDataArray[i]->PluginVisibility() == CCCAppPluginData::EPluginVisible) |
|
624 { |
|
625 tabNbr++; |
|
626 } |
|
627 TUid uid( iPluginDataArray[i]->Plugin().Id() ); |
|
628 if( aPlugin == uid ) |
|
629 { |
|
630 visibility = iPluginDataArray[i]->PluginVisibility(); |
|
631 if(visibility == CCCAppPluginData::EPluginVisible) |
|
632 { |
|
633 aTabNbr = tabNbr; |
|
634 } |
|
635 break; |
|
636 } |
|
637 } |
|
638 return visibility; |
|
639 } |
|
640 |
|
641 // --------------------------------------------------------------------------- |
|
642 // CCCAppPluginLoader::GetPbksXPExtesionNamesL |
|
643 // --------------------------------------------------------------------------- |
|
644 // |
|
645 void CCCAppPluginLoader::GetPbksXPExtesionNamesL( RArray<TPtrC>& aPbksXPExtesionNamesArray, |
|
646 const TDesC& aNameString) |
|
647 { |
|
648 TLex nameString ( aNameString ); |
|
649 TChar curChar; |
|
650 nameString.Mark(); |
|
651 while( !nameString.Eos() ) |
|
652 { |
|
653 curChar = nameString.Peek(); |
|
654 if( curChar == '|' ) |
|
655 { |
|
656 TPtrC extractedName = nameString.MarkedToken(); |
|
657 User::LeaveIfError(aPbksXPExtesionNamesArray.Append(extractedName)); |
|
658 |
|
659 nameString.Inc(); |
|
660 nameString.Mark(); |
|
661 } |
|
662 else |
|
663 { |
|
664 nameString.Inc(); |
|
665 } |
|
666 } |
|
667 } |
|
668 |
|
669 // --------------------------------------------------------------------------- |
|
670 // CCCAppPluginLoader::LargestOpaqueFromInHousePlugins |
|
671 // --------------------------------------------------------------------------- |
|
672 // |
|
673 TInt CCCAppPluginLoader::LargestOpaqueFromInHousePlugins( RArray<TCCAPluginsOrderInfo>& aOrderInfoArray ) |
|
674 { |
|
675 TInt largestOpaqueFromInHouse = 0; |
|
676 for ( TInt i=0; i<aOrderInfoArray.Count(); i++ ) |
|
677 { |
|
678 // this is for plugins in group ECCAInHousePlugins, the purpose of doing this |
|
679 // is find start position for plugins in group ECCAPlugindInBothCCAAndNameList. |
|
680 // this means if opaque values in group ECCAInHousePlugins are negative, |
|
681 // Initial value if largestOpaqueFromInHouse 0 will be taked to be used. |
|
682 // if they are positive values, find the largest |
|
683 TInt order = aOrderInfoArray[i].iOrder; |
|
684 if (aOrderInfoArray[i].iGroupInfo == TCCAPluginsOrderInfo::ECCAInHousePlugins && |
|
685 order > largestOpaqueFromInHouse ) |
|
686 { |
|
687 largestOpaqueFromInHouse = order; |
|
688 } |
|
689 } |
|
690 return largestOpaqueFromInHouse; |
|
691 } |
|
692 |
|
693 // --------------------------------------------------------------------------- |
|
694 // CCCAppPluginLoader::SmallestOpaqueFromPluginsOnlyInCCA |
|
695 // --------------------------------------------------------------------------- |
|
696 // |
|
697 TInt CCCAppPluginLoader::SmallestOpaqueFromPluginsOnlyInCCA( RArray<TCCAPluginsOrderInfo>& aOrderInfoArray ) |
|
698 { |
|
699 TInt smallestOpaque = 0; |
|
700 for ( TInt i=0; i<aOrderInfoArray.Count(); i++ ) |
|
701 { |
|
702 // for plugins in group ECCAPlugindInBothCCAAndNameList, orders are follow as |
|
703 // corresponding sXPextension in Name List view. |
|
704 |
|
705 // this is for plugins in group ECCAPluginsOnlyInCCA. the purpose of doing this is |
|
706 // find start positions for plugins in group ECCAPluginsOnlyInCCA if there is negative |
|
707 // opaque value. if no negative values, the start postion of plugins in this |
|
708 // ECCAPluginsOnlyInCCA group should follow the last one's opaque value in group |
|
709 // ECCAPlugindInBothCCAAndNameList |
|
710 TInt order = aOrderInfoArray[i].iOrder; |
|
711 if (aOrderInfoArray[i].iGroupInfo == TCCAPluginsOrderInfo::ECCAPluginsOnlyInCCA && |
|
712 order < smallestOpaque ) |
|
713 { |
|
714 smallestOpaque = order; |
|
715 } |
|
716 } |
|
717 return smallestOpaque; |
|
718 } |
|
719 |
|
720 // --------------------------------------------------------------------------- |
|
721 // CCCAppPluginLoader::UpdateOrdersForPluginsOnlyInCCA |
|
722 // --------------------------------------------------------------------------- |
|
723 // |
|
724 void CCCAppPluginLoader::UpdateOrdersForPluginsOnlyInCCA( |
|
725 const TInt aStartPosition, |
|
726 RArray<TCCAPluginsOrderInfo>& aOrderInfoArray) |
|
727 { |
|
728 for ( TInt i=0; i<aOrderInfoArray.Count(); i++ ) |
|
729 { |
|
730 if( aOrderInfoArray[i].iGroupInfo == TCCAPluginsOrderInfo::ECCAPluginsOnlyInCCA ) |
|
731 { |
|
732 aOrderInfoArray[i].iOrder = aOrderInfoArray[i].iOrder + aStartPosition; |
|
733 } |
|
734 } |
|
735 } |
|
736 |
|
737 // --------------------------------------------------------------------------- |
|
738 // CCCAppPluginLoader::UpdateOrdersForPluginsInBothCCAAndNameList |
|
739 // --------------------------------------------------------------------------- |
|
740 // |
|
741 void CCCAppPluginLoader::UpdateOrdersForPluginsInBothCCAAndNameList( |
|
742 TInt& aLastPosition, |
|
743 RArray<TCCAPluginsOrderInfo>& aOrderInfoArray, |
|
744 const RArray<TPtrC>& aNameListPluginNameArray) |
|
745 { |
|
746 // go through phonebook main view's sXP Extension plugins name list |
|
747 // Group2 means ECCAPlugindInBothCCAAndNameList |
|
748 TInt startPosition = aLastPosition; |
|
749 for ( TInt i=0; i<aNameListPluginNameArray.Count(); i++ ) |
|
750 { |
|
751 TInt found = EFalse; |
|
752 for ( TInt j=0; j<aOrderInfoArray.Count() && !found; j++ ) |
|
753 { |
|
754 if( aNameListPluginNameArray[i].CompareF(aOrderInfoArray[j].iPluginInfor->DisplayName()) == 0 |
|
755 && aOrderInfoArray[j].iGroupInfo == TCCAPluginsOrderInfo::ECCAPlugindInBothCCAAndNameList ) |
|
756 { |
|
757 aOrderInfoArray[j].iOrder = startPosition + 1 + i; |
|
758 aLastPosition = aOrderInfoArray[j].iOrder; |
|
759 found = ETrue; |
|
760 } |
|
761 } |
|
762 } |
|
763 |
|
764 } |
|
765 |
|
766 // --------------------------------------------------------------------------- |
|
767 // CCCAppPluginLoader::SortPluginsOrderInfoL |
|
768 // --------------------------------------------------------------------------- |
|
769 // |
|
770 void CCCAppPluginLoader::SortPluginsOrderInfoL( RArray<TCCAPluginsOrderInfo>& aOrderInfoArray, |
|
771 const RArray<TPtrC>& aNameListPluginNameArray) |
|
772 { |
|
773 // largest opaque from in-house plugins |
|
774 TInt largestOpaqueFromGroup1 = LargestOpaqueFromInHousePlugins(aOrderInfoArray); |
|
775 |
|
776 // go through phonebook main view's sXP Extension plugins name list |
|
777 // Group2 means ECCAPlugindInBothCCAAndNameList |
|
778 TInt lastPosInGroup2 = largestOpaqueFromGroup1 + 1; |
|
779 |
|
780 UpdateOrdersForPluginsInBothCCAAndNameList(lastPosInGroup2, aOrderInfoArray, aNameListPluginNameArray); |
|
781 |
|
782 // Group3 means ECCAPluginsOnlyInCCA |
|
783 TInt startPosInGroup3 = lastPosInGroup2 + 1; |
|
784 |
|
785 // smallest opaque from ECCAPluginsOnlyInCCA |
|
786 TInt smallestOpaqueFromGroup3 = SmallestOpaqueFromPluginsOnlyInCCA(aOrderInfoArray); |
|
787 |
|
788 // if there are negative opaque values from group3 |
|
789 if (smallestOpaqueFromGroup3 < 0) |
|
790 { |
|
791 startPosInGroup3 = startPosInGroup3 - smallestOpaqueFromGroup3; |
|
792 } |
|
793 |
|
794 UpdateOrdersForPluginsOnlyInCCA(startPosInGroup3, aOrderInfoArray); |
|
795 |
|
796 // after opaque value(iOrder) has been handled for each of three group: |
|
797 // ECCAInHousePlugins, ECCAPlugindInBothCCAAndNameList and ECCAPluginsOnlyInCCA |
|
798 // finally sort the aOrderInfoArray by iOrder |
|
799 TLinearOrder< TCCAPluginsOrderInfo > order( *TCCAPluginsOrderInfo::SortByOrder ); |
|
800 aOrderInfoArray.Sort( order ); |
|
801 } |
|
802 |
|
803 // --------------------------------------------------------------------------- |
|
804 // CCCAppPluginLoader::FindPluginNameFromNameListByCCAPluginInfo |
|
805 // --------------------------------------------------------------------------- |
|
806 // |
|
807 TInt CCCAppPluginLoader::FindPluginNameFromNameListByCCAPluginInfo( |
|
808 const CImplementationInformation& aCCAPluginInfo, |
|
809 const RArray<TPtrC>& aNameListPluginNameArray) |
|
810 { |
|
811 TInt result = KErrNotFound; |
|
812 for ( TInt i=0; i<aNameListPluginNameArray.Count() && result == KErrNotFound; i++ ) |
|
813 { |
|
814 if( aNameListPluginNameArray[i].CompareF( aCCAPluginInfo.DisplayName())==0 ) |
|
815 { |
|
816 result = i; |
|
817 } |
|
818 } |
|
819 return result; |
|
820 } |
|
821 |
|
822 // --------------------------------------------------------------------------- |
|
823 // CCCAppPluginLoader::GetPluginsInfoL |
|
824 // --------------------------------------------------------------------------- |
|
825 // |
|
826 void CCCAppPluginLoader::GetPluginsInfoL( RArray<TCCAPluginsOrderInfo>& aOrderInfoArray, |
|
827 const RArray<TPtrC>& aNameListPluginNameArray, |
|
828 RPointerArray<CImplementationInformation>& aOldPluginInfoArray, |
|
829 RPointerArray<CImplementationInformation>& aNewPluginInfoArray) |
|
830 { |
|
831 //1. For lecagy interface implementations |
|
832 AppendOrderInfoL( aOrderInfoArray, aNameListPluginNameArray, |
|
833 aOldPluginInfoArray, ETrue ); |
|
834 |
|
835 //2. For new interface implementations |
|
836 AppendOrderInfoL( aOrderInfoArray, aNameListPluginNameArray, |
|
837 aNewPluginInfoArray, EFalse ); |
|
838 } |
|
839 |
|
840 // --------------------------------------------------------------------------- |
|
841 // CCCAppPluginLoader::AppendOrderInfoL |
|
842 // --------------------------------------------------------------------------- |
|
843 // |
|
844 void CCCAppPluginLoader::AppendOrderInfoL( RArray<TCCAPluginsOrderInfo>& aOrderInfoArray, |
|
845 const RArray<TPtrC>& aNameListPluginNameArray, |
|
846 RPointerArray<CImplementationInformation>& aPluginInfoArray, |
|
847 TBool aIsOldInterFaceType) |
|
848 { |
|
849 // copy object CImplementationInformation's address from aPluginInfoArray to pluginOrderInfo |
|
850 // copy object CImplementationInformation's opaque value to pluginOrderInfo |
|
851 // give identification of TCCAPluginGroup info for each object in pluginOrderInfo |
|
852 for ( TInt i=0; i<aPluginInfoArray.Count(); i++ ) |
|
853 { |
|
854 TCCAPluginsOrderInfo pluginOrderInfo; |
|
855 pluginOrderInfo.iPluginInfor = aPluginInfoArray[i]; |
|
856 pluginOrderInfo.iOrder = GetOrderValueL( *aPluginInfoArray[i] ); |
|
857 |
|
858 //in-house CCA plugins impelemented by ourself |
|
859 if (aPluginInfoArray[i]->ImplementationUid()==TUid::Uid(KCCACommLauncherPluginImplmentationUid) || |
|
860 aPluginInfoArray[i]->ImplementationUid()== TUid::Uid(KCCADetailsViewPluginImplmentationUid)) |
|
861 { |
|
862 pluginOrderInfo.iGroupInfo = TCCAPluginsOrderInfo::ECCAInHousePlugins; |
|
863 } |
|
864 // CCA plugin name found from plugin name list of phonebook main view's sXPExtensions |
|
865 else if (FindPluginNameFromNameListByCCAPluginInfo(*aPluginInfoArray[i],aNameListPluginNameArray) != KErrNotFound ) |
|
866 { |
|
867 pluginOrderInfo.iGroupInfo = TCCAPluginsOrderInfo::ECCAPlugindInBothCCAAndNameList; |
|
868 } |
|
869 // CCA plugin name is not found from plugin name list of phonebook main view's sXPExtensions |
|
870 else |
|
871 { |
|
872 pluginOrderInfo.iGroupInfo = TCCAPluginsOrderInfo::ECCAPluginsOnlyInCCA; |
|
873 } |
|
874 |
|
875 pluginOrderInfo.iOldInterFaceType = aIsOldInterFaceType; |
|
876 User::LeaveIfError(aOrderInfoArray.Append( pluginOrderInfo )); |
|
877 } |
|
878 } |
|
879 |
|
880 // --------------------------------------------------------------------------- |
|
881 // CCCAppPluginLoader::GetOrderValueL |
|
882 // --------------------------------------------------------------------------- |
|
883 // |
|
884 TInt CCCAppPluginLoader::GetOrderValueL( const CImplementationInformation& aInfo ) |
|
885 { |
|
886 HBufC8* match = GetmachingPropertiesLC( |
|
887 aInfo.OpaqueData(), TPtrC8(KCcaOpaqueTABP), EFalse); |
|
888 TPtrC8 namePtr; |
|
889 TPtrC8 valuePtr; |
|
890 TPtrC8 mp(*match); |
|
891 GetNameValue( namePtr, valuePtr, mp); |
|
892 TInt order = 0; |
|
893 TLex8 lex( valuePtr ); |
|
894 lex.Val( order ); |
|
895 CleanupStack::PopAndDestroy(match); |
|
896 |
|
897 //Fallback2 for old plugins that provide only number in opaque data: |
|
898 //The below if{} can be removed when all plugins provide new format OpaqueData |
|
899 if(!order) |
|
900 { |
|
901 order = OpaqueValueFrom( aInfo ); |
|
902 } |
|
903 |
|
904 return order; |
|
905 } |
|
906 |
|
907 // --------------------------------------------------------------------------- |
|
908 // CCCAppPluginLoader::OpaqueValueFrom |
|
909 // --------------------------------------------------------------------------- |
|
910 // |
|
911 TInt CCCAppPluginLoader::OpaqueValueFrom( const CImplementationInformation& aInfo ) |
|
912 { |
|
913 TInt opaqueValue = 0; |
|
914 |
|
915 TLex8 lex( aInfo.OpaqueData() ); |
|
916 lex.Val( opaqueValue ); |
|
917 |
|
918 return opaqueValue; |
|
919 } |
|
920 |
|
921 // ---------------------------------------------------------------------------- |
|
922 // CCCAppPluginLoader::GetmachingPropertiesLC |
|
923 // ---------------------------------------------------------------------------- |
|
924 // |
|
925 HBufC8* CCCAppPluginLoader::GetmachingPropertiesLC( |
|
926 const TDesC8& aData, const TDesC8& aDataRef, TBool aMatchValuesToo) |
|
927 { |
|
928 TPtrC8 dataPtr(aData); |
|
929 HBufC8* foundData = HBufC8::NewLC( Max(aData.Length(), aDataRef.Length()) ); |
|
930 TPtr8 foundPtr = foundData->Des(); |
|
931 |
|
932 while( dataPtr.Length() > 0 ) |
|
933 { |
|
934 TPtrC8 name; |
|
935 TPtrC8 value; |
|
936 GetNameValue( name, value, dataPtr); |
|
937 TPtrC8 dataRefPtr(aDataRef); |
|
938 |
|
939 while( name.Length() > 0 && dataRefPtr.Length() > 0 ) |
|
940 { |
|
941 TPtrC8 nameRef; |
|
942 TPtrC8 valueRef; |
|
943 GetNameValue( nameRef, valueRef, dataRefPtr); |
|
944 TBool nameOk = !name.Compare(nameRef); |
|
945 TBool valueOk = aMatchValuesToo ? !value.Compare(valueRef) : ETrue; |
|
946 |
|
947 if(nameOk && valueOk) |
|
948 { |
|
949 foundPtr.Append(name); |
|
950 if(value.Length()) |
|
951 { |
|
952 foundPtr.Append(KCcaOpaqueValueDelimiter); |
|
953 foundPtr.Append(value); |
|
954 } |
|
955 foundPtr.Append(KCcaOpaqueNameDelimiter); |
|
956 } |
|
957 } |
|
958 } |
|
959 return foundData; |
|
960 } |
|
961 |
|
962 |
|
963 // ---------------------------------------------------------------------------- |
|
964 // CCCAppPluginLoader::GetNameValue |
|
965 // Extracted data is removed from property string |
|
966 // ---------------------------------------------------------------------------- |
|
967 // |
|
968 void CCCAppPluginLoader::GetNameValue( |
|
969 TPtrC8& aName, TPtrC8& aValue, TPtrC8& aDataPtr ) |
|
970 { |
|
971 TInt nextTokenStart = aDataPtr.Find( KCcaOpaqueNameDelimiter ); |
|
972 TPtrC8 delim( aDataPtr ); |
|
973 |
|
974 if( nextTokenStart > aDataPtr.Length() || nextTokenStart < 0 ) |
|
975 { |
|
976 nextTokenStart = aDataPtr.Length(); |
|
977 } |
|
978 |
|
979 //Inspect on the left side of field delimiter token |
|
980 TPtrC8 nameValue = aDataPtr.Left( nextTokenStart ); |
|
981 TInt delimiterStart = nameValue.Find( KCcaOpaqueValueDelimiter ); |
|
982 if( delimiterStart > aDataPtr.Length() || delimiterStart < 0 ) |
|
983 { |
|
984 aName.Set( nameValue ); |
|
985 } |
|
986 else |
|
987 { |
|
988 aName.Set( aDataPtr.Left( delimiterStart ) ); |
|
989 TInt length = nameValue.Length() - delimiterStart - 1; |
|
990 aValue.Set( aDataPtr.Mid( delimiterStart + 1, length) ); |
|
991 } |
|
992 |
|
993 //Remaining data on the right side of token |
|
994 TInt dataLeft = aDataPtr.Length() - nextTokenStart -1; |
|
995 if( dataLeft > 0 ) |
|
996 { |
|
997 //Continue with remaining data on the right side of token |
|
998 aDataPtr.Set( aDataPtr.Right(dataLeft) ); |
|
999 } |
|
1000 else |
|
1001 { |
|
1002 aDataPtr.Set( TPtrC8() ); |
|
1003 } |
|
1004 } |
|
1005 |
|
1006 // End of File |