// -----------------------------------------------------------------------------
// CWidgetUiObserver::IsFileScheme
// -----------------------------------------------------------------------------
//
TBool CWidgetUiObserver::IsFileScheme( const TDesC& aFileName )
    {
    if ( aFileName.Length()> 0 && aFileName.Ptr() )
        {
        if ( aFileName.FindF(KFileScheme) == 0 )
            {
            return ETrue;
            }
        else
            {//Check for paths are that not URI, but of the form..
             // c:/dir/foo.txt. This is to accomodate browser engine inconsistencies. 
            TUriParser16 parser;
            if( parser.Parse( aFileName ) == KErrNone )
                {
                TPtrC16 scheme = parser.Extract( EUriScheme );
                // As per the URI RFC, the part before : is the Scheme
                if ( scheme.Length() == (KMaxDriveName-1) ) 
                    {
                    return ETrue;
                    }
                }
            }
        }

    return EFalse;
    }
Ejemplo n.º 2
0
// -----------------------------------------------------------------------------
// WPAdapterUtil::CheckURI
// -----------------------------------------------------------------------------
//
EXPORT_C TBool WPAdapterUtil::CheckURI( const TDesC& aUrl )
    {
    TUriParser16 uriParser;
    TInt err = uriParser.Parse( aUrl );
    return err == KErrNone 
        && uriParser.IsPresent(EUriScheme)
        && uriParser.IsPresent(EUriHost);
    }
void UPPayHttpConnection::ParseUriL(const TDesC& aUri)
{
#ifdef F_ENCODE_URI
	TUriParser16 uriparser;
	uriparser.Parse(aUri);
	iUriParser = UriUtils::ConvertToInternetFormL(uriparser);
#else
	delete iUri;
	iUri = NULL;
	iUri = HBufC8::NewL(aUri.Length());
	iUri->Des().Copy(aUri);
	User::LeaveIfError(iUriParser.Parse(*iUri));
#endif
}
Ejemplo n.º 4
0
/**
	Converts an 8-bit format uri its into display form. Any escape tripes are decoded and 
	sets of Utf8 format characters are converted into Unicode.
	
	@since			6.0
	@deprecated	 Deprecated in 9.1	
	@leave			KUriUtilsCannotConvert. When the input data cannot be converted.
	@param			aUri	The 8-bit format uri.
	@return			A pointer to a newly created 16-bit uri.
 */
EXPORT_C CUri16* UriUtils::ConvertToDisplayFormL(const TUriC8& aUri)
	{
	// Need decode escape triples
	HBufC8* unescapedBuf = EscapeUtils::EscapeDecodeL(aUri.UriDes());
	CleanupStack::PushL(unescapedBuf);

	// Now need to convert utf8 to unicode
	HBufC16* utf8Buf = EscapeUtils::ConvertToUnicodeFromUtf8L(*unescapedBuf);
	CleanupStack::PushL(utf8Buf);

	// Parse and then create the CUri16 object
	TUriParser16 parser;
	parser.Parse(*utf8Buf);
	CUri16* displayForm = CUri16::NewL(parser);

	// Cleanup and return
	CleanupStack::PopAndDestroy(2, unescapedBuf);	// unescapedBuf, utf8Buf
	return displayForm;
	}
void CAfActivityLauncherPrivate::launchActivityL(const TDesC &uriDesc)
{
    TUriParser16 parser;
    parser.Parse(uriDesc);

    if (parser.Extract(EUriScheme).Compare(_L("appto")) == 0) {
        TLex16 uidParser(parser.Extract(EUriHost));        
        TUint uid;
        User::LeaveIfError(uidParser.Val(uid, EHex));
        
        if (mApplicationLauncher.isRunning(TUid::Uid(uid))) {        
            CAfEntry *launchRequest = CAfEntry::NewLC(0, uid, uriDesc, KNullDesC(), KNullDesC(), KNullDesC8(), KNullDesC8(), TTime());
            User::LeaveIfError(mActivitiesClient->launchActivity(*launchRequest));
            CleanupStack::PopAndDestroy(launchRequest);
        } else {
            mApplicationLauncher.startApplicationL(TUid::Uid(uid), uriDesc);
        }        
    } else {
        User::Leave(KErrArgument);
    }
}
/** Constructs a CUri16 object from the input string.

Can leave if it cannot allocate memory for a CUri object.
The calling program must destroy the CUri16 object when it is no longer
needed.

@return pointer to CUri16 object
@param aUri descriptor to URI
@leave KErrBadName	if the input is invalid

*/
CUri16* TUriShortcutParser16::CreateUriL( const TDesC16& aUri ) const
{
    const TInt uriLen = aUri.Length();

    if ( uriLen == 0 || UriUtils::HasInvalidChars( aUri ) )
    {
        User::Leave( KErrBadName );
    }


    TPtrC16 scheme;
    TPtrC16 prefix;
    TPtrC16 tld;

    if ( !HasScheme( aUri ) )
    {
        if ( HasPath( aUri ) )
        {
            scheme.Set( DefaultScheme() );
        }
        else
        {

            if ( UriUtils::HostType( aUri ) != UriUtils::ETextHost )
            {
                scheme.Set( DefaultScheme() );
            }
            else
            {
                switch ( ComponentCount( aUri ) )
                {
                case 1:

                    if ( aUri.CompareF( KLocalhost ) != 0)
                    {
                        //add prefix, and tld
                        prefix.Set( KWww );
                        tld.Set( DefaultDomain() );
                    }
                //no break after this case

                case 2:
                    scheme.Set( DefaultScheme() );
                    break;

                case 3:
                default:
                    //it has a prefix
                    scheme.Set( MatchingScheme( aUri ) );
                    break;
                }
            }
        }
    }

    //Calculates the length of the buffer needed to construct the complete URI
    TInt bufLen = uriLen;

    if ( scheme.Length() > 0 )
    {
        bufLen += scheme.Length() + KSizeOfSchemeSeparator;
    }

    if ( prefix.Length() > 0 )
    {
        bufLen += prefix.Length() + 1;//dot separator
    }

    if ( tld.Length() > 0 )
    {
        bufLen += tld.Length() + 1;//dot separator
    }

    //This descriptor must be long enough to contain the entire URI.
    HBufC16* uriBuf = HBufC16::NewLC( bufLen );

    TPtr16 uriDes( uriBuf->Des() );

    //Copy the scheme and separator
    if ( scheme.Length() > 0 )
    {
        uriDes.Copy( scheme );
        uriDes.Append( KSchemeSeparator );
    }

    //Append the prefix and dot char
    if ( prefix.Length() > 0 )
    {
        uriDes.Append( prefix );
        uriDes.Append( KSeparatorDot );
    }

    //Appends user supplied string here
    uriDes.Append( aUri );

    //Finally appends the domain
    if ( tld.Length() > 0 )
    {
        uriDes.Append( KSeparatorDot );
        uriDes.Append( tld );
    }

    //Constructs the CUri object
    TUriParser16 uriParser;
    User::LeaveIfError( uriParser.Parse( uriDes ) );

    CUri16* uri = CUri16::NewL( uriParser );

    CleanupStack::PopAndDestroy( uriBuf );

    return uri;
}