// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
HBufC16* CPosLmXmlEncoder::ETagStringLC( TPosXmlTagType aTagType ) 
    {
    TPtrC tag = TagNameL( aTagType );

    if ( !IsTagLeaf( aTagType ) )
        {
        iIndentationDepth = Max( iIndentationDepth - 1, 0 );
        }

    HBufC16* indent = IndentationLC();     
    HBufC16* string = HBufC16::NewLC( KPosStringLength + indent->Length() );

    if ( !IsTagLeaf( aTagType ) )
        {
        string->Des().Append( *indent );
        }
    string->Des().Append( KPosXmlETagStart );
    string->Des().Append( KPosXmlNameSpacePrefix );
    string->Des().Append( tag );
    string->Des().Append( KPosXmlTagEnd );
    string->Des().Append( KPosXmlNewLine );

    CleanupStack::Pop( string );
    CleanupStack::PopAndDestroy( indent );
    CleanupStack::PushL( string );
    return string;
    }
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
HBufC16* CPosLmXmlEncoder::STagStringLC( TPosXmlTagType aTagType, const TDesC& aAttributes )
    {
    TPtrC tag = TagNameL( aTagType );

    HBufC16* indent = IndentationLC();     
    HBufC16* string = HBufC16::NewLC( KPosStringLength + indent->Length() + aAttributes.Length() );

    string->Des().Append( *indent );
    string->Des().Append( KPosXmlSTagStart );
    string->Des().Append( KPosXmlNameSpacePrefix );
    string->Des().Append( tag );
    
    if ( aAttributes.Length() )
        {
        string->Des().Append( KPosXmlSpace );
        string->Des().Append( aAttributes );
        }
    
    string->Des().Append( KPosXmlTagEnd );

    if ( !IsTagLeaf( aTagType ) )
        {
        string->Des().Append( KPosXmlNewLine );
        iIndentationDepth++;
        }

    CleanupStack::Pop( string );
    CleanupStack::PopAndDestroy( indent );
    CleanupStack::PushL( string );
    return string;
    }
