/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
TInt CMgAppUi::OpenMobileWEBSiteL(TAny* /*aAny*/)
{

	const TInt KWmlBrowserUid = 0x10008D39;
	TUid id( TUid::Uid( KWmlBrowserUid ) );
	TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
	TApaTask task = taskList.FindApp( id );
	if ( task.Exists() )
	{
		HBufC8* param = HBufC8::NewLC( KMobileJukkaLink().Length() + 2);
				//"4 " is to Start/Continue the browser specifying a URL
		param->Des().Append(_L("4 "));
		param->Des().Append(KMobileJukkaLink);
		task.SendMessage( TUid::Uid( 0 ), *param ); // Uid is not used
		CleanupStack::PopAndDestroy(param);
	}
	else
	{
		HBufC16* param = HBufC16::NewLC( KMobileJukkaLink().Length() + 2);
				//"4 " is to Start/Continue the browser specifying a URL
		param->Des().Append(_L("4 "));
		param->Des().Append(KMobileJukkaLink);
		RApaLsSession appArcSession;
				// connect to AppArc server 
		User::LeaveIfError(appArcSession.Connect()); 
		TThreadId id;
		appArcSession.StartDocument( *param, TUid::Uid( KWmlBrowserUid), id );
		appArcSession.Close(); 
		CleanupStack::PopAndDestroy(param);
	}
	
	return KErrNone;
}
//Encode and Decode the Uri
void CExampleInetProtUtil::EscapeEncodeDecodeL()
	{
	//Take an eg file to encode it and then decode it....
	_LIT(KFullUriName,"K:\\ws\\direct\\direct.mmp");
	TBuf<40> desFullUriName(KFullUriName);
	
	//UTF-8 defines a mapping from sequences of octets to sequences of chars
	HBufC8* convert = EscapeUtils::ConvertFromUnicodeToUtf8L(desFullUriName);

	//Encode the eg Uri and display it
	_LIT(KTextEncode, "\n\n\nThe Encoded Uri is....\n");
	iConsole->Printf ( KTextEncode );
	HBufC16* encode = EscapeUtils::EscapeEncodeL(desFullUriName,EscapeUtils::EEscapeNormal);
	TPtr uriEncoded = encode->Des();
	TBuf16<100> desEncodedUri;
	desEncodedUri.Copy (uriEncoded);
	iConsole->Printf ( _L("%S"), &desEncodedUri );

	//Decode the eg Uri and display it
	_LIT(KTextDecode, "\nThe Decoded Uri is....\n");
	iConsole->Printf ( KTextDecode );
	
	HBufC16* decode = EscapeUtils::EscapeDecodeL(desFullUriName);
	TPtr uriDecoded = decode->Des();
	TBuf16<100> desDecodedUri;
	desDecodedUri.Copy (uriDecoded);
	iConsole->Printf ( _L("%S"), &desDecodedUri );

	delete decode;
	delete encode;
	delete convert;

	iConsole->Getch();
	iConsole->Printf ( KLeaveALine );
	}
/**
	Converts the 8 bit descriptor to 16 bit descriptor and logs it

	@param	aModify8BitDesC		The 8 bit descriptor that needs to be converted to
								16 bit descriptor.
	@param	aEngine				The engine that is used to log data.
	@leave						leaves with a standard error
*/
EXPORT_C void TSrvAddrVal::LogUsing8BitDesL(CHttpTestEngine* aEngine, const TDesC8& aModify8BitDesC)
	{
	HBufC16* modifiedBuf = HBufC16::NewLC(aModify8BitDesC.Length());
	modifiedBuf->Des().Copy(aModify8BitDesC);
	TPtr16 logValuePtr16 = modifiedBuf->Des();

	aEngine->Utils().LogIt(_L("URI: "));
	aEngine->Utils().LogIt(logValuePtr16);
	CleanupStack::PopAndDestroy(modifiedBuf);
	}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
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;
    }
