EXPORT_C void CDictionaryCodePage::ConstructIndexMappingL(const TInt* aStringPoolToTokenMapping, 
													 TStringType aType)
/**
This method constructs the internal correlation between indices and tokens.

@param				aStringPoolToTokenMapping array of token values, NULL terminated.
@param				aType is the type of the token, e.g. element.

@panic				EXmlFrameworkPanicUnexpectedLogic If the type cannot be recognised.

*/
	{
	RArray<TInt>* toToken = 0;
	RArray<TStringPoolTokenMapping>* toIndex = 0;

	switch (aType)
		{
		case EStringTypeElement:
			{
			toToken = &iElementStringPoolIndexToToken;
			toIndex = &iElementTokenToStringPoolIndex;
			break;
			}
		case EStringTypeAttribute:
			{
			toToken = &iAttributeStringPoolIndexToToken;
			toIndex = &iAttributeTokenToStringPoolIndex;
			break;
			}
		case EStringTypeAttributeValue:
			{
			toToken = &iValueStringPoolIndexToToken;
			toIndex = &iValueTokenToStringPoolIndex;
			break;
			}
		default:
			{
			__ASSERT_ALWAYS(EFalse, Panic(EXmlFrameworkPanicUnexpectedLogic));
			}
		};

	TInt element = 0;
	for (TInt count=0; (element = aStringPoolToTokenMapping[count]) != 0; ++count)
		{
		// The index to token mapping is straight forward.
		// We simply add a table index. 
		// The table index is the same index into the RArray saving space.
		User::LeaveIfError(toToken->Append(element));

		// The token to index mapping is slightly more complicated,
		// and we use a compare function to extract it.
		TStringPoolTokenMapping mapping;
		mapping.iTokenValue = element;		// This is the primary key (Token)
		mapping.iTableIndex = count;								// This is the Table index
		User::LeaveIfError(toIndex->InsertInOrder(
								mapping, 
								TLinearOrder<TStringPoolTokenMapping>(
									CDictionaryCodePage::CompareStringPoolTokenMappingTable)));
		}	
	}
Example #2
0
/**
 * Get the array of selected item indices, with respect to the list model.
 * The array is sorted in ascending order.
 * The array should be destroyed with two calls to CleanupStack::PopAndDestroy(),
 * the first with no argument (referring to the internal resource) and the
 * second with the array pointer.
 * @return newly allocated array, which is left on the cleanup stack;
 *	or NULL for empty list. 
 */
RArray< TInt >* CSettingList::GetSelectedListBoxItemsLC( CEikTextListBox* aListBox )
	{
	CAknFilteredTextListBoxModel* model = 
		static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() );
	if ( model->NumberOfItems() == 0 )
		return NULL;
		
	// get currently selected indices
	const CListBoxView::CSelectionIndexArray* selectionIndexes =
		aListBox->SelectionIndexes();
	TInt selectedIndexesCount = selectionIndexes->Count();
	if ( selectedIndexesCount == 0 )
		return NULL;
		
	// copy the indices and sort numerically
	RArray<TInt>* orderedSelectedIndices = 
		new (ELeave) RArray< TInt >( selectedIndexesCount );
	
	// push the allocated array
	CleanupStack::PushL( orderedSelectedIndices );
	
	// dispose the array resource
	CleanupClosePushL( *orderedSelectedIndices );
	
	// see if the search field is enabled
	CAknListBoxFilterItems* filter = model->Filter();
	if ( filter != NULL )
		{
		// when filtering enabled, translate indices back to underlying model
		for ( TInt idx = 0; idx < selectedIndexesCount; idx++ )
			{
			TInt filteredItem = ( *selectionIndexes ) [ idx ];
			TInt actualItem = filter->FilteredItemIndex ( filteredItem );
			orderedSelectedIndices->InsertInOrder( actualItem );
			}
		}
	else
		{
		// the selection indices refer directly to the model
		for ( TInt idx = 0; idx < selectedIndexesCount; idx++ )
			orderedSelectedIndices->InsertInOrder( ( *selectionIndexes ) [ idx ] );
		}	
		
	return orderedSelectedIndices;
	}
void CMemSpyEngineHelperCodeSegment::GetCodeSegmentHandlesL( RArray<TAny*>& aHandles, TUint* aProcessId, TBool aRamOnly ) const
    {
	TAny* handles[ KMemSpyEngineMaxCodeSegmentCount ];
	TInt count = KMemSpyEngineMaxCodeSegmentCount;

	TInt r = KErrNone;
	
	if  ( aProcessId == NULL )
    	{
	    r = iEngine.Driver().GetCodeSegs( handles, count, aRamOnly );
	    }
    else
	    {
	    r = iEngine.Driver().GetCodeSegs( *aProcessId, handles, count );
	    }

	if  ( r == KErrNone )
    	{
        TInt index;
        TLinearOrder< TAny* > comparer( SortByAddress );
        
        // Remove duplicates - since we reqested code segments for all processes, there
        // might be some dupes.
        count = Min( count, KMemSpyEngineMaxCodeSegmentCount );
        for( index = 0; index < count; index++ )
            {
            TAny* handle = handles[ index ];
            const TInt error = aHandles.InsertInOrder( handle, comparer );
            //
            if  ( ! (error == KErrNone || error == KErrAlreadyExists ) )
                {
                User::Leave( error );
                }
            }
        }
    }
