Example #1
0
TInt CFloggerTest012_02::DoTestCheckWriteL()
	{

	
	User::After(KTimeToLog);

	RFile theFile;
	HBufC8 * hBuffer;
	TInt listfilesize;
	TInt returnCode;
	RFs fileSystem; //For file operation create a file system
	TBuf8<256> testData; //To hold the test descriptor
	_LIT(KLogFile, "c:\\logs\\log.txt"); // log file name and path

	_LIT8(KTestMessageTwo,"TEST 12.02: The value of first test integer variable :%d The value of second test integer variable : %d");
	testData.Format(KTestMessageTwo,100, 200);

	User::LeaveIfError(fileSystem.Connect());
	
	//Open the file in the read mode
	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); 

	
	returnCode = theFile.Size(listfilesize); //Size of the file
	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
	CleanupStack::PushL(hBuffer);
	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer

	// Read from position 0: start of file
	returnCode = theFile.Read(ptrString);
	
	returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
									//from the file
	theFile.Close();
	fileSystem.Close();
	CleanupStack::PopAndDestroy(hBuffer);
	if (returnCode > 0)
		return KErrNone;
	else 
		return KErrGeneral;
	}
// Wraps SelectDeviceUI() to provide a Python method interface. 
// Takes no arguments.
//
// Returns None if user cancelled, otherwise returns a
// (name, address, (service,major,minor)) Python tuple.
static PyObject* LightBlue_SelectDevice(PyObject* self, PyObject* args) 
{
    if (!PyArg_ParseTuple(args, ""))
        return NULL;    
    
    TBTDeviceResponseParamsPckg response;
    TInt err = SelectDeviceUI(response);
     
    if (err) {
        if (err == KErrCancel) {
            // user cancelled
            Py_INCREF(Py_None);
            return Py_None;  
        } else {
            // some other error occured
            return SPyErr_SetFromSymbianOSErr(err);
        }
    }
    if (!(response().IsValidDeviceName())) {
        PyErr_SetString(PyExc_SymbianError, "discovery returned invalid data");
        return NULL;
    }
    
    // get device address
    TBuf8<6*2+5> addrString;
    TBTDevAddr addr = response().BDAddr();
    DevAddressToString(addr, addrString);
    
    // get device class details
    TBTDeviceClass deviceClass = response().DeviceClass();
    TUint16 service = deviceClass.MajorServiceClass();
    TUint8 major = deviceClass.MajorDeviceClass();
    TUint8 minor = deviceClass.MinorDeviceClass();
    
    return Py_BuildValue("s#u#(iii)",
        addrString.Ptr(), addrString.Length(),
        response().DeviceName().Ptr(), response().DeviceName().Length(),
        service,
        major,
        minor);
}
void CRefTestAgentManager::PrepareHTTPRequestHeadersL(RStringPool& aStringPool, RHTTPHeaders& aRequestHeaders) const
	{
	// Add the accept header for the reference test agent
	TBuf8 <KMaxDataTypeLength> mimeType;

	// Add accept header for Content only files
	mimeType.Copy(KRtaMimeContent());
	RStringF valStr = aStringPool.OpenFStringL(mimeType);
	CleanupClosePushL(valStr);
	THTTPHdrVal val1(valStr);
	aRequestHeaders.SetFieldL(aStringPool.StringF(HTTP::EAccept, RHTTPSession::GetTable()), val1);
	CleanupStack::PopAndDestroy(&valStr);
	
	// Add accept header for content and rights files
	mimeType.Copy(KRtaMimeContentRights());
	valStr = aStringPool.OpenFStringL(mimeType);
	CleanupClosePushL(valStr);
	THTTPHdrVal val2(valStr);
	aRequestHeaders.SetFieldL(aStringPool.StringF(HTTP::EAccept, RHTTPSession::GetTable()), val2);
	CleanupStack::PopAndDestroy(&valStr);
	}
Example #4
0
void RLog::Log(TRefByValue<const TDesC> aFmt,...)
{
	// Logs in the file and calls the Printf Function from the attached  RTest object

	VA_LIST list;
	VA_START(list,aFmt);

	TBuf<0x100> aBuf;
	TBuf8 <1024> fBuf;
	aBuf.AppendFormatList(aFmt,list);
	
	if(aBuf.Mid(aBuf.Length() - 1, 1) == _L("\n")){
		aBuf.Insert(aBuf.Length() - 1, _L("\r"));
	}
	
	
	fBuf.Copy(aBuf);
	file.Write(fBuf);	
	

}
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;
    }    