TInt CT_DataRGavdp::GAVDP_SecurityControlIndication(TSEID /*aSEID*/, TDes8& aSecurityDataInOut)
{
    INFO_PRINTF1(KLogInfoSecurityControlIndication);

    //verify
    CheckEvent(EGAVDP_SecurityControlIndication);

    HBufC16* securityDataInOut = HBufC16::NewL(aSecurityDataInOut.Length());
    securityDataInOut->Des().Copy(aSecurityDataInOut);
    if (KLogDataFixed().Compare(*securityDataInOut)==0)
    {
        INFO_PRINTF1(KLogInfoSecurityDataUnchanged);
    }
    else if(KLogDataChange().Compare(*securityDataInOut)==0)
    {
        aSecurityDataInOut.Copy(KLogDataChanged());
        INFO_PRINTF2(KLogInfoSecurityDataChanged, &KLogDataChanged());
    }
    else
    {
        ERR_PRINTF1(KLogErrReceivedSecurityData);
        SetAsyncError(iCmdIndex, KErrGeneral);
    }
    delete securityDataInOut;

    DecOutstanding();
    return KErrNone;
}
Beispiel #6
0
HBufC16* CResourceManager::MakeFileName(const TDesC8& aUrl)
{
    HBufC16* fileName = NULL;
    if (aUrl.Length()) {
        char* p = (char*) aUrl.Ptr();
        char* tooFar = p + aUrl.Length();
        if(*(tooFar-1) == '/')
            tooFar--;
        char* q = tooFar - 1;
        while (q > p && *q != '/')
            q--;
        if (*q == '/' && *(q + 1) != '/' && q < tooFar - 1) {
            q++;
            p = q;
            while (*p != '?' && p < tooFar)
                p++;
            int l;
            wchr* nameu16 = uni_utf8_to_utf16_str((uint8*) q, p - q, &l);
            fileName = HBufC16::NewL(l);
            fileName->Des().Copy(nameu16, l);
            NBK_free(nameu16);
        }
    }
    return fileName;
}
// -----------------------------------------------------------------------------
// CMCETestUISessionViewModel::PopulateStreamsL
// Populate streams of a session
// -----------------------------------------------------------------------------
//
void CMCETestUISessionViewModel::PopulateStreamsL()
    {
    const RPointerArray<CMCETestUIEngineAudioStream>& audioStreams = 
            iSession.AudioStreamsL();

    for ( TInt i = 0; i < audioStreams.Count(); ++i )
        {
                              
        TInt itemLength = KAudioStream().Length() + 
                          KLeftParenthesis().Length() +
                          audioStreams[i]->TextualDirection().Length() +
                          KRightParenthesis().Length() +
                          audioStreams[i]->State().Length() +
                          KTab().Length() * 3;
                      
        HBufC16* item = HBufC16::NewLC( itemLength );
        TPtr16 itemPtr = item->Des();
        itemPtr.Append( KTab );
        itemPtr.Append( KAudioStream );
        itemPtr.Append( KLeftParenthesis() );
        itemPtr.Append( audioStreams[i]->TextualDirection() );
        itemPtr.Append( KRightParenthesis() );
        itemPtr.Append( KTab );
        itemPtr.Append( audioStreams[i]->State() );
        itemPtr.Append( KTab );
    
        iArray->AppendL( *item );
        
        CleanupStack::PopAndDestroy( item );
        item = NULL;
        }
    }
// ---------------------------------------------------------------------------
// CIctsEngine::ConstructL
// ---------------------------------------------------------------------------
//
void CIctsEngine::ConstructL()
    {
    DEBUG("CIctsEngine::ConstructL");
    _LIT8(KIp, "http://connectivity-test.ext.nokia.com/");
    
    // CenRep uses UTF 16
    HBufC16* uriBuffer = HBufC16::NewLC( KMaxIpLength );
    TPtr16 uriPtr = uriBuffer->Des();
    // For HTTP FW change it to 8bit
    HBufC8* uriBuffer8 = HBufC8::NewLC( KMaxIpLength );
    TPtr8 uriPtr8 = uriBuffer8->Des();
    TRAPD(err, iRepository = CRepository::NewL( 
                                    KCRUidInternetConnectivitySettings ) );
    if ( KErrNone == err )
        {
        TInt err = iRepository->Get( KIctsIpDestination, uriPtr );
        uriPtr8.Copy( uriPtr );
        iIPAddress = uriPtr8;
        if ( KErrNone != err )
            {
            iIPAddress = KIp();
            }
        }
    else
        {   
        iIPAddress = KIp();
        }
    CleanupStack::PopAndDestroy(uriBuffer8);
    CleanupStack::PopAndDestroy(uriBuffer);
    iPollingIntervalTimer = CIctsPollingIntervalTimer::NewL( *this );
    
    iPollingTimeTimer = CIctsPollingTimeTimer::NewL( *this );
    
    iHttpHandler = CIctsHttpHandler::NewL( *this, KHttpResponseTime );
    }
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
HBufC16* CPosLmXmlEncoder::IndentationLC()
    {
    ASSERT( iIndentationDepth >= 0 );
    TInt indentLength = iIndentationDepth * KPosXmlTab().Length();
    HBufC16* indent = HBufC16::NewLC( indentLength );
    for ( TInt i=0; i < iIndentationDepth; i++ )
        {
        indent->Des().Append( KPosXmlTab );
        }
    return indent;
    }
