Ejemplo n.º 1
0
void AddBrowseGroupRecord(CSdpDatabase& aDb, TUUID aBrowseUUID)
	{
	CSdpServRecord* theRec = aDb.NewRecordL();

	TBuf8<2> attrId;
	TBuf8<4> val;
	attrId.FillZ(2);
	val.FillZ(4);

	// Set Attr 1 (service class list) to list with One UUID = 0x1001
	attrId[0] = 0x00;
	attrId[1] = 0x01;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint16(KBrowseGroupDescriptorServiceClassUUID))) // BrowseGroup(DescriptorList)
		->EndListL();

	// Set Attr 0x005 (browse group list) to public root
	attrId[0] = 0x00;
	attrId[1] = 0x05;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint16(0x1002))) // publicBrowseRoot
		->EndListL();

	// Set Attr 0x200 (default Name) to string
	attrId[1] = 0x00;
	attrId[0] = 0x02;

	theRec->BuildUintL(attrId)->BuildUUIDL(aBrowseUUID);
	}
Ejemplo n.º 2
0
void AddBrowsableRecord(CSdpDatabase& aDb, TUUID aBrowseUUID)
	{
	CSdpServRecord* theRec = aDb.NewRecordL();

	TBuf8<2> attrId;
	TBuf8<4> val;
	attrId.FillZ(2);
	val.FillZ(4);

	// Set Attr 1 (service class list) to list with UUID = 0x1108
	attrId[0] = 0x00;
	attrId[1] = 0x01;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(0x1108))
		->EndListL();

	// Set Attr 0x005 (browse group list) to public root
	attrId[0] = 0x00;
	attrId[1] = 0x05;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(aBrowseUUID) // publicBrowseRoot
		->EndListL();
	}
Ejemplo n.º 3
0
TInt CSuspendTest::ZeroFillBlock( TInt aBlockNumber )
	//
	// Zero-fills and entire block
	// The requires that writing works
	//
	{
	test.Printf( _L("Zero-filling block %d\n"), aBlockNumber );

	//
	// Create a buffer full of zeros
	//
	const TInt KZeroBufSize = 512;

	TBuf8<KZeroBufSize> buf;
	buf.FillZ( buf.MaxLength() );

	//
	// Write the data out to the Flash
	//
	TInt writeCount = iBlockSize / KZeroBufSize;
	TInt r = KErrNone;
	TUint blockBaseOffset = aBlockNumber * iBlockSize;
	TInt pos = blockBaseOffset;
	for( ; (writeCount > 0) && (KErrNone == r); writeCount-- )
		{
		r = iDrive.Write( pos, buf );
		if( r != KErrNone )
			{
			test.Printf( _L("... FAIL: write failed (%d) at offset 0x%x\n"), pos );
			}
		pos += KZeroBufSize;
		}

	return r;
	}
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;
}
Ejemplo n.º 5
0
void TestRemovedMethods()
//
// Test deprecated but exported methods
//
	{
	test.Start(_L("Test removed methods of RNotifier class"));
	
	// connect to server
	RNotifier n;
	TInt r = n.Connect();
	test(r==KErrNone);

	test.Next(_L("StartNotifierAndGetResponse (5-params with dllUid)"));
	TBuf8<128> response;
	response.SetMax();
	response.FillZ();
	response.Zero();
	TRequestStatus stat;
	n.StartNotifierAndGetResponse(stat,KUidTestTextNotifier1,KUidTestTextNotifier2,*&KStartData,response);
	User::WaitForRequest(stat);
	test(stat==KErrNotSupported);

	test.Next(_L("StartNotifier (4-params with dllUid)"));
	test(n.StartNotifier(KUidTestTextNotifier2,KUidTestTextNotifier1,*&KStartData,response)==KErrNotSupported);
	
	test.Next(_L("Test removed method LoadNotifiers()"));
	test(n.LoadNotifiers(KUidTestTextNotifier1)==KErrNotSupported);
	
	test.Next(_L("Test removed method UnloadNotifiers()"));
	test(n.UnloadNotifiers(KUidTestTextNotifier1)==KErrNotSupported);

	test.Next(_L("Close connection to notifier server"));
	n.Close();
	test.End();
	}
EXPORT_C TMTPResponseCode MMTPServiceHandler::SaveServicePropValue(
	CRepository& aRepository, TUint aColumnNum, TMTPTypeGuid& aNewData)
	{
	TInt ret;
	TMTPResponseCode responseCode = EMTPRespCodeOK;
	TBuf8<KMTPTypeINT128Size>  data;
	data.FillZ(data.MaxLength());
	TUint64 upperValue = aNewData.UpperValue();
	TUint64 lowerValue = aNewData.LowerValue();

	/**
	Least significant 64-bit buffer offset.
	*/
	const TInt           KMTPTypeUint128OffsetLS = 0;
	/**
	Most significant 64-bit buffer offset.
	*/
	const TInt           KMTPTypeUint128OffsetMS = 8;

	memcpy(&data[KMTPTypeUint128OffsetMS], &upperValue, sizeof(upperValue));
	memcpy(&data[KMTPTypeUint128OffsetLS], &lowerValue, sizeof(lowerValue));

	ret = aRepository.Set(aColumnNum, data);
	if (KErrNone != ret)
		{
		responseCode = EMTPRespCodeGeneralError;
		}
	return responseCode;
	}
Ejemplo n.º 7
0
void DoMemoryLeakTests(TUid aUid,TBool aCheckMNotifierManager)
	{
	TInt r;
	TRequestStatus stat;

	test.Start(_L("Connect to notifier server"));
	RNotifier n;
	r = n.Connect();
	test(r==KErrNone);

	test.Next(_L("Get Notifier Server Heap Info"));
	static TBuf8<128> heapInfo1;
	heapInfo1.Zero();
	n.StartNotifierAndGetResponse(stat,aUid,KHeapData,heapInfo1);
	User::WaitForRequest(stat);
	n.CancelNotifier(aUid);
	TInt heapCellCount=stat.Int();
	test(heapCellCount>0);

	test.Next(_L("Repeated StartNotifierAndGetResponse"));
	for(TInt i=0; i<1000; i++)
		{
		TBuf8<128> response;
		response.SetMax();
		response.FillZ();
		response.Zero();
		n.StartNotifierAndGetResponse(stat,aUid,aCheckMNotifierManager?*&KMNotifierManager:*&KStartData,response);
		User::WaitForRequest(stat);
		n.CancelNotifier(aUid);
		test(stat==KErrNone);
		test(response==KResponseData);
		}

	test.Next(_L("Check Notifier Server Heap Info"));
	static TBuf8<128> heapInfo2;
	heapInfo2.Zero();
	n.StartNotifierAndGetResponse(stat,aUid,KHeapData,heapInfo2);
	User::WaitForRequest(stat);
	n.CancelNotifier(aUid);
	test(stat==heapCellCount);
	
	TInt size1, size2;
	TLex8 lex(heapInfo1);
	r = lex.Val(size1);
	test(r==KErrNone);
	lex.Assign(heapInfo2);
	r = lex.Val(size2);
	test(r==KErrNone);
	//allocated size after should not be greater than before BUT may be less with new allocator
	test(size2 <= size1); 

	test.Next(_L("Close connection to notifier server"));
	n.Close();

	test.End();
	}
Ejemplo n.º 8
0
static void CreateManyLargFiles(TInt aNumber)
//
// Make a directory with aNumber entries
//
{
    RFile64 f;
    TInt maxEntry=aNumber;

    test.Printf(_L("Create a directory with %d entries\n"),aNumber);

    TFileName sessionPath;
    TInt r=TheFs.SessionPath(sessionPath);
    test_KErrNone(r);
    r=TheFs.MkDir(_L("\\F32-TST\\"));
    test((r==KErrNone)||(r==KErrAlreadyExists));
    r=TheFs.MkDir(_L("\\F32-TST\\BENCH_DELETE\\"));
    test((r==KErrNone)||(r==KErrAlreadyExists));
    TBuf8<8> WriteData =_L8("Wibbleuy");
    for (TInt i=0; i<maxEntry; i++)
    {
        TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
        baseName.AppendNum(i);
        r=f.Replace(TheFs,baseName,EFileWrite);
        test_KErrNone(r);
        r = f.SetSize(K3GB);
        test_KErrNone(r);
        r=f.Write((K3GB-30),WriteData);
        test_KErrNone(r);
        f.Flush();
        f.Close();
    }

    test.Printf(_L("Test all entries have been created successfully\n"));
    TBuf8<8> ReadData;
    TInt64 Size=0;
    for (TInt j=0; j<=maxEntry; j++)
    {
        TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
        baseName.AppendNum(j);

        TInt r=f.Open(TheFs,baseName,EFileRead);
        if (r!=KErrNone)
        {
            test_Value(r, r == KErrNotFound && j==maxEntry);
            return;
        }
        ReadData.FillZ();
        r=f.Read((K3GB-30),ReadData);
        test_KErrNone(r);
        test(f.Size(Size)==KErrNone);
        test(K3GB == Size);
        test(ReadData==WriteData);
        f.Close();
    }
}
Ejemplo n.º 9
0
void DoCleanumpTests(TUid aUid,TBool aCheckMNotifierManager)
	{
	TInt r;

	test.Start(_L("Connect to notifier server"));
	RNotifier n;
	r = n.Connect();
	test(r==KErrNone);

	test.Next(_L("StartNotifierAndGetResponse"));
	TBuf8<128> response;
	response.SetMax();
	response.FillZ();
	response.Zero();
	TRequestStatus stat;
	n.StartNotifierAndGetResponse(stat,aUid,aCheckMNotifierManager?*&KMNotifierManager:*&KStartData,response);
	User::WaitForRequest(stat);
	test(stat==KErrNone);
	test(response==KResponseData);

	test.Next(_L("Close connection to notifier server"));
	n.Close();

	test.Next(_L("Connect to notifier server"));
	r = n.Connect();
	test(r==KErrNone);

	test.Next(_L("StartNotifierAndGetResponse (to check previous notifier was cancelled)"));
	response.SetMax();
	response.FillZ();
	response.Zero();
	n.StartNotifierAndGetResponse(stat,aUid,aCheckMNotifierManager?*&KMNotifierManagerWithCancelCheck:*&KStartWithCancelCheckData,response);
	User::WaitForRequest(stat);
	test(stat==KTestNotifierWasPreviouselyCanceled);
	test(response==KResponseData);

	test.Next(_L("Close connection to notifier server"));
	n.Close();

	test.End();
	}