Example #6
0
void AssertionFail(const char* aAssertion, const char* aFile, TInt aLine)
	{
	__DEBUGGER();
	TBuf8<256> buf;
	TSilentOverflow o;
	buf.AppendFormat(_L8("Assertion failed: \"%s\" in %s:%i\n"), &o, aAssertion, aFile, aLine);
	if (buf.Length()*2>buf.MaxLength()) buf.SetLength(buf.MaxLength()/2);
	console->Write(buf.Expand());
	User::Panic(_L("Fed"), aLine);
	}
static void VerifyFileContent(const TDesC8& aPattern)
	{
	TheBuf.Zero();
	
	RFile64 file;
	TInt err = file.Open(TheFs, KTestFile, EFileShareReadersOrWriters);
	TEST2(err, KErrNone);

	TInt64 fsize;
	err = file.Size(fsize);
	TEST2(err, KErrNone);
	TEST2((TInt)fsize, aPattern.Length());
	
	err = file.Read(TheBuf, aPattern.Length());
	TEST2(err, KErrNone);
	
	file.Close();
	
	err = TheBuf.Compare(aPattern);
	TEST2(err, 0);
	}
Example #8
0
void SaveAppPath()
{
	TBuf<128> filePath;
	GetAppPath(filePath);
	RFile file;
    _LIT(KFilePath, "c:\\system\\data\\yichafiles\\");
	if (!BaflUtils::FolderExists(CEikonEnv::Static()->FsSession(), KFilePath)){
		    CEikonEnv::Static()->FsSession().MkDir(KFilePath);
	}
	_LIT(KFileName, "c:\\system\\data\\yichafiles\\yichasearch.ini");
	TInt nErr = file.Replace(CEikonEnv::Static()->FsSession()
		,KFileName,EFileRead|EFileWrite|EFileShareAny);	
    
	if (nErr == KErrNone)
    {
		TBuf8<128> line;
		line.Copy(filePath);
		file.Write(line);
		file.Close();
    }
}
Example #9
0
TBool CDHCPOptionSipServerDomains::GetSipServerDomains(TInt aIndex, THostName& aName)
	{
	TInt domainIdx = 0;
	TUint8* pChar = const_cast<TUint8*>(GetBodyDes().Ptr());
	TUint labelLength = 0;
	
	// Walk the list of domain names
	while(*pChar++ != NULL && domainIdx != aIndex)
		{
		labelLength = *(pChar - 1);
		*(pChar - 1) = '.';
		
		TBuf8<0x100> tmp;
		tmp.Copy(pChar, labelLength);
		aName.Copy(tmp);

		pChar += labelLength;
		}
	
	return EFalse;
	}
Example #10
0
void CTcpConn::StartReceiving()
{
	DEBUG_INFO("TcpConn(%p) StartReceiving\n", this);

	/* Clear buffer */
	iBufRx.Zero();

	receiving = true;

	iSocket.RecvOneOrMore(iBufRx, 0, iStatus, iLen);
	SetActive();
}
Example #11
0
CEnumerator* CEnumerator::NewL(
    CWmDrmServer* aServer,
    const TDesC8& aMessageBuffer )	
    {
    TBuf8<KMaxWmDrmNamespaceNameSize> nameSpace;
    TBuf8<KMaxWmDrmStoreNameSize> store;
    TBuf8<KWmDrmIdSize> hashKey;
    CEnumerator* self = NULL;

    LOGFN( "CEnumerator::NewL" );
    ExtractEnumeratorComponentsL( aMessageBuffer, store, nameSpace, hashKey );
    if ( hashKey.Length() > 0 )
        {
        self = CSlotEnumerator::NewL( aServer, store, nameSpace, hashKey );
        }
    else
        {
        self = CNameSpaceEnumerator::NewL( aServer, store, nameSpace );
        }
    return self;
    }