EXPORT_C OMX_ERRORTYPE 
COmxILImagePort::GetLocalOmxParamIndexes(RArray<TUint>& aIndexArray) const
	{
	DEBUG_PRINTF(_L8("COmxILImagePort::GetLocalOmxParamIndexes"));

	// Always collect local indexes from parent
	OMX_ERRORTYPE omxRetValue = COmxILPort::GetLocalOmxParamIndexes(aIndexArray);
	
	if (OMX_ErrorNone != omxRetValue)
		{
		return omxRetValue;
		}
		
	TInt err = aIndexArray.InsertInOrder(OMX_IndexParamImagePortFormat);
	
	// Note that index duplication is OK.
	if (KErrNone != err && KErrAlreadyExists != err)
		{
		return OMX_ErrorInsufficientResources;
		}
	
	return OMX_ErrorNone;

	}
Example #5
0
/**
    Parsing Dir Data Block
    @param  aDataBlock		data block in TInt[] for parsing	
    @param  aDirDataArray	returning dir data array after parsing

    @panic 					if data setup error
*/
void ParsingDirDataBlock(const TInt aDataBlock[], RArray<TInt>& aDirDataArray)
	{
	TInt err = KErrNone;
	aDirDataArray.Reset();

	if (aDataBlock[0] == EOB)
		{
		return;
		}

	TInt i = 1;
	FOREVER
		{
		TInt lastItem = aDataBlock[i-1];
		TInt currentItem = aDataBlock[i];
		
		// check currentItem
		if (currentItem == EOB)
			{
			if (lastItem == CON || lastItem > LAST)
			//check last
				{
				test.Printf(_L("ERROR<SetupDir>: wrong dir data setup! err=%d\n"), err);
				test(EFalse);
				}
			else
			// passed, insert last, break
				{
				err = aDirDataArray.InsertInOrder(lastItem);
				if (err != KErrNone && err != KErrAlreadyExists)
					{
					test.Printf(_L("ERROR<SetupDir>: wrong dir data setup! err=%d\n"), err);
					test(EFalse);
					}
				break;
				}
			}
		else if (currentItem == CON)
		// if current == CON
			{
			if (lastItem == CON || lastItem >= LAST)
			// check last item
				{
				test.Printf(_L("ERROR<SetupDir>: wrong dir data setup! err=%d\n"), err);
				test(EFalse);
				}
			else // last < LAST, last != CON
				{
				// check next item
				TInt nextItem = aDataBlock[i+1];
				if (nextItem <= 0 || nextItem > LAST || lastItem >= nextItem)
					{
					test.Printf(_L("ERROR<SetupDir>: wrong dir data setup! err=%d\n"), err);
					test(EFalse);
					}
				else
					{
					// all valid
					for (TInt j = lastItem; j < nextItem; j++)
						{
						err = aDirDataArray.InsertInOrder(j);
						if (err != KErrNone && err != KErrAlreadyExists)
							{
							test.Printf(_L("ERROR<SetupDir>: wrong dir data setup! err=%d\n"), err);
							test(EFalse);
							}
						}
					}
				}
			i++;
			}
		else if (0 <= currentItem && currentItem <= LAST)
		// if current == normal item
			{
			if (lastItem == CON)
				{
				i++;
				continue;
				}
			else if (lastItem >= LAST)
			// check last item
				{
				test.Printf(_L("ERROR<SetupDir>: wrong dir data setup! err=%d\n"), err);
				test(EFalse);
				}
			else
			// passed, insert last
				{
				err = aDirDataArray.InsertInOrder(lastItem);
				if (err != KErrNone && err != KErrAlreadyExists)
					{
					test.Printf(_L("ERROR<SetupDir>: wrong dir data setup! err=%d\n"), err);
					test(EFalse);
					}
				}
			i++;
			}
			else	// invalid input
			{
			test.Printf(_L("ERROR<SetupDir>: wrong dir data setup! err=%d\n"), err);
			test(EFalse);
			}
		}
	}