Ejemplo n.º 10
0
TInt CFloggerTest017_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"); // the log file path

	_LIT8(KOOMError, "#Logs may be lost out of memory!!"); // Error message 

	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.FillZ();
	testData.Copy(KEightSpaces8); //Copy the test descriptor 
	returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
										 //from the file

	if (returnCode == KErrNotFound) // Check for the error message in the log
		{
		returnCode = ptrString.Find(KOOMError);
		if (returnCode > 0)
			User::Leave(KErrNoMemory);
		}
	
	CleanupStack::PopAndDestroy(hBuffer);
	CleanupStack::PopAndDestroy();	//theFile
	if (returnCode > 0)
		return KErrNone;
	else 
		return KErrGeneral;
	}
Ejemplo n.º 11
0
/**
@SYMTestCaseID          SYSLIB-LOGENG-LEGACY-T_LOGSERVIPC-0002
@SYMTestCaseDesc	    Tests Message schema validation for the messages accepting
 						TLogClientServerData parameters.
@SYMTestPriority 	    High
@SYMTestActions  	    Sends messages to the test server to test the validation of messages
						against the message schema.  The messages contain either valid or invalid 
						parameters. 
@SYMTestExpectedResults The server should validate the message and handle bad messages appropriately
@SYMDEF                	INC114113
*/
void TestCliServDataParam3L()
	{
	RClientMessageTestSession session;
	
	TInt err = session.Connect();
    TEST2(err, KErrNone);
	
	CleanupClosePushL(session);
	
	TBuf8<sizeof(TLogClientServerData) + 1> buf;
	
	buf.FillZ();
	
	err = session.TestCliServDataParam(ELogOperationInitiate,buf);	
	TEST2(err, KErrArgument);
	
	CleanupStack::PopAndDestroy(&session);
	}
Ejemplo n.º 12
0
/**
@SYMTestCaseID          SYSLIB-LOGENG-LEGACY-T_LOGSERVIPC-0001
@SYMTestCaseDesc	    Tests Message schema validation for the messages accepting
 						TLogClientServerData parameters.
@SYMTestPriority 	    High
@SYMTestActions  	    Sends messages to the test server to test the validation of messages
						against the message schema.  The messages contain either valid or invalid 
						parameters. 
@SYMTestExpectedResults The server should validate the message and handle bad messages appropriately
@SYMDEF                	INC114113
*/
void TestCliServDataParam2L()
	{
	RClientMessageTestSession session;
	
	TInt err = session.Connect();
    TEST2(err, KErrNone);
	
	CleanupClosePushL(session);
	
	TBuf8<sizeof(TLogClientServerData) - 1> buf;
	
	buf.FillZ();
	
	//This should panic with Logserv 63
	err = session.TestCliServDataParam(ELogOperationInitiate,buf);	
    TEST2(err, KErrNone);
	
	CleanupStack::PopAndDestroy(&session);
	}
Ejemplo n.º 13
0
void TScsiClientInquiryResp::DecodeL(const TDesC8& aPtr)
	{
    __MSFNSLOG
    __SCSIPRINT(_L("--> SCSI INQUIRY"));
    if (aPtr.Length() < KResponseLength)
        {
        // Handle short data.
        // The data not transferred is assumed to be zero.

        // Create zeroed buffer
        TBuf8<KResponseLength> buffer;
        buffer.FillZ(KResponseLength);

        // Copy data into buffer
        buffer = aPtr;
        buffer.SetLength(KResponseLength);

        DecodeInquiry(buffer);
        }
    else
        {
        DecodeInquiry(aPtr);
        }
	}
Ejemplo n.º 14
0
//Register it in the SDP database - determine attribs, construct the record and then add attribs to new record
TInt CStatTransportBT::RegWithSDPDatabaseL( void )
{
	asserte( iBTTransportStatus == EConnectingRegisterMgr );

	//Connect and open to the session and the DB
	//User::LeaveIfError( iSdpSession.Connect() );

     TInt ret2;
	 ret2 = iSdpSession.Connect();

     if(ret2!=KErrNone)
     {
         User::Leave(ret2);
     }

	User::LeaveIfError( iSdpDatabaseSession.Open( iSdpSession ) );
	TBuf8<STANDARDBUFVALUE> value1;

	TBuf8<STANDARDBUFVALUE> value2;
	CSdpAttrValue* attrVal = 0;
	CSdpAttrValueDES* attrValDES = 0;

	//initialise
	value1.FillZ(STANDARDBUFVALUE);
	value2.FillZ(STANDARDBUFVALUE);

	// Set Attr 1 (service class list) to list with UUID = 0x1101 (serial port)
	iSdpDatabaseSession.CreateServiceRecordL(TUUID(0x1101), iRecHandle);

	// Set Service name
	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdBasePrimaryLanguage + 
												 KSdpAttrIdOffsetServiceName, 
												 _L("STATAPI") ); 

	// Set Service description
	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdBasePrimaryLanguage + 
												 KSdpAttrIdOffsetServiceDescription, 
												 _L("Symbian Test Automation Tool using Serial BT") );

	attrVal = CSdpAttrValueString::NewStringL( _L8( "Test Solutions Dept Symbian Ltd." ) );
	CleanupStack::PushL(attrVal);
	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdBasePrimaryLanguage + 
													 KSdpAttrIdOffsetProviderName, *attrVal);
	CleanupStack::PopAndDestroy(); //attrVal
	attrVal = 0;

	// Set Attr 2 (service record state) to 0
	attrVal = CSdpAttrValueUint::NewUintL(value1);
	CleanupStack::PushL(attrVal);
	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdServiceRecordState, *attrVal);
	CleanupStack::PopAndDestroy(); //attrVal
	attrVal = 0;

	// Set attr 4 (protocol list) to RFCOMM
	//initialise
	TBuf8<1> serverChannel;
	serverChannel.FillZ(1);
	serverChannel[0] = (unsigned char)iPort;

	attrValDES = CSdpAttrValueDES::NewDESL(0);
	CleanupStack::PushL(attrValDES);
	
	attrValDES->StartListL()
			->BuildDESL()->StartListL()
				->BuildUUIDL( TUUID( TUint16( 0x0003 ) ) ) // RFCOMM
				->BuildUintL( serverChannel )	//Channel ID = 3 (listening port)
			->EndListL()
	->EndListL();

	//update attr 4
	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdProtocolDescriptorList, *attrValDES);
	CleanupStack::PopAndDestroy(); //attrValDES
	attrValDES = 0;

	// Set Attr 5 (browse group list) to list with one UUID
	// 0x1101 (serial port class)
	// this should be updated with other service classes when other services are added.
	attrValDES = CSdpAttrValueDES::NewDESL(0);
	CleanupStack::PushL(attrValDES);

	attrValDES->StartListL()
			->BuildUUIDL( TUUID( 0x1002 ) )
	->EndListL();
	
	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdBrowseGroupList, *attrValDES);
	CleanupStack::PopAndDestroy();
	attrValDES = 0;

	// Set Attr 0x006 (language base)
	value1.FillZ(4);
	value1[2] = 0x65;
	value1[3] = 0x6e;
	TBuf8<STANDARDBUFVALUE> val2;
	TBuf8<STANDARDBUFVALUE> val3;
	val2.FillZ(STANDARDBUFVALUE);
	val3.FillZ(STANDARDBUFVALUE);
	val2[3] = 0x6a;
	val3[2] = 0x01;

	attrValDES = CSdpAttrValueDES::NewDESL(0);
	CleanupStack::PushL(attrValDES);

	attrValDES->StartListL()
			->BuildUintL( value1 ) // speka de english
			->BuildUintL( val2 )   // UTF-8
			->BuildUintL( val3 )   // language base
	->EndListL();

	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdLanguageBaseAttributeIDList, *attrValDES);
	CleanupStack::PopAndDestroy();
	attrValDES = 0;

	// Set Attr 0x007 (time to live) to 600 (0x258) seconds (10 minutes)
	//initialise buffer
	value1.FillZ(4);
	value1[2]=2;
	value1[3]=0x58;

	attrVal = CSdpAttrValueUint::NewUintL( value1 );
	CleanupStack::PushL( attrVal );
	iSdpDatabaseSession.UpdateAttributeL( iRecHandle, KSdpAttrIdServiceInfoTimeToLive, *attrVal );
	CleanupStack::PopAndDestroy(); //attrVal 
	attrVal = 0;

	//Set Attr 0x08 (availability) to 0xff - fully available - not in use
	//initialise
	TBuf8<1> val4;
	val4.FillZ(1);
	val4[0]=0xff;
	
	attrVal = CSdpAttrValueUint::NewUintL(val4);
	CleanupStack::PushL(attrVal);
	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdServiceAvailability, *attrVal);
	CleanupStack::PopAndDestroy(); //attrVal 
	attrVal = 0;

	//Set Attr 0x201 (service database state) to 0
	//initialise
	value1.FillZ(4);
	
	attrVal = CSdpAttrValueUint::NewUintL(value1);
	CleanupStack::PushL(attrVal);
	iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdSdpServerServiceDatabaseState, *attrVal);
	CleanupStack::PopAndDestroy(); //attrVal
	attrVal = 0;

	return KSTErrSuccess;
}
Ejemplo n.º 15
0
CSdpDatabase* BuildPrequalDbL()
	{
	CSdpDatabase* theDb = CSdpDatabase::NewL();
	
	TInt i;
	TBuf8<2> attrId;
	TBuf8<4> val;
	TBuf8<2> val1;
	CSdpServRecord* theRec = theDb->NewRecordL();
// all attribute IDs are BIG ENDian 

// Prequal Dummy Service Record. Designed to respond to SA tests - 
// where, it seems, the initial service search is done using UUIDs 1101 and 0011.
// This record will have a value for each attribute so it
// can be used for the attribute queries.
	attrId.FillZ(2);
	val.FillZ(4);
	val1.FillZ(2);

	// Set Attr 1 (service class list) to list with UUID = 0x1108
	attrId[0] = 0x00;
	attrId[1] = 0x01;
	MSdpElementBuilder* bdr;
	bdr = theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(0x0011))
			->BuildUUIDL(TUUID(KDialUpNetworkingUUID));
	//TUint16 x = 0x1201;
	//while(x<0x120a)
	//	bdr->BuildUUIDL(TUUID(x++));
	bdr->EndListL();

	// Set Attr 2 (service record state) to 0.
	val.FillZ(4);
	attrId[0] = 0x00;
	attrId[1] = 0x02;
	val[0] = 0xdd;
	val[1] = 0xdd;
	val[2] = 0xdd;
	val[3] = 0xcd;
	theRec->BuildUintL(attrId)->BuildUintL(val);

	// Set attr 3 (service id) to 0x0001
	attrId[0] = 0x00;
	attrId[1] = 0x03;
	theRec->BuildUintL(attrId)
			->BuildUUIDL(TUUID(0xeeee));

	// Set attr 4 (protocol list) to L2CAP, RFCOMM (DLCI=1), no OBEX
	attrId[0] = 0x00;
	attrId[1] = 0x04;
	val1.FillZ(2);
	val1[1] = 1;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0001)))
			->EndListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP
			->EndListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0003))) // RFCOMM
				->BuildUintL(TSdpIntBuf<TUint8>(1)) // DLCI = 1
			->EndListL()
		->EndListL();
	
	// Set Attr 0x005 (browse group list) to public root
	attrId[0] = 0x00;
	attrId[1] = 0x05;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint16(0x1002))) // publicBrowseRoot
		->EndListL();

	// Set Attr 0x006 (language base)
	attrId[0] = 0x00;
	attrId[1] = 0x06;
	val.FillZ(2);
	//val.SetLength(2);
	val[0] = 0x65;
	val[1] = 0x6e;
	TBuf8<2> val2;
	TBuf8<2> val3;
	val2.FillZ(2);
	val3.FillZ(2);
	val2[1] = 0x6a;
	val3[0] = 0x01;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUintL(val) // english
			->BuildUintL(val2) // UTF-8
			->BuildUintL(val3) // language base
		->EndListL();


	// Set Attr 0x007 (service info time to live) to 0x0000 (not used).
	attrId[0] = 0x00;
	attrId[1] = 0x07;
	//val.SetLength(4);
	val.FillZ(4);
	val[0] = 0xcc;
	val[1] = 0xcc;
	val[2] = 0xcc;
	val[3] = 0xcc;

	theRec->BuildUintL(attrId)->BuildUintL(val);

	// Set Attr 0x008 (service availability) to 0xff (not currently in use).
	attrId[0] = 0x00;
	attrId[1] = 0x08;
	TBuf8<1> ff;
	ff.FillZ(1);
	ff[0] = 0xbb;	

	theRec->BuildUintL(attrId)->BuildUintL(ff);

	// Set Attr 0x009 (profile descriptor list) to Dun version 1.00
	attrId[0] = 0x00;
	attrId[1] = 0x09;
	val.FillZ(2);
	val[0] = 0x01;
	val[1] = 0x01;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(KSerialPortUUID))) 
				->BuildUintL(val)	// version 0x100
			->EndListL()
		->EndListL();

	// Set Attr 0x00a (Documentation URL) to "http://www.documentation.url/*".
	attrId[0] = 0x00;
	attrId[1] = 0x0a;

	theRec->BuildUintL(attrId)->BuildURLL(_L8("http://www.documentation.url"));

	// Set Attr 0x00b (Client Executable URL) to "http://url.i86-microsoft-win2000/".
	attrId[0] = 0x00;
	attrId[1] = 0x0b;

	theRec->BuildUintL(attrId)->BuildURLL(_L8("http://url.i86-microsoft-win2000/"));

	// Set Attr 0x00c (ICON URL) to "http://url.32x32x8.png/icon".
	attrId[0] = 0x00;
	attrId[1] = 0x0c;

	theRec->BuildUintL(attrId)->BuildURLL(_L8("http://url.32x32x8.png/icon"));
	//theRec->BuildUintL(attrId)->BuildStringL(_L8("http://url.32x32x8.png/icon/"));
		
	// Set Attr 0x100 (service Name) to string
	//BuildContinuationString(theRec, 0x100, 0x200);
	attrId[0] = 0x01;
	attrId[1] = 0x00;
	theRec->BuildUintL(attrId)->BuildStringL(_L8("Indigo_Chat_Security_Mode_1"));

	// Set Attr 0x101 (service description) to string
	attrId[0] = 0x01;
	attrId[1] = 0x01;
	theRec->BuildUintL(attrId)->BuildStringL(_L8("ServiceDescriptionAttributeValue"));
		// Set Attr 0x102 (provider name) to string
	attrId[0] = 0x01;
	attrId[1] = 0x02;
	theRec->BuildUintL(attrId)->BuildStringL(_L8("ServiceProviderAttributeValue"));

	// Set attr 0x200 (version number list) to version 1.1
	attrId[0]=0x02;
	attrId[1]=0x00;
	val1.FillZ(2);
	val1[0]=0x01;
	val1[1]=0x01;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUintL(val1)
		->EndListL();


	//Set Attr 0x201 (Service database state) to 0
	attrId[0]=0x02;
	attrId[1]=0x01;
	val.FillZ(4);
	val[3] = 0x0e;
	theRec->BuildUintL(attrId)->BuildUintL(val);