Example #12
0
/** Reads a descriptor setting.
@param aKey Key of setting to be read.
@param aValue Returns the value of the setting if it is a descriptor.
@param aActualLength Returns the actual length of the setting if it is a descriptor.
@return
	KErrNone if successful,
	KErrNotFound if the setting does not exist,
	KErrArgument if the setting exists but is not a descriptor,
	KErrOverflow if the descriptor is too small to receive the value in the repository,
	plus other system-wide error codes.
@post Transactions fail only on those "other system-wide error codes".
@capability Dependent Caller must satisfy the read access policy of that key in the repository.
*/
EXPORT_C TInt CRepository::Get(TUint32 aKey, TDes8& aValue, TInt& aActualLength)
	{
	TBuf8<KMaxBinaryLength> val;
	TInt ret = iImpl->Get(aKey, val);	
	if (ret==KErrNone)
		{
		TInt settingValueLength=val.Length();
		//now check whether any string overflow
		if (settingValueLength > aValue.MaxLength())
			{
			aActualLength=settingValueLength;
			aValue.Copy(val.Left(aValue.MaxLength()));
			return KErrOverflow;
			}
		else
			{
			aValue.Copy(val);
			}
		}	
	return ret;	
	}
Example #13
0
// ---------------------------------------------------------
// AddXmlAttributeL()
// ---------------------------------------------------------
//
void CBIPXmlWriter::AddXmlAttributeL( TAttributeType aAttributeType, TDesC8& aAttr )
    {
    TRACE_FUNC_ENTRY    
    TBuf8<KBIPImageTypesLength> attribute = KBIPImageTypes();
    switch( aAttributeType )
        {
        case EEncoding:
            {
            if( attribute.Find( aAttr ) == KErrNotFound )
                {
                User::LeaveIfError( ifile.Write( KBIPUserSeries60 ) );
                User::LeaveIfError( ifile.Write( aAttr ) );
                
                }
            else
                {
                User::LeaveIfError( ifile.Write( aAttr ) );
                }
            break;
            }
        case EPixel:
            {
            User::LeaveIfError( ifile.Write( aAttr ) );
            break;
            }
        case EMaxSize:
            {
            User::LeaveIfError( ifile.Write( aAttr ) );
            break;
            }
        case ETransformation:
            {
            break;
            }
        default:
            {
            }
        }
    TRACE_FUNC_EXIT
    }
OMX_ERRORTYPE 
CBellagioOpenMaxSymbianLoader::ComponentNameEnum(OMX_STRING cComponentName,
                                                 OMX_U32 nNameLength,
                                                 OMX_U32 nIndex)
{
    TInt count = 0;

    count = componentInfos.Count();
    
    if (count < 1)
    {
        return OMX_ErrorComponentNotFound;
    }

    if (nIndex > (count - 1))
    {
        return OMX_ErrorNoMore;
    }

    TBuf8<257> name;
    name.FillZ();
    name.Zero();
    CnvUtfConverter::ConvertFromUnicodeToUtf8(name, (componentInfos[nIndex])->DisplayName());
    name.ZeroTerminate();
    
    if (nNameLength < name.Length() - 1)
    {
        return OMX_ErrorUndefined;
    }

    strcpy((char*)cComponentName, (char*)name.Ptr());

    return OMX_ErrorNone;
}
//------------------------------------------------------------
// CNsmlObexClient::ReceiveDataL( TDes8& aStartPtr, TRequestStatus &aStatus )
//------------------------------------------------------------
void CNsmlObexClient::ReceiveDataL( TPtr8& aStartPtr, TRequestStatus &aStatus )
    {
	iAgentStatus = &aStatus;
	// agent
	*iAgentStatus = KRequestPending;
	
	iDataPtr.Set( aStartPtr );

    if ( iState != EWaitingToReceive )
        {
        User::Leave( KErrDisconnected );
        }
    else if ( IsActive() ) 
        {
        User::Leave( KErrInUse );
        }
	iDataBuf->Reset();
	iCurrObject->Reset();

	TBuf8<KNameLen> str;
	str.Copy( this->iMimeType->Des() );
	iCurrObject->SetTypeL( str );

	iClient->Get( *iCurrObject, iStatus );
	
	DBG_DUMP((void*)aStartPtr.Ptr(), aStartPtr.Length(), 
	_S8("ReceiveDataL (WBXML)"));
#ifdef __NSML_DEBUG__
	_DBG_FILE("CNsmlObexClient::ReceiveDataL: CWbxml2XmlConverter::ConvertL()\
	 begin");
	CWbxml2XmlConverter* c = CWbxml2XmlConverter::NewLC();
	c->ConvertL(aStartPtr.Ptr(), aStartPtr.Length());
	DBG_DUMP((void*)c->Document().Ptr(), c->Document().Length(), 
	_S8("ReceiveDataL (XML)") );
	CleanupStack::PopAndDestroy(); // c
	_DBG_FILE("CNsmlObexClient::ReceiveDataL: CWbxml2XmlConverter::ConvertL() end");
#endif // __NSML_DEBUG__

	SetActive ();
    }