Beispiel #10
0
// --------------------------------------------------------------------------------
// void NSmlDebugPrintArgs16L( TText8* aFmt, ... )
// --------------------------------------------------------------------------------
void _NSmlDebugPrintArgs16L( const TDesC16& aFmt, VA_LIST aList )
	{
	HBufC16* buf = HBufC16::NewLC(1024*2);
	buf->Des().FormatList(aFmt, aList);
	HBufC8* pBuf8 = HBufC8::NewLC(1024*2);
	TPtr8 buf8 = pBuf8->Des();
	buf8.Copy(*buf);
	buf8.Append(_L8("\r\n"));
	DumpToFileL(buf8);
	CleanupStack::PopAndDestroy(2); // buf, bBuf8
	}
//将Utf8转换成Unicode
HBufC16* CCommonUtils::ConvertToUnicodeFromUTF8(const TDesC8& aStr)
{
	HBufC16* ret = HBufC16::NewLC(aStr.Length());		

	CnvUtfConverter* Converter = new (ELeave) CnvUtfConverter();
	TPtr ptr = ret->Des();
	Converter->ConvertToUnicodeFromUtf8(ptr,aStr);
	delete Converter;

	CleanupStack::Pop(ret);
	return ret;	
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
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;
    }
// ----------------------------------------------------------------------------
// CAudioStreamEngine::MaiscBufferCopied(
//     TInt aError, const TDesC8& aBuffer)
//
// called when a block of audio data has been read and is available at the 
// buffer reference *aBuffer.  calls to ReadL() will be issued until all blocks
// in the audio data buffer (iStreamBuffer) are filled.
// ----------------------------------------------------------------------------
void CAudioStreamEngine::MaiscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/)
    {
    if (aError!=KErrNone)
        {
        _LIT(KMessage,"CAudioStreamEngine::MaiscBufferCopied Recording error: %d");
        HBufC16* message = HBufC16::NewLC(KMessage().Length()+10);
        message->Des().AppendFormat(KMessage,aError);
        ShowMessage(*message, ETrue);
        CleanupStack::PopAndDestroy(); // message
        message = NULL;
        }
    
    if (aError==KErrNone) 
        {
        // stop recording if at the end of the buffer
        /*iStreamIdx++;
        if (iStreamIdx == iFrameCount)
            {
            ShowMessage(_L("CAudioStreamEngine::MaiscBufferCopied Recording complete!"), ETrue);
            iStreamEnd = iStreamIdx - 1;
            iBufferOK = ETrue;

            // Playback is complete:
            // Start the active object that will stop the stream
            iStop->Start( TCallBack(BackgroundStop, this) );            
            return;
            }*/       
        //while(!_bFreeAccessBuffer);
        
        _bAccessBuffer=EFalse;
        // issue ReadL() for next frame     
        //iAudioBuffer2Send.Append(iAudioBuffer);
        iAppUi->SendAudioFrame(iAudioBuffer);
        TRAPD(error, iInputStream->ReadL(iAudioBuffer));
        _bAccessBuffer=ETrue;
        PanicIfError(error);
        }
    else if (aError==KErrAbort) 
        {
        // Recording was aborted, due to call to CMdaAudioInputStream::Stop()
        // This KErrAbort will occur each time the Stop() method in this class is executed.
        // Also, MaiscRecordComplete() will be called after exiting this method.
        iStreamEnd = iStreamIdx - 1;
        iBufferOK = ETrue;
        iInputStatus = ENotReady;
        }
    else 
        {
        ShowMessage(_L("CAudioStreamEngine::MaiscBufferCopied Error reading data from input"), ETrue);
        iInputStatus = ENotReady;
        }
    }
Beispiel #14
0
HBufC16* CEnvironment::ExternalizeLC(TUint& aCount)
	{
	TInt length=0;
	TUint i=0;
	for (i=0; i<iCount; ++i)
		length+=iVars[i].Length();
	HBufC16* retBuf = HBufC16::NewLC(length);
	TInt nvars=0;
	TPtr16 hbuf16=retBuf->Des();
	for (i=0; i<iCount; i++)
		nvars+=iVars[i].Externalize(hbuf16);
	aCount=nvars;
	return retBuf;
	}
// -----------------------------------------------------------------------------
HBufC* CPresenceCacheBuddyInfo::InternalizeFieldL( RReadStream& aStream )
    {
    HBufC16* temp = NULL;    
    TInt32 length = aStream.ReadInt32L();
    if ( length > 0 )
        { 
        temp = HBufC::NewLC( length);
        TPtr stringPtr = temp->Des(); 
        aStream.ReadL( stringPtr, length );
        CleanupStack::Pop( temp );
        } 
    else
        {
        }
    return temp;
    }