// Second Record Fax
	theRec = theDb->NewRecordL();

	attrId.FillZ(2);
	val.FillZ(4);

	// Set Attr 1 (service class list) to list with Two UUID = 0x1111, 0x1204
	attrId[0] = 0x00;
	attrId[1] = 0x01;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(KFaxUUID)) 
			->BuildUUIDL(TUUID(KGenericTelephonyUUID)) 
		->EndListL();


	// Set attr 4 (protocol list) to L2CAP, RFCOMM (DLCI=2), no OBEX
	attrId[0] = 0x00;
	attrId[1] = 0x04;
	val.FillZ(4);
	val[3] = 2;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP
			->EndListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0003))) // RFCOMM
				->BuildUintL(val)	// DLCI = 2
			->EndListL()
		->EndListL();

	// Set Attr 0x005 (browse group list) to public root
	attrId[0] = 0x00;
	attrId[1] = 0x05;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint16(0x1002))) // publicBrowseRoot
		->EndListL();

	// Set Attr 0x006 (language base)
	attrId[0] = 0x00;
	attrId[1] = 0x06;
	val.FillZ(2);
	val[0] = 0x65;
	val[1] = 0x6e;
	val2.FillZ(2);
	val3.FillZ(2);
	val2[1] = 0x6a;
	val3[0] = 0x01;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUintL(val) // english
			->BuildUintL(val2) // UTF-8
			->BuildUintL(val3) // language base
		->EndListL();

	// Set Attr 0x009 (profile descriptor list) to Dun version 1.00
	attrId[0] = 0x00;
	attrId[1] = 0x09;
	val.FillZ(2);
	val[0] = 0x01;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(KFaxUUID))) // Fax
				->BuildUintL(val)	// version 0x100
			->EndListL()
		->EndListL();

	// Set Attr 0x00a (Documentation URL) to a very long value, for use with continuation
	attrId[0] = 0x00;
	attrId[1] = 0x0a;

	TBuf8<654> urlBuf;
	urlBuf.Append(_L8("http://"));
	for(TInt r = 0; r < 160; r ++)
	{
		urlBuf.Append(_L8("url/"));
	}
	urlBuf.Append(_L8("url.doc"));
	theRec->BuildUintL(attrId)->BuildURLL(urlBuf);


	// Set Attr 0x100 (default Name) to string
	attrId[1] = 0x00;
	attrId[0] = 0x01;
	theRec->BuildUintL(attrId)->BuildStringL(_L8("Fax"));
	
// Third Record Obex
	theRec = theDb->NewRecordL();

	attrId.FillZ(2);
	val.FillZ(4);

	// Set Attr 1 (service class list) to list with One UUID = 0x1105
	attrId[0] = 0x00;
	attrId[1] = 0x01;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint16(KObexUUID))) // Obex
		->EndListL();

	// Set attr 4 (protocol list) to L2CAP, RFCOMM (DLCI=3), OBEX
	attrId[0] = 0x00;
	attrId[1] = 0x04;
	val.FillZ(4);
	val[3] = 3;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP
			->EndListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0003))) // RFCOMM
				->BuildUintL(val)	// DLCI = 3
			->EndListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0008))) // Obex
			->EndListL()
		->EndListL();

	// Set Attr 0x005 (browse group list) to public root
	attrId[0] = 0x00;
	attrId[1] = 0x05;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint16(0x1002))) // publicBrowseRoot
		->EndListL();

	// Set Attr 0x006 (language base)
	attrId[0] = 0x00;
	attrId[1] = 0x06;
	val.FillZ(2);
	val[0] = 0x65;
	val[1] = 0x6e;
	val2.FillZ(2);
	val3.FillZ(2);
	val2[1] = 0x6a;
	val3[0] = 0x01;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUintL(val) // english
			->BuildUintL(val2) // UTF-8
			->BuildUintL(val3) // language base
		->EndListL();

	// Set Attr 0x009 (profile descriptor list) to Obex version 1.00
	attrId[0] = 0x00;
	attrId[1] = 0x09;
	val.FillZ(4);
	val[0] = 0x01;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(KObexUUID))) // Obex
				->BuildUintL(val)	// version 0x100
			->EndListL()
		->EndListL();

	// Set Attr 0x100 (default Name) to string
	attrId[1] = 0x00;
	attrId[0] = 0x01;
	theRec->BuildUintL(attrId)->BuildStringL(_L8("OBEX Objext Push"));


	// Now add browse test stuff
	//
	AddBrowseGroupRecord(*theDb, TUUID(0xbbcb));
	AddBrowseGroupRecord(*theDb, TUUID(0xbbdb));
	AddBrowseGroupRecord(*theDb, TUUID(0xbbeb));
	AddBrowseGroupRecord(*theDb, TUUID(0xbbfb));
	AddBrowseGroupRecord(*theDb, TUUID(0xccec));
	AddBrowseGroupRecord(*theDb, TUUID(0xccfc));
	AddBrowseGroupRecord(*theDb, TUUID(0xaaba));
	AddBrowseGroupRecord(*theDb, TUUID(0xaaca));

	AddBrowsableRecord(*theDb, TUUID(0xbbcb));
	AddBrowsableRecord(*theDb, TUUID(0xbbdb));
	AddBrowsableRecord(*theDb, TUUID(0xbbeb));
	AddBrowsableRecord(*theDb, TUUID(0xbbfb));
	AddBrowsableRecord(*theDb, TUUID(0xccec));
	AddBrowsableRecord(*theDb, TUUID(0xccfc));
	AddBrowsableRecord(*theDb, TUUID(0xaaba));
	AddBrowsableRecord(*theDb, TUUID(0xaaca));



	// Now add a load more records to force continuation for the service search
	//
	for(i = 0; i < 165; i ++)
	{
		theRec = theDb->NewRecordL();

		attrId.FillZ(2);
		val.FillZ(4);

		// Set Attr 1 (service class list) to list with UUID = 0x1108
		attrId[0] = 0x00;
		attrId[1] = 0x01;
		theRec->BuildUintL(attrId)->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(0x1101))
			->EndListL();
	}
	return theDb;
	}