Example #6
0
TVerdict CForceRemove::doTestStepL()
	{

#ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
	// Wait up to 30 seconds to ensure both SWIS and the sisregistry server
	// have shut down
	_LIT(KSisRegistryServerName, "!SisRegistryServer");
	_LIT(KInstallServerName, "!InstallServer");
	TInt delaytime = 30; 

	while (delaytime-- > 0)
		{
		TFullName serverName;
		TFindServer find(KInstallServerName);
		if (KErrNotFound == find.Next(serverName))
			{
			find.Find(KSisRegistryServerName);
			if (KErrNotFound == find.Next(serverName))
				{
				break;
				}
			}
		User::After(1000000); // wait a second until the next test
		}
#endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
	
	TPtrC name;
	RTestUtilSessionSwi testutil;
	User::LeaveIfError(testutil.Connect());
	CleanupClosePushL(testutil);
	
	// If file deletion fails we'll try moving the file to a temp directory
	// for another process to clean up later.
	
	TTime currentTime;
	currentTime.UniversalTime();
	
	_LIT(KTempPathFormat, "\\temp\\%Lu");
	TDriveUnit sysDrive (RFs::GetSystemDrive());
	TBuf<128> tempPathFormat(sysDrive.Name());
	tempPathFormat.Append(KTempPathFormat);
	
	TFileName targetPath;
	targetPath.Format(tempPathFormat, currentTime.Int64());
	
	_LIT(KNumFiles, "numfiles");

#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
	RArray<TUint> removeUids;
	CleanupClosePushL(removeUids);
#endif

	TInt num(0);
	GetIntFromConfig(ConfigSection(), KNumFiles, num);

	// Get the file names and use testutil to remove them
	for (TInt i = 0; i < num; ++i)
		{
		_LIT(KFile, "file");
		TBuf<32> key(KFile);
		key.AppendNum(i);
		
		if (!GetStringFromConfig(ConfigSection(), key, name))
			continue;
			
		INFO_PRINTF2(_L("ForceRemove - trying to delete file %S"), &name);

		TInt err = testutil.Delete(name);
		if (err != KErrNone && err != KErrNotFound && err != KErrPathNotFound)
			{
			INFO_PRINTF3(_L("RTestUtilSessionSwi::Delete(%S) returned %d, attempting move instead."), &name, err);
			TFileName source(name);
			TParsePtr parse(source);
			TFileName dest(targetPath);
			dest.Append(parse.Path());
			if (parse.DrivePresent())
				{
				dest[0] = source[0];
				}
			testutil.MkDirAll(dest);
			dest.Append(parse.NameAndExt());

			err = testutil.Move(source, dest);
			
			if (err != KErrNone)
				{
				INFO_PRINTF4(_L("Attempt to move from %S to %S returned %d"),
							&source, &dest, err);
				}
			}
#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
		_LIT(KRegistryPath, "\\sys\\install\\sisregistry\\");
		if (name.FindF(KRegistryPath) == KErrNotFound)
			continue;

		// Extract the uid and add it to our list
		TInt slashPos = name.LocateReverse('\\');
		TPtrC ptrUid = name.Mid(slashPos + 1);
		if (ptrUid.Length() != 8)
			continue;

		TUint uid = 0; 
		TLex lex(ptrUid);
		if (lex.Val(uid, EHex) == KErrNone)
			{
			removeUids.InsertInOrder(uid);	// Will not allow duplicates
			}
#endif
		}

#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
	// Use the sisregistry folder uid to remove the package entries from SCR
	// Note that we remove packages present in ROM too due to two reasons:
	// This is exactly what ForceRemove used to do (delete entire registry folder containing ALL reg files)
	// After deleting an entry SWIRegistry re-registers ROM apps (missing ones)
	TInt count = removeUids.Count();

	RSisRegistryAccessSession regWrite;
	TInt err = regWrite.Connect();
	User::LeaveIfError(err);
	CleanupClosePushL(regWrite);

	Swi::RSisRegistrySession regRead;
	User::LeaveIfError(regRead.Connect());
	CleanupClosePushL(regRead);
	for (TInt i = 0; i < count; ++i)
		{ 
		TUid uid = TUid::Uid(removeUids[i]);
		Swi::RSisRegistryEntry entry;
		CleanupClosePushL(entry);
		if (entry.Open(regRead, uid) == KErrNone)
			{
			// Get its augmentations
			RPointerArray<Swi::CSisRegistryPackage> augmentations;
			CleanupResetAndDestroy<RPointerArray<Swi::CSisRegistryPackage> >::PushL(augmentations);
			
			entry.AugmentationsL(augmentations);
			TInt augCount = augmentations.Count();
			for (TInt j = 0; j < augCount; ++j)
				{
				// Remove it
				TInt dummyTime;
				regWrite.DeleteEntryL(*augmentations[j], dummyTime);
				}
			// Finally remove the base package entry
			Swi::CSisRegistryPackage* package = entry.PackageL();
			CleanupStack::PushL(package);
			TInt dummyTime;
			regWrite.DeleteEntryL(*package,dummyTime);
			CleanupStack::PopAndDestroy(2, &augmentations); // package
			}
		CleanupStack::PopAndDestroy(&entry);
		}
	CleanupStack::PopAndDestroy(3, &removeUids);	// regWrite, regRead
#endif
	
	CleanupStack::PopAndDestroy(&testutil);
	
	return EPass;
	}
LOCAL_C void AddRepositoryToReset(const TUid& aRepositoryUid)
	{
	// Use InsertInOrder not because of speed but to eliminate
	// duplicates.
	RepsToReset.InsertInOrder(aRepositoryUid, CompareUid);
	}