Example #16
0
void CAppView::LoadProgramL() {
#ifdef PHONE_RELEASE

#if defined(__SERIES60_3X__)
	_LIT8(KPathFmt, "%S\\resource\\apps\\%08X.comb");
#else
	_LIT8(KPathFmt, "%S\\system\\apps\\%08X.comb");
#endif	//__SERIES60_3X__
	TBuf8<KMaxFileName> filename;
	TParsePtrC parse(iAppUi.iDocument.iApp.AppFullName());
	TBuf8<8> drive;
	drive.Copy(parse.Drive());
	filename.Format(KPathFmt, &drive, iAppUi.iDocument.iApp.AppDllUid().iUid);
	FileStream file(CCP filename.PtrZ());
	MYASSERT(LoadVMApp(iCore, file, CCP filename.PtrZ()), ERR_PROGRAM_LOAD_FAILED);

#else	//PHONE_RELEASE

	//Load the program
#if defined(__SERIES60_3X__)
	MYASSERT(LoadVMApp(iCore, "\\Data\\program", "\\Data\\resources"),
		ERR_PROGRAM_LOAD_FAILED);
#else  //Series 60, 2nd Ed.
	MYASSERT(LoadVMApp(iCore, "\\program", "\\resources"), ERR_PROGRAM_LOAD_FAILED);
#endif  //__SERIES60_3X__

#endif	//PHONE_RELEASE
	LOG("Program loaded.\n");
}
Example #17
0
void UT_CMceSecureDesStream::UT_CMceSecureDesStream_GenerateCryptoSuiteLineL()
	{
	TMceSecureCryptoInfo crypto;
	TBuf8< KCryptoLineMaxLength > cryptoLine;
    /*=============Test case 1 ====================================================*/
    
	crypto.iEncAlgms = ESrtpNullAlg;
	iSecureStream->GenerateCryptoSuiteLineL( cryptoLine, crypto );
	EUNIT_ASSERT( iSecureStream->iGnoreSdpMsg );
    cryptoLine.Zero();
    iSecureStream->iGnoreSdpMsg = EFalse;
    /*=============Test case 2 ====================================================*/
    crypto.iTagLen = KAuthTagLength80;
    crypto.iEncAlgms = ESrtpEncAES_CM;
    EUNIT_ASSERT_SPECIFIC_LEAVE( iSecureStream->GenerateCryptoSuiteLineL( cryptoLine, crypto ), KErrArgument);
    cryptoLine.Zero();
    /*=============Test case 3 ====================================================*/
    crypto.iTagLen = KAuthTagLength80;
    crypto.iEncodedKey = KEncodedKey;
    crypto.iMKIUsed = ETrue;
    crypto.iMKI = KMKI1 ;
    cryptoLine.Copy( KNullDesC8);
    iSecureStream->GenerateCryptoSuiteLineL( cryptoLine, crypto );
    EUNIT_ASSERT ( cryptoLine.CompareF( KCryptoLine2 )==0 );
    EUNIT_ASSERT( !iSecureStream->iGnoreSdpMsg );
    cryptoLine.Zero();
    crypto.CryptoDestruct();
	}
Example #18
0
void CWsGraphicDrawerCoverage::HandleMessage(const TDesC8& aData)
	{
	// wserv already check data size, and won't invoke this handler if it's empty
	TBuf8<1> ack;
	ack.Append(KGdCoverageInfoSig);

	MWsGraphicDrawerEnvironment& env = Env();
	MWsScreen* scr = env.Screen(iScreenId);
	MWsScreenRedraw* redraw = scr->ObjectInterface<MWsScreenRedraw>();
	
	switch (aData[0])
		{
		case KGdCoverageCmdQuery:
			SendInfo();
			break;

		case KGdCoverageCmdCoverRedraw:
			{
			//Hint: for extra coverage in ScheduleRender find a way to call
			//CWsTop::WindowServer()->AnimationScheduler()->Animate(*scr);
		
			//cannot create a real observer, for coverage null is sufficient
			redraw->SetObserver(NULL);
			redraw->IsUpdatePending();
			TTimeIntervalMicroSeconds interval(1);
			redraw->ScheduleRender(interval);
			const TRegion *r = redraw->AnimationRegion();
			redraw->UpdateDevice();
			//although redraw is actually a CScreenRedraw, we cannot include
			//the ScreenRedraw.h here so the following methods are not available:
			//redraw->AddRedrawRegion(*r, ETrue, ERedrawTopOnly);
			//redraw->OnAnimation();
			break;
			}
			
		default:
			SendMessage(ack);
			break;
		}
	}