Ejemplo n.º 16
0
void DoTests(TUid aUid,TBool aCheckMNotifierManager)
	{	
	TInt r;
	
	test.Start(_L("Connect to notifier server"));
	RNotifier n;
	r = n.Connect();
	test(r==KErrNone);

	test.Next(_L("StartNotifier (without response)"));
	r = n.StartNotifier(aUid,aCheckMNotifierManager?*&KMNotifierManager:*&KStartData);
	RDebug::Printf("r=%d", r);
	test(r==KErrNone);

	test.Next(_L("CancelNotifier"));
	r = n.CancelNotifier(aUid);
	test(r==KErrNone);

	test.Next(_L("StartNotifier"));
	TBuf8<128> response;
	response.SetMax();
	response.FillZ();
	response.Zero();
	r = n.StartNotifier(aUid,aCheckMNotifierManager?*&KMNotifierManager:*&KStartData,response);
	test(r==KErrNone);
	test(response==KResponseData);

	test.Next(_L("UpdateNotifier"));
	response.SetMax();
	response.FillZ();
	response.Zero();   // EKA1 text notifier dies if current length < length of response
	r = n.UpdateNotifier(aUid,aCheckMNotifierManager?*&KMNotifierManager:*&KUpdateData,response);
	test(r==KErrNone);
	test(response==KResponseData);

	test.Next(_L("UpdateNotifierAndGetResponse"));
	response.SetMax();
	response.FillZ();
	response.Zero();   // EKA1 text notifier dies if current length < length of response
	TRequestStatus updateStat;
	n.UpdateNotifierAndGetResponse(updateStat,aUid,aCheckMNotifierManager?*&KMNotifierManager:*&KUpdateData,response);
	User::WaitForRequest(updateStat);
	test(updateStat==KErrNone);
	test(response==KResponseData);
	
	test.Next(_L("CancelNotifier"));
	r = n.CancelNotifier(aUid);
	test(r==KErrNone);

	test.Next(_L("StartNotifierAndGetResponse (to check previous notifier was cancelled)"));
	response.SetMax();
	response.FillZ();
	response.Zero();
	TRequestStatus stat;
	n.StartNotifierAndGetResponse(stat,aUid,aCheckMNotifierManager?*&KMNotifierManagerWithCancelCheck:*&KStartWithCancelCheckData,response);
	User::WaitForRequest(stat);
	test(stat==KTestNotifierWasPreviouselyCanceled);
	test(response==KResponseData);

	test.Next(_L("CancelNotifier"));
	r = n.CancelNotifier(aUid);
	test(r==KErrNone);

	test.Next(_L("Close connection to notifier server"));
	n.Close();

	test.Next(_L("Memory leak tests"));
	DoMemoryLeakTests(aUid,aCheckMNotifierManager);

	test.Next(_L("Session cleanup test"));
	DoCleanumpTests(aUid,aCheckMNotifierManager);

	test.End();
	}
enum TVerdict CTestStepNullAgtLoopbackTest::doTestStepL(void)
{
    __UHEAP_MARK;

    TInt r;                // the result of various operations
    TRequestStatus status; // status of asynchronous ops

    RSocketServ server;    // connection paraphanelia
    RConnection connection;
    RSocket socket;

    TInetAddr dest;
    dest.SetAddress(KDummyNifLocalAddressBase + 4);
    dest.SetPort(KPortNo);

    TBuf8<KBufferLength> buffer;

    // connect to the socket server
    r = server.Connect();
    TESTEL(r == KErrNone, r);
    CleanupClosePushL(server);

    // this is why we needed a socket server...
    r = connection.Open(server, KAfInet);
    TESTEL(r == KErrNone, r);
    CleanupClosePushL(connection);

    // start the connection up (outgoing)
    connection.Start(status);
    User::WaitForRequest(status);
    TESTEL(status.Int() == KErrNone, status.Int());

    // open a udp socket
    r = socket.Open(server, KAfInet, KSockDatagram, KProtocolInetUdp);
    TESTEL(r == KErrNone, r);
    CleanupClosePushL(socket);
    TESTL(socket.SetOpt(KSoReuseAddr, KSolInetIp, 1)==KErrNone);
    // set the source port number - otherwise will panic cos it's zero
    r = socket.SetLocalPort(KPortNo);
    TESTEL(r == KErrNone, r);

    // build some data to send on the socket
    // this is an ICMP ping request apparently
    buffer.SetMax();
    buffer.FillZ();
    buffer[0] = (TUint8) 0x8;		// ICMP type = 8
    buffer[1] = (TUint8) 0x0;		// ICMP code = 0
    buffer[2] = (TUint8) 0xF7;		// ICMP checksum high byte
    buffer[3] = (TUint8) 0xFF;		// ICMP checksum low byte
    // NB the rest of the buffer is zero
    // hence the checksum (0xFFFF - 0x800) since 0x8
    // is the only non-zero element of the buffer

    // send the data out over the socket
    socket.SendTo(buffer, dest, 0, status);
    User::WaitForRequest(status);
    TESTEL(status.Int() == KErrNone, status.Int());

    buffer.Zero();
    // I expect to get the data looped back from the dummy NIF
    socket.RecvFrom(buffer, dest, 0, status);
    User::WaitForRequest(status);
    TESTEL(status.Int() == KErrNone, status.Int());

    // check that what we sent is what we got back
    if (status.Int() == KErrNone)
    {
        // if the receive times out and we access buffer we get a panic
        TEST(buffer[0] == 0x08);
        TEST(buffer[1] == 0x00);
        TEST(buffer[2] == 0xF7);
        TEST(buffer[3] == 0xFF);
    }

    // close the socket
    socket.Shutdown(RSocket::ENormal, status);
    User::WaitForRequest(status);
    TESTEL(status.Int() == KErrNone, status.Int());
    CleanupStack::Pop();

    // force the destruction of the connection
    r = connection.Stop();
    TESTEL(r == KErrNone, r);
    CleanupStack::Pop();

    // close the socket server
    server.Close();
    CleanupStack::Pop();

    __UHEAP_MARKEND;

    return iTestStepResult;
}
/**
  ExecuteActionL
  Parse the Email file and creates an email in the specified local folder.  Creates
  simple emails, emails with HTML, attachments, multipart and embedded emails.
  @internalTechnology 
  @pre    None
  @post   None
  @leave  System wide errors
*/
void CMtfTestActionCreateSmtpMessageFromEmailFile::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCreateSmtpMessageFromEmailFile);
	CMsvSession* paramSession	= ObtainParameterReferenceL<CMsvSession>(TestCase(),
									ActionParameters().Parameter(0));
								 
	TMsvId paramServiceId 		= ObtainValueParameterL<TMsvId>(TestCase(),
									ActionParameters().Parameter(1));
								 
	TMsvId paramFolderId 		= ObtainValueParameterL<TMsvId>(TestCase(),
								    ActionParameters().Parameter(2));
								 
	TInt paramConfigIndexMailFile = ObtainValueParameterL<TInt>(TestCase(),
								 ActionParameters().Parameter(3),0);
	
	TInt overrideAddress=0;
	if(ActionParameters().Count()>5)
		{
		overrideAddress=ObtainValueParameterL<TInt>(TestCase(),
								 ActionParameters().Parameter(5));		
		}

	TPtrC fileName = TestCase().GetConfigurationFileL(CMtfConfigurationType::EMtfEmailFile,
														paramConfigIndexMailFile);

	/************************************************************************************
	Get the name of the Email file save at the Configuration file index, open the  file, 
	read one line of text from the file, parse the line and set the fields of the email 
	message based on the contents of the parsed line.
	************************************************************************************/
	
	// Set the context ot the folder in which emails have to be created
	CMsvEntry* entry = CMsvEntry::NewL(*paramSession,paramFolderId,TMsvSelectionOrdering());
	CleanupStack::PushL(entry);
	entry->SetEntryL(paramFolderId);

	RFs fs;
	fs.Connect();

	CImCltRecvConvert* recvConvert = CImCltRecvConvert::NewLC(fs,entry,KUidMsgTypeSMTP,
															   paramServiceId);
	recvConvert->SetMsvId(paramFolderId);

	// Open the Email file
	RFile file;
	User::LeaveIfError(file.Open(fs,fileName,EFileRead));

	TestCase().INFO_PRINTF2(_L("Email Data file: %S"), &fileName);
	
	TBuf8<KMaxLenghtOfLine> line;
	TBuf8<1> aChar;				// To read one character from the file
	TBool finished = FALSE;

	recvConvert->ResetL();

	// Parse each line from the 

	do {
		line.FillZ();
		line.SetLength(0);
		// Read one line from email file
		do {
			file.Read(aChar, 1);
			if(aChar.Length())
				{
				line.Append(aChar);
				}
			else
				{
				finished = TRUE;
				}
			} while(aChar.Length() && aChar[0] != 0x0A);
			
			if(!line.Length())
				{
				break;
				}
			// Parse the line for the fields of the email and store them
			recvConvert->ParseNextFieldL(line);
		} while(!finished);


	/****************************************************************************
	 Complete the message creation by setting all the required fields and 
	 storing the email on to the message store.
	 The created email's ID is returned by MessageCompelteL function
	****************************************************************************/
	TMsvId paramMessageId;
	paramMessageId = recvConvert->MessageCompleteL();

	if(paramMessageId == 0)
		{
		User::Leave(KErrUnknown);
		}

	file.Close();
	CleanupStack::PopAndDestroy(recvConvert);
	
	if(overrideAddress)
		{
#ifndef __MESSAGING_API_V2__		
		entry->SetEntryL(paramServiceId);
		CMsvStore* store=entry->ReadStoreL();
		CleanupStack::PushL(store);
#endif		
		CImSmtpSettings* settings= new(ELeave) CImSmtpSettings();
		CleanupStack::PushL(settings);
#ifdef __MESSAGING_API_V2__
 		CEmailAccounts* accounts = CEmailAccounts::NewLC();
 		TSmtpAccount smtpAccount;
 		accounts->GetSmtpAccountL(paramServiceId, smtpAccount);
		accounts->LoadSmtpSettingsL(smtpAccount, *settings);
		CleanupStack::PopAndDestroy();
#else		
		settings->RestoreL(*store);
		CleanupStack::PopAndDestroy();
#endif		
		HBufC* emailAddress=settings->EmailAddress().AllocL();
		CleanupStack::PopAndDestroy();
		CleanupStack::PushL(emailAddress);
		entry->SetEntryL(paramMessageId);
#ifdef __MESSAGING_API_V2__
		CMsvStore* store=entry->EditStoreL();
#else
		
		store=entry->EditStoreL();
#endif
		CleanupStack::PushL(store);
		
		CImHeader* header= CImHeader::NewLC();
		header->RestoreL(*store);
		
		header->ToRecipients().Reset();
		header->ToRecipients().AppendL(*emailAddress);
		
		header->StoreL(*store);
		store->CommitL();
		
		CleanupStack::PopAndDestroy(3,emailAddress);
		}
	
	CleanupStack::PopAndDestroy(entry);

	TestCase().INFO_PRINTF2(_L("Created a email from file %S"),&fileName);

	StoreParameterL<TMsvId>(TestCase(),paramMessageId,ActionParameters().Parameter(4));
	fs.Close();
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCreateSmtpMessageFromEmailFile);
	TestCase().ActionCompletedL(*this);
	}