Beispiel #16
0
HBufC16* CEnvironment::ExternalizeLC(TUint& aCount, wchar_t** envp)
	{
	if (envp==0)
		return ExternalizeLC(aCount);	// get current environment
	// Externalize supplied environment
	TInt length=0;
	wchar_t** ep=envp;
	for (ep=envp; *ep; ++ep)
		length+=wcslen(*ep)+1;
	HBufC16* retBuf = HBufC16::NewLC(length);
	TInt nvars=0;
	TPtr16 hbuf16=retBuf->Des();
	for (ep=envp; *ep; ++ep)
		nvars+=TEnvVar::Externalize(*ep, hbuf16);
	aCount=nvars;
	return retBuf;
	}
Beispiel #17
0
/**
 * Function that displays the deck to the dealer.
 */	
void CScabbyQueenDealer::ShowDeckL()
	{
	TInt cardNum;
	iConsole.Printf(_L("\nThe Deck...\n"));
	
	for (TInt i=0; i<=iFullDeck->Length()-KCardLength; i=i+KCardLength)
		{
		if (i==0)
			cardNum = i;
		else
			cardNum = i/2;
		HBufC16* buffer = HBufC16::NewL(4);
		buffer->Des().Copy(iFullDeck->Mid(i,2));
		iConsole.Printf(_L("%d - %S | "),cardNum,buffer);
		}
	iConsole.Getch();
	}
void CT_DataRGavdp::RunL(CActive* aActive, TInt aIndex)
{
    TInt err = aActive->iStatus.Int();
    SetAsyncError(aIndex, err);
    DecOutstanding();

    if (iReadBuffer)
    {
        if (aActive->iStatus.Int()==KErrNone)
        {
            if (iReadExpectBuffer)
            {
                if (iReadExpectBuffer->Compare(*iReadBuffer)!=0)
                {
                    ERR_PRINTF1(KLogErrReadData);
                    SetError(EFail);
                }
            }
            HBufC16* readbufdes = HBufC16::NewL(iReadBuffer->Length());
            readbufdes->Des().Copy(*iReadBuffer);
            INFO_PRINTF2(KLogInfoReceived,readbufdes);
            delete readbufdes;
        }
        else
        {
            ERR_PRINTF2(KLogErrSocket, aActive->iStatus.Int());
        }

        delete iReadBuffer;
        iReadBuffer = NULL;
    }

    if (iSendBuffer)
    {
        if (aActive->iStatus.Int()!=KErrNone)
        {
            ERR_PRINTF2(KLogErrSocket, aActive->iStatus.Int());
        }
        else
            INFO_PRINTF1(KLogInfoSendSucess);
        delete iSendBuffer;
        iSendBuffer = NULL;
    }

}
Beispiel #19
0
/**
 * Function that displays the current hand.
 */	
void CScabbyQueenPlayer::ShowHand()
	{
	TInt cardNum;
	iConsole.Printf(_L("\nYour hand...\n"));
	for (TInt i=0; i<=iHand.Length()-2; i=i+2)
		{
		if (i==0)
			cardNum = i;
		else
			cardNum = i/2;
		HBufC16* buffer = HBufC16::NewL(4);
		CleanupStack::PushL(buffer);
		buffer->Des().Copy(iHand.Mid(i,2));
		iConsole.Printf(_L("%d <%S>|"),cardNum,buffer);
		CleanupStack::PopAndDestroy(buffer);
		}
	iConsole.Getch();
	}
Beispiel #20
0
void QtFallbackWebPopup::showS60BrowserDialog()
{
    static MBrCtlDialogsProvider* dialogs = CBrowserDialogsProvider::NewL(0);
    if (!dialogs)
        return;

    int size = itemCount();
    CArrayFix<TBrCtlSelectOptionData>* options = new CArrayFixFlat<TBrCtlSelectOptionData>(qMax(1, size));
    RPointerArray<HBufC> items(qMax(1, size));
    CleanupStack::PushL(TCleanupItem(&ResetAndDestroy, &items));

    for (int i = 0; i < size; i++) {
        if (itemType(i) == Separator) {
            TBrCtlSelectOptionData data(_L("----------"), false, false, false);
            options->AppendL(data);
        } else {
            HBufC16* itemStr = HBufC16::NewL(itemText(i).length());
            itemStr->Des().Copy((const TUint16*)itemText(i).utf16(), itemText(i).length());
            CleanupStack::PushL(itemStr);
            TBrCtlSelectOptionData data(*itemStr, i == currentIndex(), false, itemIsEnabled(i));
            options->AppendL(data);
            items.AppendL(itemStr);
            CleanupStack::Pop();
        }
    }

    dialogs->DialogSelectOptionL(KNullDesC(), (TBrCtlSelectOptionType)(ESelectTypeSingle | ESelectTypeWithFindPane), *options);

    CleanupStack::PopAndDestroy(&items);

    int newIndex;
    for (newIndex = 0; newIndex < options->Count() && !options->At(newIndex).IsSelected(); newIndex++) {}
    if (newIndex == options->Count())
        newIndex = currentIndex();
    
    m_popupVisible = false;
    popupDidHide();

    if (currentIndex() != newIndex && newIndex >= 0)
        valueChanged(newIndex);

    delete options;
}
TBool CBCTestLogger::ReadLineL(RFile& aFile, TDes& aLine)
    {	
 	TBuf8<1> atom;
	TBuf8<1> enter;
	HBufC16* text = HBufC16::NewL( 1 );

 	for( TInt err = aFile.Read(atom); err == KErrNone 
 	    && atom.Length() > 0; err = aFile.Read( atom ) )
 	    {
 		if(atom[0] == 10 && enter[0] == 13)
 		    {
 			break;
 		    }
 		text->Des().Copy(atom);
		aLine.Append(*text);
		enter = atom;
 	    }

 	delete text;
	return atom.Length()>0;
    }    