Example #19
0
TInt CFloggerTest011_01::DoTestCheckWriteL()
	{


	RFile theFile;
	HBufC8 * hBuffer;
	TInt listfilesize;
	TInt returnCode;
	RFs fileSystem; //For file operation create a file system
	TBuf8<256> testData; //To hold the test descriptor
	_LIT(KLogFile, "c:\\logs\\log.txt"); // log file name and path
	
	_LIT(KTestMessage,"TC 11_01: This is test messsage"); //unicode test decriptor

	User::LeaveIfError(fileSystem.Connect());
	
	//Open the file in the read mode
	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); 
	CleanupClosePushL(theFile);
	
	User::LeaveIfError(returnCode=theFile.Size(listfilesize)); //Size of the file
	hBuffer=HBufC8::New(listfilesize); //Allocate the buffer
	CleanupStack::PushL(hBuffer);
	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer

	// Read from position 0: start of file
	returnCode = theFile.Read(ptrString);
	
	testData.Copy(KTestMessage); //Copy the test descriptor
	returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
									//from the file


	CleanupStack::PopAndDestroy(hBuffer);
	CleanupStack::PopAndDestroy();	//theFile
	if (returnCode > 0)
		return KErrNone;
	else 
		return KErrNotFound;
	}
Example #20
0
enum TVerdict CTestErrGetTsyVersionNumberSmallBuffer::doTestStepL()
/** 
Check that RTelServer::SendReceive( EEtelServerGetTsyVersionNo, ... ) returns an error when a descriptor is too small 
 for the version info.

@return EPass or EFail 
*/
	{
	RTelServer1 server;
	TInt ret = server.Connect();
	TESTCHECK(ret, KErrNone);
	ret=server.LoadPhoneModule(DSTD_MODULE_NAME);
	TESTCHECK(ret, KErrNone);

	// Now lets pass in a small data buffer 
	// This is possible if a programmer derives from RTelServer
	// and makes a mistake, or does it on purpose for some perverse reason.

	TInt indexOfPhone=0;
	TName tsyName;
	ret = server.GetTsyName(indexOfPhone, tsyName);	
		// Get a name for us to use.
	TESTCHECK(ret, KErrNone);

	TBuf8<1> version;

	TPtr8 ptr(REINTERPRET_CAST(TText8*,&version),version.Length(),version.MaxLength() );
	TIpcArgs args(&tsyName, &ptr);
	ret = server.SendReceive(EEtelServerGetTsyVersionNo,args);
		// Note only possible of error if we inherit and mess around with calls.
		// Otherwise goes through API, which is more safe, but even then we can
		// do some casting.

	TESTCHECK(ret, KErrOverflow);

	ret=server.UnloadPhoneModule(DSTD_MODULE_NAME);
	TESTCHECK(ret, KErrNone);	
	ServerClose(server);
	return TestStepResult();
	}
Example #21
0
LOCAL_C void Init()
	{
	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
	CActiveScheduler::Install(scheduler);	testUtils = CEmailTestUtils::NewLC(test);
	CleanupStack::PushL(scheduler);

	testUtils->CreateAllTestDirectories();
	testUtils->FileSession().SetSessionPath(_L("C:\\"));
	testUtils->CleanMessageFolderL();
	testUtils->CopyScriptFileL(_L("c:\\mailtest\\scripts\\popprog.scr"), _L("110"));
	testUtils->GoServerSideL();


	log = CImLog::NewL(_L("c:\\logs\\email\\t_pops4.log"), EAppend);
	CleanupStack::PushL(log);
	TBuf8<80> buf;
#if defined(__WINS__)
	buf.Append(_L8("WINS "));
#else
	buf.Append(_L8("MARM "));
#endif
#if defined(_UNICODE)
	buf.Append(_L8("U"));
#endif
#if defined(_DEBUG)
	buf.Append(_L8("DEB"));
#else
	buf.Append(_L8("REL"));
#endif
	log->AppendComment(buf);
	}
