lowlevellibsandfws/pluginfw/Framework/frame/RegistryData.cpp
changeset 22 ddc455616bd6
parent 0 e4d67989cc36
child 44 97b0fb8a2cc2
child 45 4b03adbd26ca
equal deleted inserted replaced
18:47c74d1534e1 22:ddc455616bd6
  2156 void CRegistryData::ResetTInterfaceIndex(TAny* aObject)
  2156 void CRegistryData::ResetTInterfaceIndex(TAny* aObject)
  2157 	{
  2157 	{
  2158 	TInterfaceIndex* index=reinterpret_cast<TInterfaceIndex*>(aObject);
  2158 	TInterfaceIndex* index=reinterpret_cast<TInterfaceIndex*>(aObject);
  2159 	index->Reset();
  2159 	index->Reset();
  2160 	}
  2160 	}
       
  2161 void CRegistryData::RemoveImplFromImplIndexCleanUp(TAny* aPtr)
       
  2162     {
       
  2163     TCleanupImplIndexEntry *aCleanup = (TCleanupImplIndexEntry*)aPtr;
       
  2164     aCleanup->iRegistryData->RemoveImplByAddrFromImplIndex(aCleanup->iImplEntry);
       
  2165     }
  2161 
  2166 
  2162 /**
  2167 /**
  2163 This method retrieves the data for security checks from the iInterfaceImplIndex
  2168 This method retrieves the data for security checks from the iInterfaceImplIndex
  2164 @param          aImplPtr The new item to be checked
  2169 @param          aImplPtr The new item to be checked
  2165 @param			aCheckIsNeeded	Boolean indicating, whether a filename check is needed
  2170 @param			aCheckIsNeeded	Boolean indicating, whether a filename check is needed
  2285 	else if(aInsertMode == EInsertImplAsUpgradeOfExistingImpl)
  2290 	else if(aInsertMode == EInsertImplAsUpgradeOfExistingImpl)
  2286 		{
  2291 		{
  2287 		TImplContainer& implContainer = implContainerArray[aImplPosInContainerArray];
  2292 		TImplContainer& implContainer = implContainerArray[aImplPosInContainerArray];
  2288 		CImplementationData* oldImpl =  implContainer.iCurrentImpl;
  2293 		CImplementationData* oldImpl =  implContainer.iCurrentImpl;
  2289 		implContainer.iUnusedImpls.AppendL(oldImpl);
  2294 		implContainer.iUnusedImpls.AppendL(oldImpl);
  2290 		RemoveImplFromImplIndex(oldImpl); // ignore return code
  2295 		RemoveImplByAddrFromImplIndex(oldImpl); // ignore return code
  2291 		implContainer.iCurrentImpl = aNewImpl;
  2296 		implContainer.iCurrentImpl = aNewImpl;
  2292 
  2297 
  2293 		// We are replacing existing impl with aNewImpl.  If existing  
  2298 		// We are replacing existing impl with aNewImpl.  If existing  
  2294 		// corresponds to a ROM-based plug-in then aNewImpl is an 
  2299 		// corresponds to a ROM-based plug-in then aNewImpl is an 
  2295 		// update and qualifies as ROM-based under current policy.
  2300 		// update and qualifies as ROM-based under current policy.
  2322 
  2327 
  2323 	User::LeaveIfError( InsertImplIntoImplIndex(aNewImpl) );
  2328 	User::LeaveIfError( InsertImplIntoImplIndex(aNewImpl) );
  2324 	
  2329 	
  2325 	if(aIfPosInInterfaceImplIndex==KErrNotFound)
  2330 	if(aIfPosInInterfaceImplIndex==KErrNotFound)
  2326 		{		
  2331 		{		
  2327 		iInterfaceImplIndex.InsertInOrderL(aNewIfIndexEl, TLinearOrder<TInterfaceIndex>(TInterfaceStruct::CompareInfUid));		
  2332         TCleanupImplIndexEntry aCleanup(this, aNewImpl);
       
  2333         CleanupStack::PushL(TCleanupItem(RemoveImplFromImplIndexCleanUp,&aCleanup));
       
  2334 		iInterfaceImplIndex.InsertInOrderL(aNewIfIndexEl, TLinearOrder<TInterfaceIndex>(TInterfaceStruct::CompareInfUid));
       
  2335 		CleanupStack::Pop();
  2328 		}
  2336 		}
  2329 	}
  2337 	}
  2330 
  2338 
  2331 /**
  2339 /**
  2332 This method takes removes all implementations of a plugin from the iInterfaceImplIndex
  2340 This method takes removes all implementations of a plugin from the iInterfaceImplIndex
  2345 		CInterfaceData* interface = (*aDllData->iIfList)[counter];
  2353 		CInterfaceData* interface = (*aDllData->iIfList)[counter];
  2346 		TInterfaceIndex index;
  2354 		TInterfaceIndex index;
  2347 		index.iInterfaceUid = interface->iInterfaceUid;
  2355 		index.iInterfaceUid = interface->iInterfaceUid;
  2348 		
  2356 		
  2349 		TInt indexPos = iInterfaceImplIndex.FindInOrder(index,TLinearOrder<TInterfaceIndex>(TInterfaceStruct::CompareInfUid));
  2357 		TInt indexPos = iInterfaceImplIndex.FindInOrder(index,TLinearOrder<TInterfaceIndex>(TInterfaceStruct::CompareInfUid));
  2350 
  2358         TImplContainerArray* impDataArray = NULL;
       
  2359 		TInt implCount=0;
       
  2360 		
  2351 		if(indexPos!=KErrNotFound)
  2361 		if(indexPos!=KErrNotFound)
  2352 			{
  2362 			{
  2353 			TImplContainerArray* impDataArray = &(iInterfaceImplIndex[indexPos].iImpData);
  2363             impDataArray = &(iInterfaceImplIndex[indexPos].iImpData);
  2354 			TInt implCount=interface->iImplementations->Count();
  2364             implCount=interface->iImplementations->Count();
  2355 			for(TInt i=0; i<implCount; i++)
  2365 			for(TInt i=0; i<implCount; i++)
  2356 				{
  2366 				{
  2357 				implStruct.iCurrentImpl = (*interface->iImplementations)[i];
  2367 				implStruct.iCurrentImpl = (*interface->iImplementations)[i];
  2358 				TInt impPos = impDataArray->FindInOrder(implStruct, TLinearOrder<CRegistryData::TImplStruct> (TImplStruct::CompareImplStructUid));
  2368 				TInt impPos = impDataArray->FindInOrder(implStruct, TLinearOrder<CRegistryData::TImplStruct> (TImplStruct::CompareImplStructUid));
  2359 				if(impPos!=KErrNotFound)
  2369 				if(impPos!=KErrNotFound)
  2372 
  2382 
  2373 					// update current entry
  2383 					// update current entry
  2374 					if(implContainer.iCurrentImpl->iParent->iParent == aDllData)
  2384 					if(implContainer.iCurrentImpl->iParent->iParent == aDllData)
  2375 						{
  2385 						{
  2376 						// do not care about the return code.
  2386 						// do not care about the return code.
  2377 						RemoveImplFromImplIndex(implContainer.iCurrentImpl);
  2387 						RemoveImplByAddrFromImplIndex(implContainer.iCurrentImpl);
  2378 						
  2388 						
  2379 						TInt implContainerUnusedImplCount=implContainer.iUnusedImpls.Count();
  2389 						TInt implContainerUnusedImplCount=implContainer.iUnusedImpls.Count();
  2380 						// no unused impl's therefore no rollback and remove entry
  2390 						// no unused impl's therefore no rollback and remove entry
  2381 						if(implContainerUnusedImplCount == 0)
  2391 						if(implContainerUnusedImplCount == 0)
  2382 							{
  2392 							{
  2415 							}
  2425 							}
  2416 #endif
  2426 #endif
  2417 							}
  2427 							}
  2418 						}
  2428 						}
  2419 					}
  2429 					}
       
  2430 				//To make sure it is removed from the implIndex no matter what and that the return code is ignored.
       
  2431 				//The previous removal is still required so that a subsequent InsertImplIntoImplIndex is possible
       
  2432 				//for an implementation. e.g. an implementaion is on different drives and only one of htem was removed.
       
  2433 				// The other one should now make it to the iImplIndex through InsertImplIntoImplIndex. If it wasn't 
       
  2434 				// removed, before the insert operation, it will fail since both the implementations hav the same
       
  2435 				// impl UID.
       
  2436 				RemoveImplByAddrFromImplIndex((*interface->iImplementations)[i]);
  2420 				}
  2437 				}
  2421 			if(impDataArray->Count() == 0)
  2438 			if(impDataArray->Count() == 0)
  2422 				{
  2439 				{
  2423 				iInterfaceImplIndex[indexPos].Reset();
  2440 				iInterfaceImplIndex[indexPos].Reset();
  2424 				iInterfaceImplIndex.Remove(indexPos);
  2441 				iInterfaceImplIndex.Remove(indexPos);
  2458  				}
  2475  				}
  2459  			}	
  2476  			}	
  2460  		}	
  2477  		}	
  2461  	}
  2478  	}
  2462 
  2479 
  2463 /** This method removes the specified entry from iImplIndex.
  2480 
  2464 
  2481 /** This method does a search by address and removes the specified entry from iImplIndex.
  2465 @param	aPtr is the entry to remove
  2482 
       
  2483 @param  aPtr is the entry to remove
  2466 @return True if aPtr is removed from iImplIndex. False if aPtr is not
  2484 @return True if aPtr is removed from iImplIndex. False if aPtr is not
  2467 		in iImplIndex, i.e. nothing is removed.
  2485         in iImplIndex, i.e. nothing is removed.
  2468 */
  2486 */
  2469 TBool CRegistryData::RemoveImplFromImplIndex(CImplementationData* aPtr) const
  2487 TBool CRegistryData::RemoveImplByAddrFromImplIndex(CImplementationData* aPtr) const
  2470 	{
  2488     {
  2471 	TInt i = iImplIndex.FindInOrder(aPtr, TLinearOrder<CImplementationData>(CImplementationData::CompareImplUid));
  2489     TInt aIdx = iImplIndex.Find(aPtr);
  2472 	if (i != KErrNotFound)
  2490     if (aIdx != KErrNotFound)
  2473 		{
  2491         {
  2474 		// The array does not own the pointer. Do not delete!
  2492         // This linear pointer search ensures a safe removal of the impl from iImplIndex so that it is free from a dead object.
  2475 		iImplIndex.Remove(i);
  2493     
  2476 		}
  2494         // The array does not own the pointer. Do not delete!
  2477 	return (i != KErrNotFound);
  2495         iImplIndex.Remove(aIdx);
  2478 	}
  2496         return ETrue;
       
  2497         }
       
  2498     return EFalse;
       
  2499     }
  2479 
  2500 
  2480 /** This method inserts the entry aNewImpl into iImplIndex.
  2501 /** This method inserts the entry aNewImpl into iImplIndex.
  2481 
  2502 
  2482 @param aNewImpl the item to add to iImplIndex.
  2503 @param aNewImpl the item to add to iImplIndex.
  2483 @return KErrNone aNewImpl is successfully added to the index.
  2504 @return KErrNone aNewImpl is successfully added to the index.