// ---------------------------------------------------------------------------
// Set Template from file
// ---------------------------------------------------------------------------
//          
void XmlSecTemplate::SetTemplateFromFileL(RXmlEngDocument& aTemplate, 
                                          const TDesC8& aFile, 
                                          RFs& aRFs)
    {
    if(aTemplate.NotNull())
        {
        aTemplate.Close();
        }
    // load template
    HBufC16* buf = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aFile);
    CleanupStack::PushL(buf);
    RXmlEngDOMImplementation dom;
    dom.OpenL();
    CleanupClosePushL(dom);
    RXmlEngDOMParser parser;
    User::LeaveIfError(parser.Open(dom));
    CleanupClosePushL(parser);
    aTemplate = parser.ParseFileL(aRFs,buf->Des());
    CleanupStack::PopAndDestroy(&parser);
    CleanupStack::PopAndDestroy(&dom);
    CleanupStack::PopAndDestroy(buf);
    }
Beispiel #23
0
void CResourceManager::Download(MResConn* conn, HBufC8* aUrl, HBufC8* aFileName,HBufC8* aCookie, TInt aSize)
{
    NBK_PlatformData* pfd = (NBK_PlatformData*) conn->iRequest->platform;
    CNBrKernel* nbk = (CNBrKernel*) pfd->nbk;
    HBufC16* name = NULL;

    if (aUrl == NULL)
        return;
    
    if (aFileName) {
        name = HBufC16::NewL(aFileName->Length());
        name->Des().Copy(*aFileName);
    }
    else
        name = CResourceManager::MakeFileName(*aUrl);
            
    nbk->Download(*aUrl, *name, KNullDesC8, aSize);
    
    if (name) {
        delete name;
    }
}
// ============================================================================
// CWidgetUIConfigHandler::ToUnicodeL
// Utility to bundle transcoding to unicode steps.
//
// @since 3.1
// @param aEncoding input buffer encoding
// @param aUnicodeSizeMultiplier how many bytes of input make one unicode char
// @param aInBuf input data in encoding
// @param aOutBuf malloc'ed output buf, caller takes ownership
// @param aFileSession CCnvCharacterSetConverter requires it
// ============================================================================
//
void CWidgetUIConfigHandler::ToUnicodeL( TInt aEncoding,
                                         TInt aUnicodeSizeMultiplier,
                                         TPtrC8 aInBuf, HBufC16** aOutBuf,
                                         RFs& aFileSession )
    {
    *aOutBuf = NULL;

    // outbuf sizing and alloction
    HBufC16* outBuf = HBufC16::NewLC(aUnicodeSizeMultiplier * aInBuf.Length());
    TPtr16 outPtr = outBuf->Des();

    // convert to unicode
    CCnvCharacterSetConverter* charConv = CCnvCharacterSetConverter::NewLC();
    charConv->PrepareToConvertToOrFromL( aEncoding, aFileSession );
    TInt state = CCnvCharacterSetConverter::KStateDefault;
    TInt rep = 0; // number of unconvertible characters
    TInt rIndx = 0; // index of first unconvertible character
    User::LeaveIfError(
        charConv->ConvertToUnicode( outPtr, aInBuf, state, rep, rIndx ) );
    CleanupStack::PopAndDestroy( charConv );

    CleanupStack::Pop(); // outBuf
    *aOutBuf = outBuf;
    }
