Exemplo n.º 1
0
void SimpleAbstractStreamReader::readChild(AST::UiObjectDefinition *uiObjectDefinition)
{
    Q_ASSERT(uiObjectDefinition);

    setSourceLocation(uiObjectDefinition->firstSourceLocation());

    elementStart(toString(uiObjectDefinition->qualifiedTypeNameId));

    readProperties(uiObjectDefinition);
    readChildren(uiObjectDefinition);

    elementEnd();
}
// -----------------------------------------------------------------------------
// TSTSDistinguishedNameConverter::CreateDNL
// Create CX500DistinguishedName
// -----------------------------------------------------------------------------
CX500DistinguishedName* TSTSDistinguishedNameConverter::CreateDNL(
    const TDesC& aNameInfo)
{

    CArrayPtrFlat< CX520AttributeTypeAndValue>* elements =
        new(ELeave) CArrayPtrFlat<CX520AttributeTypeAndValue> (1);
    CleanupStack::PushL(elements);
    CleanupResetAndDestroyPushL(*elements);
    TInt pos(0);
    TInt nameLength(aNameInfo.Length());
    TInt elementStart(0);

    while (pos < nameLength)
    {
        if (aNameInfo[ pos ] == '\\')
        {
            // next character is escaped, so we jump over it
            pos++;
        }
        else if ((aNameInfo[ pos ] == ',') || (pos == (nameLength - 1)))
        {
            // found the end of single element, parse it
            TInt elementLength = pos - elementStart;
            if (pos == (nameLength - 1))
            {
                elementLength++;
            }
            TPtrC elementDes(aNameInfo.Mid(elementStart, elementLength));
            CX520AttributeTypeAndValue* element =
                ParseDNElementL(elementDes);
            if (element)
            {
                CleanupStack::PushL(element);
                elements->AppendL(element);
                CleanupStack::Pop();  // element
            }
            elementStart = pos + 1;
        }
        pos++;
    }

    TInt elementCount = elements->Count();

    if (elementCount == 0)
    {
        CX520AttributeTypeAndValue* element = GenerateDNElementLC();
        elements->AppendL(element);
        CleanupStack::Pop();  // element
        elementCount++;
    }

    // In certificates the element order is reversed
    CArrayPtrFlat< CX520AttributeTypeAndValue>* reversedElements =
        new(ELeave) CArrayPtrFlat<CX520AttributeTypeAndValue> (elementCount);
    CleanupStack::PushL(reversedElements);

    for (TInt i = elementCount - 1; i >= 0; i--)
    {
        reversedElements->AppendL(elements->At(i));
    }

    CX500DistinguishedName* dn =
        CX500DistinguishedName::NewL(*reversedElements);

    CleanupStack::PopAndDestroy(3);   // elements, reversedElements


    return dn;
}