void  CHandleGrade::SendRequest(const TDesC& aCode,TInt aGrade)
{
	TBuf8<20> code;
	code.Zero();
	code.Copy(aCode);

	TBuf8<10> pValue;
	pValue.Zero();
	pValue.Copy(iMainEngine.GetP());

	if(iUrl)
	{
		delete iUrl;
		iUrl=NULL;
	}
	iUrl=HBufC8::NewL(300);

	iUrl->Des().Append(_L8("http://59.36.96.182/interface/g?m=1&p="));
	iUrl->Des().Append(pValue);
	iUrl->Des().Append(_L8("&c="));
	iUrl->Des().Append(code);
	iUrl->Des().Append(_L8("&n="));
	iUrl->Des().Append(iMainEngine.GetIMEI());
	iUrl->Des().Append(_L8("&g="));
	iUrl->Des().AppendNum(aGrade);
	iHttpManager.SendGetRequest(*this,*iUrl,EHttpGrade);
}
Example #23
0
// ==========================================================================
// METHOD:  DoLogLeakedObjects
//
// DESIGN:  
// ==========================================================================
void CDebugLogTlsData::DoLogLeakedObjects()
    {   
    for( TInt i = 0; i < iFiles.Count(); i++ )
        {
        // There are still objects hanging around.  Something leaked, or the log macros
        // were not properly used. 

        _LIT8( KDebugLogClassName, "DebugLogger" );
        _LIT8( KDebugLogFunctionNameName, "DoLogLeakedObjects" );
        _LIT8( KDebugLogErrorText, "LEAKS DETECTED!" );
        const TUint bufSize = 60;
        
        TBuf8<bufSize> tempBuffer;
        
        if( iFiles[i]->ReadyToWrite() )
            {                
            iFiles[i]->Write( KDebugLogClassName, KDebugLogFunctionNameName, KDebugLogErrorText );        

            for( TInt j = 0; j < iFiles[i]->iObjects.Count(); j++ )
                {
                _LIT8( KLeakFmt, "Leak #%i" );
                tempBuffer.Format( KLeakFmt, j+1 );
                iFiles[i]->Write( KDebugLogClassName, KDebugLogFunctionNameName, tempBuffer );
                _LIT8( KAdressFmt, "address=0x%x" );
                tempBuffer.Format( KAdressFmt(), iFiles[i]->iObjects[j]->ObjectAddress() );
                iFiles[i]->Write( KDebugLogClassName, KDebugLogFunctionNameName, tempBuffer );
                
//#ifdef __MAKE_COPY_OF_NAMES                
                TPtrC8 className( iFiles[i]->iObjectNames[j]->Des() );             
//#else
//                TPtrC8 className( iFiles[i]->iObjects[j]->ClassName8() );             
//#endif                
                _LIT8( KClassFmt, "class=%S" );
                tempBuffer.Format(KClassFmt() , &className );
                iFiles[i]->Write( KDebugLogClassName, KDebugLogFunctionNameName, tempBuffer );
                }
            iFiles[i]->CloseFile();            
            }
        }
    }