void CWapDgrmTestStep::_PrintL(CSmsBufferBase& aSmsBuffer)
/**
 *  print a SMS buffer to the console
 */
{
	HBufC16* WideBuffer = NULL;
	TInt Length = 0;

	// copy the data to the descriptor from aSmsBuffer
	Length = aSmsBuffer.Length();
	WideBuffer = HBufC16::NewL(Length);
	TPtr16 WideChars = WideBuffer->Des();
	aSmsBuffer.Extract(WideChars,0,Length);

	// Length
	_Print(WideChars.Length());
	_Print(_L8(": <"));

	// Data
	_Print(WideChars);
	_Print(_L8(">\n"));

	delete WideBuffer;
}
/**
 * Test CJavaRegistryEntry::Name() method.
 * 1. Application no name defined
 * 2. Application suite no name defined
 * 3. Application name.
 * 4. Application suite name.
 */
TEST(TestRegistryEntry, TestName)
{
    LOG(EJavaStorage, EInfo, "+TestName");
    JavaStorageApplicationEntry_t midlet1;
    JavaStorageEntry attr;

    Uid suite1Uid(L"[e2234577]");

    attr.setEntry(PACKAGE_ID, suite1Uid.toString());
    midlet1.insert(attr);

    Uid midlet1Uid(L"[e2234588]");

    attr.setEntry(ID, midlet1Uid.toString());
    midlet1.insert(attr);

    js->open();
    js->startTransaction();
    CHECK(jtu->populate(*js, APPLICATION_TABLE, midlet1));

    JavaStorageApplicationEntry_t suite1;
    attr.setEntry(ID, suite1Uid.toString());
    suite1.insert(attr);
    attr.setEntry(MEDIA_ID, L"-124614446");
    suite1.insert(attr);

    CHECK(jtu->populate(*js, APPLICATION_PACKAGE_TABLE, suite1));
    js->commitTransaction();

    auto_ptr<CJavaRegistry> registry(CJavaRegistry::NewL());

    // 1. Application uid.
    TUid midletUid;
    uidToTUid(midlet1Uid, midletUid);

    CJavaRegistryEntry* entry = registry->RegistryEntryL(midletUid);
    CHECK(entry != NULL);

    // 1. Application no name defined
    CHECK(entry->Name() == KNullDesC);

    // 2. Application suite no name defined
    TUid suiteUid;
    uidToTUid(suite1Uid, suiteUid);

    delete entry;
    entry = NULL;

    entry = registry->RegistryEntryL(suiteUid);
    CHECK(entry != NULL);
    CHECK(entry->Name() == KNullDesC);

    delete entry;
    entry = NULL;

    JavaStorageApplicationEntry_t midlet2;

    Uid suite2Uid(L"[e2224577]");

    attr.setEntry(PACKAGE_ID, suite2Uid.toString());
    midlet2.insert(attr);

    Uid midlet2Uid(L"[e2224588]");

    attr.setEntry(ID, midlet2Uid.toString());
    midlet2.insert(attr);

    wstring midlet2Name = L"MIDlet2";
    attr.setEntry(NAME, midlet2Name);
    midlet2.insert(attr);

    js->open();
    js->startTransaction();

    CHECK(jtu->populate(*js, APPLICATION_TABLE, midlet2));

    wstring suite2Name = L"MySuite2";
    JavaStorageApplicationEntry_t suite2;
    attr.setEntry(PACKAGE_NAME, suite2Name);
    suite2.insert(attr);
    attr.setEntry(MEDIA_ID, L"-124614446");
    suite2.insert(attr);

    attr.setEntry(ID, suite2Uid.toString());
    suite2.insert(attr);

    CHECK(jtu->populate(*js, APPLICATION_PACKAGE_TABLE, suite2));

    // Session must be committed before next use of Registry otherwise
    // it is locked.
    js->commitTransaction();

    // 3. Application name.
    uidToTUid(midlet2Uid, midletUid);

    entry = registry->RegistryEntryL(midletUid);
    CHECK(entry != NULL);

    const TDesC16& name = entry->Name();
    HBufC16* refName = wstringToBuf(midlet2Name);
    CHECK(name.Compare(refName->Des()) == 0);

    delete refName;
    refName = NULL;
    delete entry;
    entry = NULL;

    // 4. Application suite name.
    uidToTUid(suite2Uid, suiteUid);

    entry = registry->RegistryEntryL(suiteUid);
    CHECK(entry != NULL);

    const TDesC16& name2 = entry->Name();
    refName = wstringToBuf(suite2Name);
    CHECK(name2.Compare(refName->Des()) == 0);

    delete refName;
    refName = NULL;
    delete entry;
    entry = NULL;

    registry.reset(0);

    js->startTransaction();
    CHECK(jtu->remove(*js, APPLICATION_TABLE, midlet1));
    CHECK(jtu->remove(*js, APPLICATION_PACKAGE_TABLE, suite1));
    CHECK(jtu->remove(*js, APPLICATION_TABLE, midlet2));
    CHECK(jtu->remove(*js, APPLICATION_PACKAGE_TABLE, suite2));
    js->commitTransaction();
    js->close();

    LOG(EJavaStorage, EInfo, "-TestName");
}
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);
    }