// -----------------------------------------------------------------------------
// CWimJavaProvisioning::InitializePathsAndSizes
// Initializes the path and size data members
// -----------------------------------------------------------------------------
//
void CWimJavaProvisioning::InitializePathsAndSizes()
    {
    _WIMTRACE(_L("WIM | WIMServer | CWimJavaProvisioning::InitializePathsAndSizesL | Begin"));

    // Do initialization only if initialization is not done
    if ( !iFileInfosInitialized )
        {
        TUint16 callStatus = KErrNone;

        TBuf8<KWimProvACIFFileOidLength> ACIFOid;
        
        ACIFOid.Copy( KWimProvACIFFileOID, KWimProvACIFFileOidLength );

        TBuf8<KWimProvACIFFileOidLengthTaged> ACIFOidTaged;

        ACIFOidTaged.Copy( KWimProvACIFFileOIDTaged,
                                KWimProvACIFFileOidLengthTaged );
        
        WIMI_BinData_t path;
        path.pb_buf = NULL;
        path.ui_buf_length = 0;

        WIMI_File_Info* fileInfos = NULL;

        TUint16 fileCount = 0;

        WIMI_BinData_t fileOid;
        fileOid.pb_buf = NULL;
        fileOid.ui_buf_length = 0;

        // Get WIM reference, reader is always 0
        if ( iWimRef )
            {
            free_WIMI_Ref_t( iWimRef );
            iWimRef = NULL;
            }
        iWimRef = WIMI_GetWIMRef( 0 );

        if ( !iWimRef )
            {
            callStatus = WIMI_ERR_BadReference;
            }
    
        if ( callStatus == KErrNone )
            {

            // Get Java file info from Wimlib
            callStatus = WIMI_JAVAFileInfo( iWimRef,
                                           &fileInfos,
                                           &fileCount );
            }

        if ( callStatus == KErrNone )
            {
            TBuf8<KWimJavaOidLengthTaged> oidBuf; // Buffer for OID

            // Loop all file infos and safe path to each file
            for ( TInt i = 0; i < fileCount; i++ )
                {
                // Get file OID from infos
                fileOid.pb_buf = fileInfos[i].t_oid.pb_buf;
                fileOid.ui_buf_length = fileInfos[i].t_oid.ui_buf_length;
                oidBuf.FillZ();
                oidBuf.Copy( fileOid.pb_buf, fileOid.ui_buf_length );

                // File path
                path.pb_buf = fileInfos[i].b_path.pb_buf;
                path.ui_buf_length = fileInfos[i].b_path.ui_buf_length;

                // Compare OIDs
                if ( !oidBuf.Compare( ACIFOid ) 
                    || !oidBuf.Compare( ACIFOidTaged ) ) // ACIF File
                    {
                    // Copy file path to member
                    iPathACIF.Copy( path.pb_buf, path.ui_buf_length );
                    
                    // Set file size
                    iACIFFileSize = fileInfos[i].ui_file_size;

                    // Check if path is given but size not. If path exists and
                    // size == 0 then parse size from fetched file
                    if ( iPathACIF.Length() > 0 &&
                         iACIFFileSize == 0 )
                        {
                        WIMI_BinData_t pt_path;

                        WIMI_BinData_t fileContent;
                        
                        pt_path.ui_buf_length = ( TUint16 )iPathACIF.Length();
                        pt_path.pb_buf = ( TUint8* )iPathACIF.Ptr();
        
                        fileContent.pb_buf = NULL;
                        fileContent.ui_buf_length = 0;
    
                        //Get ACIF file
                        WIMI_STAT callStatus = WIMI_GetJAVAFile(iWimRef,
                                                                 &pt_path,      
                                                                 &fileContent );
                       iACIFFileSize = fileContent.ui_buf_length;
                       }
                    }
                
                }
            }
        iFileInfosInitialized = ETrue;
        }
    }
Ejemplo n.º 20
0
CSdpDatabase* BuildTBTDbL()
	{
	CSdpDatabase* theDb = CSdpDatabase::NewL();
	
	TBuf8<2> attrId;
	TBuf8<4> val;
	TBuf8<2> val1;
	CSdpServRecord* theRec = CSdpServRecord::NewL();
// all attribute IDs are BIG ENDian 

// First Record DUN service. This record will have a value for each attribute so it
// can be used for the attribute queries.

	attrId.FillZ(2);
	val.FillZ(4);
	val1.FillZ(2);
	// Set Attr 0 (Record handle) to 0x00010000
	val[0] = 0x00;
	val[1] = 0x01;
	val[2] = 0x00;
	val[3] = 0x00;
	theRec->BuildUintL(attrId)->BuildUintL(val);

	// Set Attr 1 (service class list) to list with Three UUIDs = 0x1103, 0x1201 and 0x1000.
	attrId[0] = 0x00;
	attrId[1] = 0x01;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(KDialUpNetworkingUUID))
			->BuildUUIDL(TUUID(KGenericNetworkingUUID)) 
			->BuildUUIDL(TUUID(KServiceDiscoveryServerServiceClassUUID))
		->EndListL();

	// Set Attr 2 (service record state) to 0.
	val.FillZ(4);
	attrId[0] = 0x00;
	attrId[1] = 0x02;
	theRec->BuildUintL(attrId)->BuildUintL(val);

	// Set attr 3 (service id) to 0x0001
	attrId[0] = 0x00;
	attrId[1] = 0x03;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(0x0001))
		->EndListL();

	// Set attr 4 (protocol list) to L2CAP, RFCOMM (DLCI=1), no OBEX
	attrId[0] = 0x00;
	attrId[1] = 0x04;
	val1.FillZ(2);
	val1[1] = 1;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP
			->EndListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0003))) // RFCOMM
				->BuildUintL(val1)	// DLCI = 1
			->EndListL()
		->EndListL();

	// Set Attr 0x005 (browse group list) to public root
	attrId[0] = 0x00;
	attrId[1] = 0x05;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint16(0x1002))) // publicBrowseRoot
		->EndListL();

	// Set Attr 0x006 (language base)
	attrId[0] = 0x00;
	attrId[1] = 0x06;
	val.FillZ(2);
	val[0] = 0x65;
	val[1] = 0x6e;
	TBuf8<2> val2;
	TBuf8<2> val3;
	val2.FillZ(2);
	val3.FillZ(2);
	val2[1] = 0x6a;
	val3[0] = 0x01;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUintL(val) // english
			->BuildUintL(val2) // UTF-8
			->BuildUintL(val3) // language base
		->EndListL();


	// Set Attr 0x007 (service info time to live) to 0x0000 (not used).
	attrId[0] = 0x00;
	attrId[1] = 0x07;
	val.FillZ(4);

	theRec->BuildUintL(attrId)->BuildUintL(val);

	// Set Attr 0x008 (service availability) to 0xff (not currently in use).
	attrId[0] = 0x00;
	attrId[1] = 0x08;
	TBuf8<1> ff;
	ff.FillZ(1);
	ff[0] = 0xff;	

	theRec->BuildUintL(attrId)->BuildUintL(ff);

	// Set Attr 0x009 (profile descriptor list) to Dun version 1.00
	attrId[0] = 0x00;
	attrId[1] = 0x09;

	val.FillZ(2);
	val[0] = 0x01;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(KDialUpNetworkingUUID))) 
				->BuildUintL(val)	// version 0x100
			->EndListL()
		->EndListL();

	// Set Attr 0x00a (Documentation URL) to "http://my.fake/public/documentation/*".
	attrId[0] = 0x00;
	attrId[1] = 0x0a;

	theRec->BuildUintL(attrId)->BuildURLL(_L8("http://my.fake/public/documentation.doc"));

	// Set Attr 0x00b (Client Executable URL) to "http://my.fake/public/*/client.exe".
	attrId[0] = 0x00;
	attrId[1] = 0x0b;

	theRec->BuildUintL(attrId)->BuildURLL(_L8("http://my.fake/public/*/client.exe"));

	// Set Attr 0x00c (ICON URL) to "http://my.fake/public/icons/*".
	attrId[0] = 0x00;
	attrId[1] = 0x0c;

	theRec->BuildUintL(attrId)->BuildURLL(_L8("http://my.fake/public/icons/*"));
		
	// Set Attr 0x100 (service Name) to string
	attrId[0] = 0x01;
	attrId[1] = 0x00;
	theRec->BuildUintL(attrId)->BuildStringL(_L8("Dial-up networking"));

	// Set Attr 0x101 (service description) to string
	attrId[0] = 0x01;
	attrId[1] = 0x01;
	theRec->BuildUintL(attrId)->BuildStringL(_L8("Dummy description for dial-up-networking"));

	// Set Attr 0x102 (provider name) to string
	attrId[0] = 0x01;
	attrId[1] = 0x02;
	theRec->BuildUintL(attrId)->BuildStringL(_L8("PAN team"));

	// Set attr 0x200 (version number list) to version 1.1
	attrId[0]=0x02;
	attrId[1]=0x00;
	val1.FillZ(2);
	val1[0]=0x01;
	val1[1]=0x01;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUintL(val1)
		->EndListL();


	//Set Attr 0x201 (Service database state) to 0
	attrId[0]=0x02;
	attrId[1]=0x01;
	val.FillZ(4);
	theRec->BuildUintL(attrId)->BuildUintL(val);

	// Add the record into the database
	theDb->AddRecord(theRec);