// ----------------------------------------------------------------------------
// UntrustedCertificateInfoSymbian::ConstructL()
// ----------------------------------------------------------------------------
//
void UntrustedCertificateInfoSymbian::ConstructL(const QByteArray &aEncodedCert)
{
    TPtrC8 encodedCert( reinterpret_cast<const TText8*>( aEncodedCert.constData() ),
        aEncodedCert.length() );

    ASSERT( mCert == 0 );
    mCert = CX509Certificate::NewL( encodedCert );

    HBufC16* subjectBuf = NULL;
    X509CertNameParser::SubjectFullNameL( *mCert, subjectBuf );
    CleanupStack::PushL( subjectBuf );
    QT_TRYCATCH_LEAVING( mSubjectName =
        QString::fromUtf16(subjectBuf->Ptr(), subjectBuf->Length()) );
    CleanupStack::PopAndDestroy( subjectBuf );

    HBufC16* issuerBuf = NULL;
    X509CertNameParser::IssuerFullNameL( *mCert, issuerBuf );
    CleanupStack::PushL( issuerBuf );
    QT_TRYCATCH_LEAVING( mIssuerName =
        QString::fromUtf16(issuerBuf->Ptr(), issuerBuf->Length()));
    CleanupStack::PopAndDestroy( issuerBuf );

    TPtrC8 fingerprint = mCert->Fingerprint();
    QT_TRYCATCH_LEAVING( mFingerprint = QByteArray::fromRawData(
        reinterpret_cast<const char*>(fingerprint.Ptr()), fingerprint.Length()) );

    mMd5Fingerprint = Md5FingerprintL( mCert->Encoding() );

    TPtrC8 serialNumber = mCert->SerialNumber();
    QT_TRYCATCH_LEAVING( mSerialNumber = QByteArray::fromRawData(
        reinterpret_cast<const char*>(serialNumber.Ptr()), serialNumber.Length()) );

    const CValidityPeriod& validityPeriod = mCert->ValidityPeriod();
    convertDateTime(validityPeriod.Start(), mValidFrom);
    convertDateTime(validityPeriod.Finish(), mValidTo);

    mFormat = X509Certificate;

    const CSigningAlgorithmIdentifier& alg = mCert->SigningAlgorithm();
    mDigestAlgorithm = mapAlgorithm(alg.DigestAlgorithm().Algorithm());
    mAsymmetricAlgorithm = mapAlgorithm(alg.AsymmetricAlgorithm().Algorithm());
}
void CHttpCacheManager::ApplyCacheOverridesL(CRepository& aRepository, const TUint32& aSecIdInt, TBool& aCacheEnabled, TInt& aCacheSize, TBool& aOpCacheEnabled, TBool& aVssCacheEnabled, TDes& aPath, const TDesC& aDefaultDrive)
    {
    TDriveUnit drive(aDefaultDrive);
    
    // set defaults
    if(aSecIdInt == KUIDBROWSERNG)       // for the browser, force use of Operator and VSS caches
        {
        aOpCacheEnabled = ETrue;
        aVssCacheEnabled = ETrue;
        }
    
    // read override string from centrep
    HBufC16 *overrideBuf = HBufC16::NewLC(64);
    TPtr overrideStr(overrideBuf->Des());
    TInt strLen;
    TInt err = aRepository.Get(KCacheManagerHttpCacheProcessOverride, overrideStr, strLen);
    if(strLen > overrideBuf->Length())
        {
        overrideBuf = overrideBuf->ReAllocL(strLen);
        // make sure cleanup stack contains correct pointer since ReAllocL always allocates a new des for larger space.
        CleanupStack::Pop();
        CleanupStack::PushL(overrideBuf);
        // reassign the TPtr
        overrideStr.Set(overrideBuf->Des());
        // pull in the whole string
        aRepository.Get(KCacheManagerHttpCacheProcessOverride, overrideStr, strLen);
        }
    // if we failed to load an override string, use the default.
    if( overrideStr.Length() == 0 )
        {
        CleanupStack::PopAndDestroy( overrideBuf );
        overrideBuf = KDefaultOverrideString().AllocLC();
        overrideStr.Set( overrideBuf->Des() );
        }
    // Built in Lex likes white space to separate strings, but easier to enter with ; separators.  Replace all ; with spaces.
    TInt pos=0;
    do{
        if(overrideStr[pos] == ';')
            {
            overrideStr[pos] = ' ';
            }
        pos++;
    }while(pos < overrideStr.Length());
    
    TLex overrideLex(overrideStr);
    do{
        TUint32 tempId;
        User::LeaveIfError(overrideLex.BoundedVal(tempId,EHex,KMaxTUint32));
        if(overrideLex.TokenLength() != 8)  // if we're not pointing at an SID in the string, we are incorrect and the override is broken.
            User::Leave(KErrCorrupt);
        overrideLex.SkipSpace();
        TInt32 tempCacheEnabled;
        User::LeaveIfError(overrideLex.BoundedVal(tempCacheEnabled,KMaxTInt32));
        overrideLex.SkipSpace();
        TInt32 tempCacheSize;
        User::LeaveIfError(overrideLex.BoundedVal(tempCacheSize,KMaxTInt32));
        overrideLex.SkipSpace();
        TDriveUnit tempDrive(overrideLex.NextToken());
        overrideLex.SkipSpaceAndMark();
        // found a hex SID matching ours, use the parameters.
        if(tempId == aSecIdInt)
            {
            aCacheEnabled = tempCacheEnabled;
            aCacheSize = tempCacheSize * 1024; // conf is in KB
            drive = tempDrive;
            break;
            }
    }while(!overrideLex.Eos());

    // Modify drive letter on aPath to match
    TParsePtr parsePath(aPath);
    TPtrC pathStr(parsePath.Path());
    TPath tempPath;
    tempPath.Format(_L("%c:%S"), TInt(drive)+'A', &pathStr);
    aPath.Copy(tempPath);
    HttpCacheUtil::EnsureTrailingSlash( aPath );
    
    CleanupStack::PopAndDestroy(overrideBuf);
    }