void CIntegrityServicesSession::ServiceL(const RMessage2& aMessage)
	{
	switch (aMessage.Function())
		{
		case EAdd:
			{
			RDebug::Print(_L("ServiceL EAdd"));
			HBufC16* fileName = HBufC16::NewLC(aMessage.GetDesLength(0));
		  	TPtr16 ptr(fileName->Des());
		  	aMessage.Read(0, ptr);

		  	TRAPD(err, iIntegrityServices->RegisterNewL(*fileName));

			aMessage.Complete(err);
			CleanupStack::PopAndDestroy(fileName);	
			break;
			}
		case ERemove:
			{
			RDebug::Print(_L("ServiceL ERemove"));
			HBufC16* fileName = HBufC16::NewLC(aMessage.GetDesLength(0));
		  	TPtr16 ptr(fileName->Des());
		  	aMessage.Read(0, ptr);

		  	TRAPD(err, iIntegrityServices->RemoveL(*fileName));

			aMessage.Complete(err);
			CleanupStack::PopAndDestroy(fileName);	
			
			break;
			}
		case ETemporary:
			{
			RDebug::Print(_L("ServiceL ETemporary"));
			HBufC16* fileName = HBufC16::NewLC(aMessage.GetDesLength(0));
		  	TPtr16 ptr(fileName->Des());
		  	aMessage.Read(0, ptr);

		  	TRAPD(err, iIntegrityServices->RegisterTemporaryL(*fileName));

			aMessage.Complete(err);
			CleanupStack::PopAndDestroy(fileName);	
			break;
			}
		case ECommit:
			{
			RDebug::Print(_L("ServiceL ECommit"));
			TRAPD(err, iIntegrityServices->CommitL());
			aMessage.Complete(err);
			break;
			}
		case ERollBack:
			{
			RDebug::Print(_L("ServiceL ERollBack"));
			TBool all;
			TPckg<TBool> allTransactions(all);
			aMessage.ReadL(0, allTransactions);
			TInt error=KErrNone;
			
			if(all)
				{
				CIntegrityServices::RollbackAllL();
				}
			else
				{
				TRAPD(err, iIntegrityServices->RollBackL());
				error=err;
				}
			aMessage.Complete(error);
			
			break;
			}
			
		case ESetSimulatedFailure:
			{
			HBufC16* aFailType = HBufC16::NewLC(256);
			HBufC16* aPosition = HBufC16::NewLC(256);
			HBufC16* aFailFileName = HBufC16::NewLC(256);
			TPtr16 failType(aFailType->Des());
			TPtr16 position(aPosition->Des());
			TPtr16 failFileName(aFailFileName->Des());
			
			aMessage.ReadL(0, failType);
			aMessage.ReadL(1, position);
			aMessage.ReadL(2, failFileName);
			RDebug::Print(_L("ServiceL ESetSimulatedFailure %S %S %S"), &aFailType, &aPosition, &aFailFileName);
			TRAPD(err, SetSimulatedFailureL(failType, position, failFileName));
			aMessage.Complete(err);
			CleanupStack::PopAndDestroy(3, aFailType);
			break;
			}
		case ECreateNewTestFile:
			{
			RDebug::Print(_L("ServiceL ECreateNewTestFile"));
			HBufC16* fileName = HBufC16::NewLC(aMessage.GetDesLength(0));
		  	TPtr16 ptr(fileName->Des());
		  	aMessage.Read(0, ptr);

		  	TRAPD(err, CreateNewTestFileL(*fileName));

			aMessage.Complete(err);
			CleanupStack::PopAndDestroy(fileName);	
			break;
			}
		case ECreateTempTestFile:
			{
			RDebug::Print(_L("ServiceL ECreateTempTestFile"));
			HBufC16* fileName = HBufC16::NewLC(aMessage.GetDesLength(0));
		  	TPtr16 ptr(fileName->Des());
		  	aMessage.Read(0, ptr);

		  	TRAPD(err, CreateTempTestFileL(*fileName));

			aMessage.Complete(err);
			CleanupStack::PopAndDestroy(fileName);	
			break;
			}
	default:
		{
		PanicClient(aMessage, EPanicIntegrityServicesServerIllegalFunction);
		break;
		}
		}
	}
/**
 * Checks if @c aItemText matches @c aSearchText in the sense described in
 * S60.  Calls UpdateNextCharsL() if findutil is not supported.
 *
 * @since 5.0
 * @param aItemText list box item text.
 * @param aSearchText search text.
 * @param aNextChars reference to the next characters for the adaptive search grid
 * @param aDigraphs digraphs and trigraph text.
 * 
 * @return @c ETrue if list box item text matches aSearchText EFalse otherwise.
 */