// Second Record Fax
	theRec = CSdpServRecord::NewL();

	attrId.FillZ(2);
	val.FillZ(4);
	// Set Attr 0 (Record handle) to 0x00010001
	val[0] = 0x00;
	val[1] = 0x01;
	val[2] = 0x00;
	val[3] = 0x01;
	theRec->BuildUintL(attrId)->BuildUintL(val);

	// Set Attr 1 (service class list) to list with Two UUID = 0x1111, 0x1204
	attrId[0] = 0x00;
	attrId[1] = 0x01;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(KFaxUUID)) 
			->BuildUUIDL(TUUID(KGenericTelephonyUUID)) 
		->EndListL();


	// Set attr 4 (protocol list) to L2CAP, RFCOMM (DLCI=2), no OBEX
	attrId[0] = 0x00;
	attrId[1] = 0x04;
	val.FillZ(4);
	val[3] = 2;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP
			->EndListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0003))) // RFCOMM
				->BuildUintL(val)	// DLCI = 2
			->EndListL()
		->EndListL();

	// Set Attr 0x005 (browse group list) to public root
	attrId[0] = 0x00;
	attrId[1] = 0x05;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint16(0x1002))) // publicBrowseRoot
		->EndListL();

	// Set Attr 0x006 (language base)
	attrId[0] = 0x00;
	attrId[1] = 0x06;
	val.FillZ(2);
	val[0] = 0x65;
	val[1] = 0x6e;
	val2.FillZ(2);
	val3.FillZ(2);
	val2[1] = 0x6a;
	val3[0] = 0x01;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUintL(val) // english
			->BuildUintL(val2) // UTF-8
			->BuildUintL(val3) // language base
		->EndListL();

	// Set Attr 0x009 (profile descriptor list) to Dun version 1.00
	attrId[0] = 0x00;
	attrId[1] = 0x09;

	val.FillZ(2);
	val[0] = 0x01;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(KFaxUUID))) // Fax
				->BuildUintL(val)	// version 0x100
			->EndListL()
		->EndListL();

	// Set Attr 0x00a (Documentation URL) to a very long value, for use with continuation
	attrId[0] = 0x00;
	attrId[1] = 0x0a;

	TBuf8<654> urlBuf;
	urlBuf.Append(_L8("http://"));
	for(TInt r = 0; r < 160; r ++)
	{
		urlBuf.Append(_L8("url/"));
	}	
	urlBuf.Append(_L8("url.doc"));
	theRec->BuildUintL(attrId)->BuildURLL(urlBuf);


	// Set Attr 0x100 (default Name) to string
	attrId[1] = 0x00;
	attrId[0] = 0x01;
	theRec->BuildUintL(attrId)->BuildStringL(_L8("Fax"));
	
	// Add the record into the database
	theDb->AddRecord(theRec);

// Third Record Obex
	theRec = CSdpServRecord::NewL();

	attrId.FillZ(2);
	val.FillZ(4);
	// Set Attr 0 (Record handle) to 0x00010001
	val[0] = 0x00;
	val[1] = 0x01;
	val[2] = 0x00;
	val[3] = 0x02;
	theRec->BuildUintL(attrId)->BuildUintL(val);

	// Set Attr 1 (service class list) to list with One UUID = 0x1105
	attrId[0] = 0x00;
	attrId[1] = 0x01;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint16(KObexUUID))) // Obex
		->EndListL();

	// Set attr 4 (protocol list) to L2CAP, RFCOMM (DLCI=3), OBEX
	attrId[0] = 0x00;
	attrId[1] = 0x04;
	val.FillZ(4);
	val[3] = 3;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP
			->EndListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0003))) // RFCOMM
				->BuildUintL(val)	// DLCI = 3
			->EndListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0008))) // Obex
			->EndListL()
		->EndListL();

	// Set Attr 0x005 (browse group list) to public root
	attrId[0] = 0x00;
	attrId[1] = 0x05;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint16(0x1002))) // publicBrowseRoot
		->EndListL();

	// Set Attr 0x006 (language base)
	attrId[0] = 0x00;
	attrId[1] = 0x06;
	val.FillZ(2);
	val[0] = 0x65;
	val[1] = 0x6e;
	val2.FillZ(2);
	val3.FillZ(2);
	val2[1] = 0x6a;
	val3[0] = 0x01;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUintL(val) // english
			->BuildUintL(val2) // UTF-8
			->BuildUintL(val3) // language base
		->EndListL();

	// Set Attr 0x009 (profile descriptor list) to Obex version 1.00
	attrId[0] = 0x00;
	attrId[1] = 0x09;

	val.FillZ(2);
	val[0] = 0x01;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(KObexUUID))) // Obex
				->BuildUintL(val)	// version 0x100
			->EndListL()
		->EndListL();

	// Set Attr 0x100 (default Name) to string
	attrId[1] = 0x00;
	attrId[0] = 0x01;
	theRec->BuildUintL(attrId)->BuildStringL(_L8("OBEX Objext Push"));
	
	// Add the record into the database
	theDb->AddRecord(theRec);

	// Now add a load more records to force continuation for the service search
	//
	for(TUint8 i = 0; i < 200; i ++)
	{
		theRec = CSdpServRecord::NewL();

		attrId.FillZ(2);
		val.FillZ(4);
		// Set Attr 0 (Record handle) to 0x00010003
		val[0] = 0x00;
		val[1] = 0x01;
		val[2] = 0x00;
		val[3] = TUint8(i+3);
		theRec->BuildUintL(attrId)->BuildUintL(val);
		// Set Attr 1 (service class list) to list with UUID = 0x1108
		attrId[0] = 0x00;
		attrId[1] = 0x01;
		theRec->BuildUintL(attrId)->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(0x1108))
			->EndListL();
		// Add the record into the database
		theDb->AddRecord(theRec);
	}
	return theDb;
	}
Ejemplo n.º 21
0
void BuildRecordZeroL(CSdpDatabase* aDb)
/**
 Record 0 should be used when a server instance is created.
 note that attributes 2, 5 and 0x201 should be updated.
 also note only English, pas de Francais, keine Deutsch, non Espanol
**/
	{
	TBuf8<2> attrId;
	TBuf8<4> val;
	CSdpServRecord* theRec = CSdpServRecord::NewL();
	CleanupStack::PushL(theRec);


	// Set Attr 0 (Record handle) to 0
	attrId.FillZ(2);
	val.FillZ(4);
	theRec->BuildUintL(attrId)->BuildUintL(val);

	// Set Attr 1 (service class list) to list with UUID = 0x1000
	attrId[0] = 0x00;
	attrId[1] = 0x01;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint16(0x1000)))
		->EndListL();

	// Set Attr 2 (service record state) to 0
	attrId[0] = 0x00;
	attrId[1] = 0x02;
	val.FillZ(4);
	theRec->BuildUintL(attrId)->BuildUintL(val);


	// Set attr 4 (protocol list) to L2CAP, no RFCOMM, no OBEX
	attrId[0] = 0x00;
	attrId[1] = 0x04;
	val.FillZ(4);
	val[3] = 1;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP
			->EndListL()
		->EndListL();

	// Set Attr 5 (browse group list) to list with one UUID
	// 0x1000 (SDP server class)
// this should be updated with other service classes when other services are added.
	attrId[0] = 0x00;
	attrId[1] = 5;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint32(0x1002)))
		->EndListL();

	// Set Attr 0x006 (language base)
	attrId[0] = 0x00;
	attrId[1] = 0x06;
	TUint16 lang = 0x656e;
	TUint16 coding = 0x006a;
	TUint16 base = 0x0100;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUintL(TSdpIntBuf<TUint16>(lang)) // english
			->BuildUintL(TSdpIntBuf<TUint16>(coding)) // UTF-8
			->BuildUintL(TSdpIntBuf<TUint16>(base)) // language base
		->EndListL();

	// Set Attr 0x007 (time to live) to 1200 (0x4B0) seconds (20 minutes)
	attrId[0] = 0x00;
	attrId[1] = 0x07;
	val.FillZ(4);
	val[2]=4;
	val[3]=0xb0;
	theRec->BuildUintL(attrId)->BuildUintL(val);

	// Set Attr 0x008 (availability) to 0xff - fully available - not in use
	attrId[0] = 0x00;
	attrId[1] = 0x08;
	TBuf8<1> val4;
	val4.FillZ(1);
	val4[0]=0xff;
	theRec->BuildUintL(attrId)->BuildUintL(val4);


	// Set Attr 0x100 (default Name) to string
	attrId[0] = 0x01;
	attrId[1] = 0;
	theRec->BuildUintL(attrId)->BuildStringL(_L8("SDP Server"));

	// Set Attr 0x101 (def. description) to string
	attrId[0] = 0x01;
	attrId[1] = 1;
	theRec->BuildUintL(attrId)->BuildStringL(_L8("EPOC SDP server UPF-4"));

	// Set Attr 0x102 (def. provider) to Symbian
	attrId[0] = 0x01;
	attrId[1] = 2;
	theRec->BuildUintL(attrId)->BuildStringL(_L8("Symbian Ltd."));

	// Set Attr 0x201 (service database state) to 0
	attrId[0] = 0x02;
	attrId[1] = 0x01;
	val.FillZ(4);
	theRec->BuildUintL(attrId)->BuildUintL(val);

	CleanupStack::Pop();
	// Add the record into the database
	aDb->AddRecord(theRec);
}
Ejemplo n.º 22
0
// ---------------------------------------------------------------------------
// CTestRtcp::TestSendByeL
// ---------------------------------------------------------------------------
//
void CTestRtcp::TestSendByeL()
    {
    CMccInterfaceStub* stub = CMccInterfaceStub::NewL();
    CleanupStack::PushL( stub );
    CMccInterface* interface = CMccInterface::NewL( *stub );
    CleanupStack::PushL( interface );

    // Create session
    TUint32 session;
    User::LeaveIfError( interface->CreateSession( session ) );
    
    RPointerArray<CMccCodecInformation> codecArray;
    CleanupResetAndDestroy< RPointerArray<CMccCodecInformation> >::PushL( codecArray );
    User::LeaveIfError( interface->GetCapabilities( codecArray ) );
    codecArray[0]->SetPriority( EMdaPriorityMax );

    // Create link
    TUint32 link;
    TInt linkType = KMccLinkGeneral;
    User::LeaveIfError( interface->CreateLink( session, linkType, link, iNetsettings ) );
    stub->WaitForEvent( session, link, 0, KMccLinkCreated );
    
    User::LeaveIfError( interface->SetRemoteAddress( session, link, iNetsettings.iRemoteAddress ) );

    // Create upstream    
    TUint32 upStream;
    TUint32 dataSinkId;
    TUint32 dataSourceId;
     
    interface->AddDataSink( KMccRtpSinkUid, KNullDesC8, dataSinkId );
    interface->AddDataSource( KUidMmfAudioInput, KNullDesC8, dataSourceId );
    
    codecArray[0]->SetPriorityPreference( KAudioPrefVoipAudioUplink );
    User::LeaveIfError( interface->CreateStream( session, link, upStream,
                                                 KMccAudioUplinkStream, *codecArray[0] ) );
                                                 
    User::LeaveIfError( interface->PrepareStream( session, link, upStream ) );
    stub->WaitForEvent( session, link, upStream, KMccStreamPrepared );
    stub->WaitForEvent( session, link, upStream, KMccStreamPrepared );
    
    User::LeaveIfError( interface->StartStream( session, link, upStream ) );
    stub->WaitForEvent( session, link, upStream, KMccStreamStarted );
    stub->WaitForEvent( session, link, upStream, KMccStreamStarted );
    
    iConsole.Printf( _L( "Press any key to send Bye\n" ) );
    iConsole.Getch();    
    
    TMccRtcpEventData signal;
    signal.iRtcpPacketType = KRtcpByePacket;
    
    TBuf8<10> reason;
    reason.SetMax();
    reason.FillZ();  
    
    signal.iRtcpPacketData = reason;
    TPckgBuf<TMccRtcpEventData> rtcpPkg( signal );

    // Encapsulate the signal in event
    TMccEvent event;
    event.iSessionId = session;
    event.iLinkId = link;
    event.iStreamId = upStream;
    event.iEventCategory = KMccEventCategoryRtcp;
    event.iEventType = KMccRtcpControl;
    event.iEventData.Append( rtcpPkg );
    
    // Send the signal
    interface->SendMediaSignalL( event );
    
    // Clean up
    User::LeaveIfError( interface->StopStream( session, link, upStream ) );
    stub->WaitForEvent( session, link, upStream, KMccStreamStopped );
    stub->WaitForEvent( session, link, upStream, KMccStreamStopped );
    
    // TBD: REMOVE DATASINK&SOURCE
    User::LeaveIfError( interface->DeleteStream( session, link, upStream ) );   
    User::LeaveIfError( interface->CloseLink( session, link ) );
    User::LeaveIfError( interface->CloseSession( session ) );
    
    CleanupStack::Pop(); // Codec array
    codecArray.ResetAndDestroy();
    codecArray.Close();
    CleanupStack::PopAndDestroy( interface );
    CleanupStack::PopAndDestroy( stub );
    }