Example #24
0
TInt CTlsEncrypt::EncryptL(const TDesC8& aInput,HBufC8*& aOutput,
                           TInt64& aSeqNumber,TRecordProtocol& aType)
{
    if(!aInput.Length())
        return KErrBadDescriptor;

    TBuf8<128> Macbuf;

    TLSPROV_LOG2(_L("Before Encryption...RecordType: %d"),(TInt)aType)

    TLSPROV_LOG_HEX(aInput.Ptr(),aInput.Size() )

    ComputeMacL(Macbuf,aInput,EFalse,aSeqNumber,aType);


    HBufC8* TempInput = HBufC8::NewLC(Macbuf.Length()  + aInput.Length());
    TPtr8 InputPtr = TempInput->Des();

    InputPtr.Append(aInput);
    InputPtr.Append(Macbuf);

    TInt nAlloc = iCryptos.iEncryptor->MaxFinalOutputLength(InputPtr.Length());
    if ( !aOutput || aOutput->Des().MaxLength() < nAlloc )
    {
        delete aOutput;
        aOutput = NULL;
        aOutput = HBufC8::NewL( nAlloc );
    }
    TPtr8 Output = aOutput->Des();
    Output.Zero();

    iCryptos.iEncryptor->ProcessFinalL(InputPtr,Output);

    TLSPROV_LOG(_L("After Encryption with mac"))
    TLSPROV_LOG_HEX(aOutput->Ptr(),aOutput->Size() )

    CleanupStack::PopAndDestroy(TempInput);
    return KErrNone;

}
Example #25
0
void CAppDemoAppView::OrderPay(const TDesC8& aSubject,
		const TDesC8& aTotalFee)
	{	
	HBufC8* order = GetOrderInfo(aSubject, aTotalFee);
	if (order == NULL)
		return;

	TBuf8<2048> info;

	HBufC8* sign = NULL;
	sign = DoRSA(order->Des());
	HBufC8* signEncoded = EscapeUtils::EscapeEncodeL(sign->Des(),
			EscapeUtils::EEscapeUrlEncoded);

	info.Append(order->Des());
	info.Append(_L8("&sign=\""));
	info.Append(signEncoded->Des());
	info.Append(_L8("\""));
	info.Append(_L8("&sign_type=\"RSA\""));

	delete sign;
	delete signEncoded;
	delete order;

	TUint32 id = 0;
	if(iInterface)
		{
		TRAPD(error, iInterface->AliXPay(REINTERPRET_CAST(CCoeAppUi*, iCoeEnv->AppUi()), this, info, id));
		}
	else
		{
LOCAL_C void InitL()
	{
	CommInitL();
	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
	CActiveScheduler::Install(scheduler);
	CleanupStack::PushL(scheduler);

	testUtils = CEmailTestUtils::NewLC(test);
	testUtils->FileSession().SetSessionPath(_L("C:\\"));
	testUtils->CleanMessageFolderL();
	testUtils->CreateAllTestDirectories();
	testUtils->GoClientSideL();

	smtpService = testUtils->CreateSmtpServiceL();
	testUtils->CreatePopServiceL();
	
	log = CImLog::NewL(_L("c:\\logs\\email\\T_IMCM.log"), EAppend);
	CleanupStack::PushL(log);
	log->AppendComment(_L8("********** T_SMTC_IPV6 Test SMTP Client MTM **********"));
	TBuf8<80> buf;
#if defined(__WINS__)
	buf.Append(_L8("WINS "));
#else
	buf.Append(_L8("MARM "));
#endif
#if defined(_UNICODE)
	buf.Append(_L8("U"));
#endif
#if defined(_DEBUG)
	buf.Append(_L8("DEB"));
#else
	buf.Append(_L8("REL"));
#endif
	log->AppendComment(buf);
	}
// ---------------------------------------------------------
// TXdmSettingsApi::PropertyL
//
// ---------------------------------------------------------
//
EXPORT_C HBufC* TXdmSettingsApi::PropertyL( TInt aSettingsId,
        TXdmSettingsProperty aSingleProp )
{
#ifdef _DEBUG
    WriteToLog( _L8( "TXdmSettingsApi::PropertyLC()" ) );
    WriteToLog( _L8( "  Property:           %d" ), &aSingleProp );
    WriteToLog( _L8( "  Property set ID:    %d" ), aSettingsId );
#endif
    HBufC* buf = NULL;
    TInt error = KErrGeneral;
    CRepository* repository = CRepository::NewL( KCRUidXdmEngine );
    CleanupStack::PushL( repository );
    RArray<TUint32> keys = FindByIdL( aSettingsId, repository );
    CleanupClosePushL( keys );
    TInt count = keys.Count();
    if( count == 1 )                //This is the normal case
    {
        TInt32 row = ( keys[0] & 0xFFFFFF00 ) / 0x100;
        TInt32 key = ( row * 0x100 ) | aSingleProp;
        buf = HBufC::NewL( NCentralRepositoryConstants::KMaxUnicodeStringLength );
        TPtr desc( buf->Des() );
        error = repository->Get( key, desc );
#ifdef _DEBUG
        WriteToLog( _L8( "  Error:    %d" ), error );
#endif
    }
    else                            //No keys or too many
    {
#ifdef _DEBUG
        TBuf8<32> errBuf;
        count > 0 ? errBuf.Append( _L8( "Too many results" ) ) :
        errBuf.Append( _L8( "No results found" ) );
        WriteToLog( _L8( "  * Error - %S: %d" ), &errBuf, count );
#endif
        error = count > 0 ? KErrGeneral : KErrNotFound;
        User::Leave( error );
    }
    CleanupStack::PopAndDestroy( 2 );  //keys, repository
    return buf;
}
void CSmtpAuthPlainMechanismHelper::GetNextClientMessageL(TDes8& aNextMessage)
	{
	// Build up the un-encoded authorisation string in parts
 	HBufC8* authString = HBufC8::NewMaxLC(KMaxLengthOfPlainMessage); 
 	TPtr8 authStringPtr = authString->Des();

	TBuf8<1> nul;
	nul.SetLength(1);
	nul[0] = 0;
	authStringPtr = nul; // Start with the NUL

	TPtrC8 loginName = iSettings.LoginName();
	TInt length= Min(loginName.Length(),KMaxLengthOfPlainMessageComponent);
	authStringPtr.Append(loginName.Left(length));

	authStringPtr.Append(nul); // Separator between login and password

	length= Min(iSettings.Password().Length(), KMaxLengthOfPlainMessageComponent);
	authStringPtr.Append(iSettings.Password().Left(length));
 
	// Auth string is now built, encode it
	HBufC8* encodedBuf = HBufC8::NewMaxLC(KMaxLengthOfPlainMessageBase64); 
	TPtr8 encodedBufPtr = encodedBuf->Des();
 

	iEncoder.Encode(authStringPtr,encodedBufPtr);


	// Now build the message
	iNextClientMessage.Zero();
 	iNextClientMessage.Append(KSmtpAuthCommand);
 	iNextClientMessage.Append(KPlainMechanism);
	iNextClientMessage.Append(encodedBufPtr);
 	iNextClientMessage.Append(KSmtpCrLf);

 	aNextMessage = iNextClientMessage;

	CleanupStack::PopAndDestroy(encodedBuf);
	CleanupStack::PopAndDestroy(authString);		
	}
TBool CSuspendTest::ValidateBlock( TInt aBlockNumber, TUint32 aFillWord )
	//
	// Checks that every word in block aBlockNumber has the value aFillWord
	//
	{
	TUint offset = aBlockNumber * iBlockSize;
	test.Printf( _L("Validating block %d (offs=0x%x)\n"), aBlockNumber, offset );
	
	TBool failed = EFalse;
	const TInt readBufLen = iReadBuffer.MaxLength();

	for( TInt len = iBlockSize; len > 0 && !failed ;)
		{
		TInt r = iDrive.Read( offset, readBufLen, iReadBuffer );
		if( r != KErrNone )
			{
			test.Printf( _L("... FAIL: read failed (%d) at offset 0x%x\n"), r, offset );
			test( KErrNone == r );
			}
		test( iReadBuffer.Length() == readBufLen );

		TUint32* p = (TUint32*)iReadBuffer.Ptr();
		for( TInt i = 0; i < readBufLen; i += 4 )
			{
			if( aFillWord != *p )
				{
				failed = ETrue;
				test.Printf( _L("... FAILED: word @ offs=0x%x, read=0x%x, expected=0x%x\n"), 
								offset+i, p[0], aFillWord );
				break;
				}
			++p;
			}
		offset += readBufLen;
		len -= readBufLen;
		}
	
	return !failed;
	}
/**
This method is a receive notification of a processing instruction.
@param				aTarget is the processing instruction target.
@param				aData is the processing instruction data. If empty none was supplied.
@param				aErrorCode is the error code.
					If this is not KErrNone then special action may be required.
*/
void CTestHandler::OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, 
										  TInt aErrorCode)
{
	_LIT8(KOnProcInstFuncName,"OnProcessingInstruction()\r\n");
	_LIT8(KInfoOnEndEle,"\tProcessing instruction target: %S \t data: %S\r\n");
	_LIT8(KInfoOnError,"Error occurs %d \r\n");

	TBuf8<KShortInfoSize> info;
	
	iLog.Write(KOnProcInstFuncName);
	
	if (aErrorCode == KErrNone)
	{
		info.Format(KInfoOnEndEle,&aTarget,&aData);
		iLog.Write(info);
	}
	else
	{
		info.Format(KInfoOnError,aErrorCode);
		iLog.Write(info);
	}
}