inline TBool IsAdaptiveFindMatch( const TDesC& aItemString, 
	const TDesC& aSearchText, HBufC*& aNextChars, TInt /*aInputLang*/, const TDesC& aDigraphs )
	{	    	
	HBufC16* searchText = NULL;
	TRAPD( error, searchText = HBufC16::NewL( KMatchingBufferLength ) );
	TBool wildchar = EFalse;
	if ( error == KErrNone )
	    {
	    TInt itemStringLength = aItemString.Length();
        TInt searchTextLength = aSearchText.Length();    
        
        if ( searchTextLength < KMatchingBufferLength )
        	{
        	searchText->Des().Append( aSearchText );
        	}
        else
        	{
        	searchText->Des().Append( aSearchText.Left(KMatchingBufferLength-1) );
        	}  
        	 
         // To disable the wildchar matching provided by MatchC
        if ( aSearchText.Locate( KLitQuestion ) != KErrNotFound || 
             aSearchText.Locate( KLitStar ) != KErrNotFound )
            {            
            wildchar = IsAdaptiveFindMatchClassic( aItemString, aSearchText );
            if ( wildchar == EFalse )
                {
                delete searchText;
                return wildchar;
                }
            else 
                {  
                TInt val;      
                searchText->Des().Append( KLitStar );
                for( TInt i = 0; i < itemStringLength; i++ )
                    {
                    if ( i == 0 || IsFindWordSeparator( aItemString[i-1] ) )
                        {
                        val = MyFindC(  aItemString, aSearchText );                    
                        if( (val == i) && (i < (itemStringLength-searchTextLength))) 
                            {
                            if( !(IsThaiSpecialCharacter(aItemString[i+searchTextLength])) && !(IsVietnameseSpecialCharacter( aItemString[i+searchTextLength]) ))
                                {
                                TRAP_IGNORE( UpdateNextCharsL( aNextChars, aItemString[i+searchTextLength]) );   
                                }                                
                            }
                        }         
              	    } // for
              	delete searchText;
                return wildchar;	 
                }
            }
      	     	
        searchText->Des().Append( KLitStar );
        searchText->Des().UpperCase();

        TBool isCommonChars = EFalse;
        TInt all_result = KErrNotFound;
        
        TLanguage lang = User::Language();
        
        for( TInt i = 0; i < itemStringLength; i++ )
            {
            if ( i == 0 || IsFindWordSeparator( aItemString[i-1] ) )
                {
                TInt result = KErrNotFound;
                //Some vowels of Thai can not be searched with MatchC(). 
                if( aDigraphs.Length() != 0 || lang == ELangThai )
                    {
                    result = aItemString.Mid(i).Match( searchText->Des() );
                    }
                else
                    {
                    result = aItemString.Mid(i).MatchC( searchText->Des() );
                    }
                
                if( result != KErrNotFound ) 
                    {
                    all_result = result;
                    if( i < (itemStringLength-searchTextLength) )                	   	       	   		
                        {
                        if( !(IsThaiSpecialCharacter( aItemString[i+searchTextLength])) && !(IsVietnameseSpecialCharacter( aItemString[i+searchTextLength]) ))
                            {
                            TRAP_IGNORE( UpdateNextCharsL( aNextChars, aItemString[i+searchTextLength]) );

                            if ( aDigraphs.Length() != 0 )
                                {
                                TBuf<2> digraph;
                                digraph.Append( aItemString[i+searchTextLength-1] );
                                digraph.Append( aItemString[i+searchTextLength] );

                                if( searchTextLength == 1 )
                                    {
                                    if( aDigraphs.Find( digraph ) == KErrNotFound )
                                        {
                                        isCommonChars = ETrue;
                                        }
                                    }
                                else
                                    {
                                    TBuf<3> trigraph;
                                    trigraph.Append( aItemString.Mid(i+searchTextLength-2,3) );
                                    if( digraph[0] == KLitSpace 
                                        || ( aDigraphs.Find( digraph ) == KErrNotFound
                                        && aDigraphs.Find( trigraph ) == KErrNotFound ) )
                                        {
                                        isCommonChars = ETrue;
                                        }
                                    }
                                }
                            }            	   
                        }
                    else
                        {
                        isCommonChars = ETrue;
                        }
                    }                                                                  	   	
                } // if (i==0 ..)  
      	    } // for	 
        
        if(aDigraphs.Length() != 0 && !isCommonChars )   
            {
            all_result = KErrNotFound;
            }
	    
  	    if( all_result != KErrNotFound )
            {
            delete searchText;
            return ETrue;
           	}    
        else 
            {
            delete searchText;
            return EFalse;
            }
        	            		
         } // if (error == KErrNone)   
    delete searchText;                 
    return EFalse;
	}
/** 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;
}