Ejemplo n.º 23
0
TBool CTestBitStr::PerformTestsL(CConsoleBase& aConsole)
{
    TBool pass = ETrue;


    // Test the encoding varying length bit strings by encoding 65
    // different bit strings with a single bit set in each position. Position -1
    // indicates the empty bit string.
    for (TInt8 bitNum = -1; bitNum < 64; bitNum++)
    {
        TBuf8<8> bitStr;
        TUint numOctets;

        if (bitNum >= 0)
        {
            numOctets = 1 + (bitNum / 8);
        }
        else
        {
            numOctets = 0;
        }

        bitStr.SetLength(numOctets);
        bitStr.FillZ();

        TUint8 valToEncode = 0;
        if (bitNum >= 0 )
        {
            // The most significant bit in the most significant byte is bit zero
            valToEncode = (TUint8) (1 << (7 - (bitNum % 8)));
            bitStr[bitNum / 8] = valToEncode;
        }

        // Get the encoder and decoder
        CASN1EncBitString* encoder = CASN1EncBitString::NewLC(bitStr, bitNum + 1);
        TASN1DecBitString decoder;

        // Prepare an encode buffer
        TInt totalLength = encoder->LengthDER();
        HBufC8* encodeBuffer = HBufC8::NewMaxLC(totalLength);
        TPtr8 tEncodeBuf = encodeBuffer->Des();

        // Write into the encode buffer
        TUint writeLength = 0;
        encoder->WriteDERL(tEncodeBuf, writeLength);

        // Read it out again and check lengths plus encoded value
        TInt readLength = 0;
        HBufC8* decodeBuffer = decoder.ExtractOctetStringL(tEncodeBuf, readLength);
        CleanupStack::PushL(decodeBuffer);
        TPtr8 tDecodeBuf = decodeBuffer->Des();

        if (writeLength != STATIC_CAST(TUint, readLength))
        {
            aConsole.Write(_L("ERROR!\n"));
            iASN1Action.ReportProgressL(KErrASN1EncodingError, 1, 1);
            pass = EFalse;
        }
        else if (bitNum >= 0 && valToEncode != tDecodeBuf[bitNum / 8])
        {
            aConsole.Write(_L("ENCODING ERROR!\n"));
            iASN1Action.ReportProgressL(KErrASN1EncodingError, 1, 1);
            pass = EFalse;
        }
        else
        {
            iASN1Action.ReportProgressL(KErrNone, bitNum + 1, 65);
        }

        CleanupStack::PopAndDestroy(3, encoder); // decodeBuffer, encodeBuffer, encoder
    }

    return pass;
}
Ejemplo n.º 24
0
CSdpDatabase *BuildUpf4DbL()
	{
	CSdpDatabase *theDb = CSdpDatabase::NewL();
	
	TBuf8<2> attrId;
	TBuf8<4> val;
	CSdpServRecord *theRec = CSdpServRecord::NewL();
// all attribute IDs are BIG ENDian 

// Record 0 should be used when a server instance is created.
// note that attributes 2, 5 and 0x201 should be updated.
// also note only English, pas de Francais, keine Deutsch, non Espanol
	BuildRecordZeroL(theDb);
	
// Second Record DUN service

	attrId.FillZ(2);
	val.FillZ(4);
	// Set Attr 0 (Record handle) to 0x00010000
	val[0] = 0x00;
	val[1] = 0x01;
	val[2] = 0x00;
	val[3] = 0x00;
	theRec->BuildUintL(attrId)->BuildUintL(val);

	// Set Attr 1 (service class list) to list with Two UUID = 0x1103, 0x1201
	attrId[0] = 0x00;
	attrId[1] = 0x01;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint16(0x1103))) // dial up networking
			->BuildUUIDL(TUUID(TUint16(0x1201))) // generic networking
		->EndListL();

	// Set attr 4 (protocol list) to L2CAP, RFCOMM (DLCI=1), no OBEX
	attrId[0] = 0x00;
	attrId[1] = 0x04;
	val.FillZ(4);
	val[3] = 1;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP
			->EndListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0003))) // RFCOMM
				->BuildUintL(TSdpIntBuf<TUint8>(1)) // DLCI = 1
//				->BuildUintL(val) was four bytes	// DLCI = 1 
			->EndListL()
		->EndListL();

	// Set Attr 0x005 (browse group list) to public root
	attrId[0] = 0x00;
	attrId[1] = 0x05;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint16(0x1002))) // publicBrowseRoot
		->EndListL();

	// Set Attr 0x006 (language base)
	attrId[0] = 0x00;
	attrId[1] = 0x06;
/*	val.FillZ(2);
	val[0] = 0x65;
	val[1] = 0x6e;
	TBuf8<2> val2;
	TBuf8<2> val3;
	val2.FillZ(2);
	val3.FillZ(2);
	val2[1] = 0x6a;
	val3[0] = 0x01;
*/
	TUint16 lang = 0x656e;
	TUint16 coding = 0x006a;
	TUint16 base = 0x0100;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUintL(TSdpIntBuf<TUint16>(lang)) // english
			->BuildUintL(TSdpIntBuf<TUint16>(coding)) // UTF-8
			->BuildUintL(TSdpIntBuf<TUint16>(base)) // language base
		->EndListL();

	// Set Attr 0x009 (profile descriptor list) to Dun version 1.00
	attrId[0] = 0x00;
	attrId[1] = 0x09;
	val.FillZ(2);
	val[0] = 0x01;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(KDialUpNetworkingUUID))) // Dialup Networking
				->BuildUintL(val)	// version 0x100
			->EndListL()
		->EndListL();

	// Set Attr 0x100 (default Name) to string
	attrId[1] = 0x00;
	attrId[0] = 0x01;
	theRec->BuildUintL(attrId)->BuildStringL(_L8("Dial-up networking"));
	
	// Add the record into the database
	theDb->AddRecord(theRec);

	

	// Third Record Fax
	theRec = CSdpServRecord::NewL();

	attrId.FillZ(2);
	val.FillZ(4);
	// Set Attr 0 (Record handle) to 0x00010001
	val[0] = 0x00;
	val[1] = 0x01;
	val[2] = 0x00;
	val[3] = 0x01;
	theRec->BuildUintL(attrId)->BuildUintL(val);

	// Set Attr 1 (service class list) to list with Two UUID = 0x1111, 0x1204
	attrId[0] = 0x00;
	attrId[1] = 0x01;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint16(0x1111))) // Fax
			->BuildUUIDL(TUUID(TUint16(0x1204))) // generic telephony
		->EndListL();

	// Set attr 4 (protocol list) to L2CAP, RFCOMM (DLCI=2), no OBEX
	attrId[0] = 0x00;
	attrId[1] = 0x04;
	val.FillZ(4);
	val[3] = 2;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP
			->EndListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0003))) // RFCOMM
				->BuildUintL(val)	// DLCI = 2
			->EndListL()
		->EndListL();

	// Set Attr 0x005 (browse group list) to public root
	attrId[0] = 0x00;
	attrId[1] = 0x05;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint16(0x1002))) // publicBrowseRoot
		->EndListL();

	// Set Attr 0x006 (language base)
	attrId[0] = 0x00;
	attrId[1] = 0x06;
	lang = 0x656e;
	coding = 0x006a;
	base = 0x0100;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUintL(TSdpIntBuf<TUint16>(lang)) // english
			->BuildUintL(TSdpIntBuf<TUint16>(coding)) // UTF-8
			->BuildUintL(TSdpIntBuf<TUint16>(base)) // language base
		->EndListL();

	// Set Attr 0x009 (profile descriptor list) to Dun version 1.00
	attrId[0] = 0x00;
	attrId[1] = 0x09;
	val.FillZ(2);
	val[0] = 0x01;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(KFaxUUID))) // Fax
				->BuildUintL(val)	// version 0x100
			->EndListL()
		->EndListL();

	// Set Attr 0x100 (default Name) to string
	attrId[1] = 0x00;
	attrId[0] = 0x01;
	theRec->BuildUintL(attrId)->BuildStringL(_L8("Fax"));
	
	// Add the record into the database
	theDb->AddRecord(theRec);

	// Fourth Record Obex
	theRec = CSdpServRecord::NewL();

	attrId.FillZ(2);
	val.FillZ(4);
	// Set Attr 0 (Record handle) to 0x00010001
	val[0] = 0x00;
	val[1] = 0x01;
	val[2] = 0x00;
	val[3] = 0x02;
	theRec->BuildUintL(attrId)->BuildUintL(val);

	// Set Attr 1 (service class list) to list with One UUID = 0x1105
	attrId[0] = 0x00;
	attrId[1] = 0x01;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint16(0x1105))) // Obex
		->EndListL();

	// Set attr 4 (protocol list) to L2CAP, RFCOMM (DLCI=3), OBEX
	attrId[0] = 0x00;
	attrId[1] = 0x04;
	val.FillZ(4);
	val[3] = 3;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP
			->EndListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0003))) // RFCOMM
				->BuildUintL(val)	// DLCI = 3
			->EndListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0008))) // Obex
			->EndListL()
		->EndListL();

	// Set Attr 0x005 (browse group list) to public root
	attrId[0] = 0x00;
	attrId[1] = 0x05;
	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint16(0x1002))) // publicBrowseRoot
		->EndListL();

	// Set Attr 0x006 (language base)
	attrId[0] = 0x00;
	attrId[1] = 0x06;
	lang = 0x656e;
	coding = 0x006a;
	base = 0x0100;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()
			->BuildUintL(TSdpIntBuf<TUint16>(lang)) // english
			->BuildUintL(TSdpIntBuf<TUint16>(coding)) // UTF-8
			->BuildUintL(TSdpIntBuf<TUint16>(base)) // language base
		->EndListL();

	// Set Attr 0x009 (profile descriptor list) to Obex version 1.00
	attrId[0] = 0x00;
	attrId[1] = 0x09;

	val.FillZ(2);
	val[0] = 0x01;

	theRec->BuildUintL(attrId)->BuildDESL()
		->StartListL()->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(KObexUUID))) // Obex
				->BuildUintL(val)	// version 0x100
			->EndListL()
		->EndListL();

	// Set Attr 0x100 (default Name) to string
	attrId[1] = 0x00;
	attrId[0] = 0x01;
	theRec->BuildUintL(attrId)->BuildStringL(_L8("OBEX Objext Push"));
	
	// Add the record into the database
	theDb->AddRecord(theRec);

	return theDb;
	}