Ejemplo n.º 5
0
// ---------------------------------------------------------
// CProcessorDN::ProcessTagL
// ---------------------------------------------------------
//
void CProcessorDN::ProcessTagL( TBool /*aFieldIDPresent*/ )
    {
    
    iDestinationDropped = EFalse;
    
    iProtectionLevel = EProtLevel0;
    
    if( iIsFirstRound )
        {
        TInt dnId = -1;
        for ( TInt idx(0); idx < TagContainer().Count(); idx++)
            {
            if ( TagContainer().FieldId( idx ) == EDN_Id )
                {
                HBufC16* ptrTag = TagContainer().Tag(idx);
                TLex16 lex(ptrTag->Des());
                TInt err = lex.Val(dnId);
                if (err != KErrNone)
                    {
                    CLOG_WRITE( "The destinaton Id field is bad.");
                    User::Leave(err);    
                    }
                break;
                }
            }
        if (dnId == -1)
            {
            iDestination = iCmManager->CreateDestinationL( KDefaultDestinationName );        
            CLOG_WRITE( "Destinaton created without dnId.");
            }
        else
            {
            iDestination = iCmManager->CreateDestinationL( KDefaultDestinationName, dnId);        
            CLOG_WRITE_FORMAT( "Destinaton created. dnId:%d", dnId);
            }
        }
        
    HBufC *destName( NULL );
    TInt priority = 0;
    RPointerArray<HBufC> names;
    
    for (TInt idx(0); idx < TagContainer().Count(); idx++)
        {
        HBufC16* ptrTag = TagContainer().Tag(idx);
        TInt field =  TagContainer().FieldId( idx );
        
        if( iIsFirstRound && !iDestinationDropped )
            {
            switch ( field )
                {
                case EDN_Name:
                    {
                    // If more destinations exist with same name then one is kept
                    TRAPD( err, iDestination.SetNameL( *ptrTag ) );
                    if( KErrAlreadyExists == err )
                        {
                        CLOG_WRITE_FORMAT( 
                        "Error: Destination exist: %S. It is dropped!", ptrTag )
                        CLOG_WRITE( "\t \r\n" )
                        iDestinationDropped = ETrue;
                        }
                    else
                        {
                        destName = ptrTag->AllocLC();    
                        }
                    }
                break;
                case EDN_Metadata:
                    {
                    if( !ptrTag->Compare( KPurposeUnknown ) )
                        {
                        iDestination.SetMetadataL( ESnapMetadataPurpose, 
                                                   ESnapPurposeUnknown );
                        }
                    else if( !ptrTag->Compare( KPurposeInternet ) )
                        {
                        iDestination.SetMetadataL( 
                            ESnapMetadataPurpose, 
                            ESnapPurposeInternet );
                        }
                    else if( !ptrTag->Compare( KPurposeOperator ) )
                        {
                        iDestination.SetMetadataL( 
                            ESnapMetadataPurpose, 
                            ESnapPurposeOperator );
                        }
                    else if( !ptrTag->Compare( KPurposeMMS ) )
                        {
                        iDestination.SetMetadataL( 
                            ESnapMetadataPurpose, 
                            ESnapPurposeMMS );
                        }
                    else if( !ptrTag->Compare( KPurposeIntranet ) )
                        {
                        iDestination.SetMetadataL( 
                            ESnapMetadataPurpose, 
                            ESnapPurposeIntranet );
                        }
                    else
                        {
                        //no valid data is given - use default value
                        iDestination.SetMetadataL( ESnapMetadataPurpose, 
                                                   ESnapPurposeUnknown );
                        CLOG_WRITE( "! Error : Invalid Metadata. Default:User Defined");
                        }
                    }
                break;
                case EDN_Protection:
                    {
                    TPtrC16 protPtr = ptrTag->Right( ptrTag->Length() );
                    TLex16 lex( protPtr );
                    TUint32 prot( 0 );
                    if ( lex.Val( prot, EDecimal ) == KErrNone )
                        {
                        if( prot <= EProtLevel3 ) // prot is unsigned so no need
                                                  // to check lower boundary
                            {
                            iProtectionLevel = TProtectionLevel( prot );
                            }
                        else
                            {
                            //no valid data is given - use default value
                            iProtectionLevel = EProtLevel0;
                            CLOG_WRITE( "! Error : Invalid Protection level. Default:Level0");
                            }
                        }
                    }
                break;
                case EDN_Hidden:
                    {
                    if( !ptrTag->Compare( KStrYes ) )
                        {
                        iDestination.SetHiddenL( ETrue );
                        }
                    else if( !ptrTag->Compare( KStrNo ) )
                        {
                        iDestination.SetHiddenL( EFalse );
                        }
                    else
                        {
                        //no valid data is given - use default value
                        iDestination.SetHiddenL( EFalse );
                        CLOG_WRITE( "! Error : Invalid Hidden. Default:No");
                        }
                    }
                break;
                case EDN_HiddenAgent:
                    {
                    if( !ptrTag->Compare( KStrYes ) )
                        {
                        iDestination.SetMetadataL( ESnapMetadataHiddenAgent, ETrue );
                        }
                    else if( !ptrTag->Compare( KStrNo ) )
                        {
                        iDestination.SetMetadataL( ESnapMetadataHiddenAgent, EFalse );
                        }
                    else
                        {
                        iDestination.SetMetadataL( ESnapMetadataHiddenAgent, EFalse );
                        //no valid data is given - use default value
                        CLOG_WRITE( "! Error : Invalid HiddenAgent. Default:No");
                        }
                    }
                break;
                case EDN_Highlighted:
                    {
                    if( !ptrTag->Compare( KStrYes ) )
                        {
                        iDestination.SetMetadataL( ESnapMetadataHighlight, ETrue );
                        }
                    else if( !ptrTag->Compare( KStrNo ) )
                        {
                        iDestination.SetMetadataL( ESnapMetadataHighlight, EFalse );
                        }
                    else
                        {
                        iDestination.SetMetadataL( ESnapMetadataHighlight, EFalse );
                        //no valid data is given - use default value
                        CLOG_WRITE( "! Error : Invalid Highlighted. Default:No");
                        }
                    }
                break;
                } // switch
            } // if
         else if( !iIsFirstRound && !iDestinationDropped )
            {
            switch ( field )
                {
                case EDN_Name:
                 {
                 iDest = FindDestinationL( ptrTag );
                 if( iDest == NULL )
                     {
                     CLOG_WRITE_FORMAT( "Error: Destination not found: %S ", ptrTag )
                     iDestinationDropped = ETrue;
                     }
                 else
                     {
                     CLOG_WRITE_FORMAT( "\t Destination name: %S ", ptrTag )
                     }
                 }
                break;
            case EDN_IAPName:
                   {
                   TInt pos;
                   RCmConnectionMethodExt* plugin = FindPluginL( ptrTag, pos );
                   if( plugin )
                        {
                        TRAPD( err, iDest->AddConnectionMethodL( *plugin ) );
                        // Set the priority according to the order in which the IAPs are in the XML
                        TRAPD( err2 ,iDest->ModifyPriorityL( *plugin, priority ));
                        if ( err2 != KErrNone )
                        	{
                        	err2 = KErrNone; // to remove the compiler warnings
                        	}
                        
                        iDest->UpdateL();
                        priority++;
                        
                        if( err == KErrNone )
                            {
                            CLOG_WRITE_FORMAT( "\t Added connection method: %S ", ptrTag )
                            (*iCmInDest)[ pos ] = ETrue;
                            }
                        else
                            {
                            CLOG_WRITE_FORMAT( 
                            "Warning connection method could not added: %S ", ptrTag )
                            }
                        }
                     else
                        {
                        CLOG_WRITE_FORMAT( 
                        "Warning: plugin could not added: %S ", ptrTag )
                        }                       
                   }
                break;
            case EDN_EmbeddedDNName:
                    {
                    const RCmDestinationExt* embDestination = FindDestinationL( ptrTag );
                    if( embDestination )
                        {
                    
                        TRAPD( err, iDest->AddEmbeddedDestinationL( *embDestination ) );
                    
                        if( err == KErrNone )
                            {
                            CLOG_WRITE_FORMAT( "\t Added embedded destination: %S ", ptrTag )
                            }
                        else
                            {
                            CLOG_WRITE_FORMAT( 
                            "Warning embedded destination could not added: %S ", ptrTag )
                            }
                        }
                     else
                        {
                        CLOG_WRITE_FORMAT( 
                        "Warning embedded destination could not added: %S ", ptrTag )
                        }
                        
                    }
                break;
            default:
                {
                break;
                }
              } // switch
                
            } // if