Ejemplo n.º 25
0
void CDHCPIP6Control::HandleGetMultipleParamsL(TDes8& /*aDes */)
#endif //SYMBIAN_TCPIPDHCP_UPDATE
/**
  * This function will be called when the application want to retrieve multiple 
  * options from the server by using option ORO(option 6) 
  *
  * @see RFC 3315 sec 22.7
  * @internalTechnology
  */
	{
#ifdef SYMBIAN_TCPIPDHCP_UPDATE	
	HBufC8 *saveBuf=NULL, *buffer=NULL;
	TUint16 *headerPtr;
	TInt numOfOpcodes=0;
	TInt totalLength=0,opcodeLength=aDes.Length();
	TInt maxLength=aDes.MaxLength();
	TUint16 opcode;
	TBool allFound=ETrue;
	
	DHCPv6::CDHCPMessageHeaderIP6 msgSaved(saveBuf);
	TPtr8 savedPtr(const_cast<TUint8*>(iValidMsg.Ptr()), iValidMsg.Length(), iValidMsg.Length());
	CleanupClosePushL(msgSaved);
	msgSaved.iRecord.ParseL(savedPtr);

	//The below for loop checks all the required opcode data is present or not
	//The message opcode data is not present in the iValidMsg buffer,the corresponding 
	//opcodes are stored in iCurrentParameters for sending it in DHCPINFORM message
	for(TInt i=0;i<opcodeLength;i++)
		{
		opcode=*(aDes.Ptr()+i); //search required opcode is present or not, one by one
		
		DHCPv6::COptionNode* findNode = msgSaved.GetOptions().FindOption(opcode);
		if (findNode )
			{
			//get the opcode length
			TInt bufLength=findNode->GetItemLength();
			totalLength+=bufLength;
			//The opcode buffer length is greater than maximum length through overflow error
			if ((totalLength+1) > maxLength)
				{
				totalLength-=bufLength;
				continue; //current buffer is too big..so hope next buffer is small
				}
			if (!buffer)
				{
				buffer=HBufC8::NewLC(totalLength + 1);//+1 is extra byte to store number of opcodes
				buffer->Des().Append(KNoChar);
				}
			else
				{
				buffer=buffer->ReAllocL(totalLength + 1);
				CleanupStack::Pop();//buffer as ptr address has changed
		        CleanupStack::PushL(buffer);
				}
			headerPtr = reinterpret_cast<TUint16*>(findNode->Ptr()); 
			++numOfOpcodes;
			//Append the opcode information to the buffer
			buffer->Des().Append(reinterpret_cast<const TUint8*>(headerPtr),bufLength);
			}
		else
			{
			//If atleast one opcode, among the requested, is not found then request through 
			//DHCP INFORM message by calling RequestInformOrCompleteCallL
			allFound=EFalse;
			}
		}
	
	if (allFound ) //everything is present..just return call now itself..
		{
		if ((totalLength + 1) > maxLength || totalLength<=0)
			{
			User::Leave(KErrOverflow);
			}
		if(buffer) // buffer would be NULL only when aDes.Length = 0 which is a rare scenario. But still check it to avoid NULL pointer dereference.
			{
			aDes.Copy(buffer->Ptr(), buffer->Length());
			TBuf8<1> dummy;
			dummy.FillZ(1);
			dummy[0]=numOfOpcodes;
			aDes.Replace(0,1,dummy);//update number of opcodes collected
			}
		}
	else
		{
		//If the option is not found then trigger the information request
		TPtr8 opcodePtr(const_cast<TUint8*>(aDes.Ptr()),opcodeLength);
		opcodePtr.SetLength(opcodeLength);
		RequestInformOrCompleteCallL(opcodePtr);	
		}	
	
	if (buffer)
		{
		CleanupStack::PopAndDestroy(buffer);
		}

	CleanupStack::PopAndDestroy(&msgSaved);
#endif //SYMBIAN_TCPIPDHCP_UPDATE
	}
Ejemplo n.º 26
0
LOCAL_C void mainL() // initialize and call example code under cleanup stack
    {
	test.Title();
	CTestConsole *con = CTestConsole::NewL(test.Console());

	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);

	TDriveUnit sysDrive (fs.GetSystemDrive());
	TBuf<24> logFile (sysDrive.Name());
	logFile.Append(_L("\\temblog.txt"));

	RFile file;
	User::LeaveIfError(file.Replace(fs, logFile, EFileShareAny|EFileWrite));
	CleanupClosePushL(file);

	con->SetLogFile(file);
	test.SetConsole(con);

    TInt r;
	RDebug::Printf("Hello from user side\n");
	
    test.Start(_L(" @SYMTestCaseID:SEC-CRYPTOSPI-TEMB-0001 Load driver "));

    test.Next(_L("Loading Physical Device"));
    r=User::LoadPhysicalDevice(KPddFileName);
    test(r==KErrNone || r==KErrAlreadyExists);

    test.Next(_L("Loading Logical Device"));
    r=User::LoadLogicalDevice(KLddFileName);
    test(r==KErrNone || r==KErrAlreadyExists);

	//
	// Generate key and IV
	//
    test.Start(_L("Random - Generating key & IV for AES tests"));
	test.Printf(_L("\tGenerating random key\n"));
	// Generate random 16 byte key
	TBuf8<KEYLEN> key;
	key.SetLength(key.MaxLength());
	TRandom::RandomL(key);
	key[0] = 'K';
	key[1] = 'E';
	key[2] = 'Y';
	key[3] = '*';
	for(int z=4; z<KEYLEN; ++z) key[z] = z;

	test.Printf(_L("\tGenerating random IV\n"));
	// Generate random 16 byte IV
	TBuf8<16> iv;
	iv.SetLength(iv.MaxLength());
	TRandom::RandomL(iv);
	iv[0] = 'I';
	iv[1] = 'V';
	iv[2] = '*';
	iv[3] = '*';

	TBuf8<BUFLEN> plaintext;
	plaintext.FillZ();
	plaintext.SetLength(BUFLEN);
	plaintext[0] = 'P';
	plaintext[1] = 'L';
	plaintext[2] = 'A';
	plaintext[3] = 'I';
	plaintext[4] = 'N';
	for(int i=0; i<BUFLEN; ++i)
		{
		plaintext[i] = i;
		}


	//
	// KMS tests
	//
    test.Next(_L("KMS - Store key"));
	TBuf8<BUFLEN+16> kmsData;
	kmsData.FillZ();
	kmsData.SetLength(0);
	do
		{
		RKeyMgmtSession kms;
		User::LeaveIfError(kms.Connect());
		CleanupClosePushL(kms);
		
		TKeyHandle keyHandle;
		User::LeaveIfError(kms.StoreKey(key, keyHandle));
		_LIT_SECURITY_POLICY_PASS(KAlwaysPass);
		User::LeaveIfError(kms.AddUsage(keyHandle, 0 /* operation */, KAlwaysPass));
		
		test.Next(_L("KMS - Attempt to use key via embedded key handle"));
		TPckgBuf<TKeyHandle> keyHandlePkg;
		keyHandlePkg() = keyHandle;

		TKeyProperty keyProperty = {KAesUid, KNullUid, KSymmetricKeyUid, KNonExtractableKey};
		CCryptoParams* keyParam =CCryptoParams::NewLC();
		keyParam->AddL(keyHandlePkg, KSymmetricKeyParameterUid);
		CKey *ckey=CKey::NewL(keyProperty, *keyParam);
		CleanupStack::PopAndDestroy(keyParam);
		CleanupStack::PushL(ckey);
		CryptoSpi::CSymmetricCipher *aes = 0;
		CSymmetricCipherFactory::CreateSymmetricCipherL(aes,
														KAesUid,
														*ckey,
														KCryptoModeEncryptUid,
														KOperationModeCBCUid,
														KPaddingModePKCS7Uid,
														NULL);
		CleanupStack::PopAndDestroy(ckey);
		CleanupStack::PushL(aes);

		aes->SetOperationModeL(CryptoSpi::KOperationModeCBCUid);
		aes->SetIvL(iv);		

		aes->ProcessFinalL(plaintext, kmsData);

		CleanupStack::PopAndDestroy(aes);
		CleanupStack::PopAndDestroy(&kms);
		} while(false);


	//
	// Encrypt using legacy API
	//
	TBuf8<BUFLEN+16> sw;
	sw.FillZ();
	sw.SetLength(0);
	do 
		{ 
		test.Next(_L("Encrypt using key directly (non-KMS)"));
		
		// ECB
		test.Printf(_L("    CBC\n"));
		CAESEncryptor *rawaes = CAESEncryptor::NewLC(key); // rawaes
		CModeCBCEncryptor *cbc = CModeCBCEncryptor::NewL(rawaes, iv);
		CleanupStack::Pop(rawaes); //
		CleanupStack::PushL(cbc);  // cbc
		
#ifdef PKCS7PAD
		CPadding *pad = CPaddingPKCS7::NewLC(16); // cbc, pad
#else
		CPadding *pad = CPaddingNone::NewLC(16); // cbc, pad
#endif
		CBufferedEncryptor *aes = CBufferedEncryptor::NewL(cbc, pad);
		CleanupStack::Pop(pad); // cbc
		CleanupStack::Pop(cbc);
		CleanupStack::PushL(aes); // aes
		
		test.Printf(_L("About to s/w encrypt (old api)\n"));
		aes->ProcessFinalL(plaintext, sw);
		
		CleanupStack::PopAndDestroy(aes);
		} while(false);

	test.Printf(_L("Checking KMS encrypt and direct encrypt had the same result\n"));
	test(kmsData == sw);
    test.End();
	
	test.Printf(_L("\r\n0 tests failed out of 1\r\n"));
		
	// test.Printf(KTxtPressAnyKey);
	// test.Getch(); // get and ignore character
	test.Close();

	CleanupStack::PopAndDestroy(&file);
	CleanupStack::PopAndDestroy(&fs);
    }