Esempio 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);
	}
Esempio n. 2
0
void AvrcpSdpUtils::CreateServiceRecordL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle, TBool aTarget, TUint16 aProfileVersion)
	{
	if(!aTarget)
		{
		// New service record with service class attribute containing
		// 0x110e (for A/V Remote Control) 
		CSdpAttrValueDES* serviceClassUuids = CSdpAttrValueDES::NewDESL(NULL);
		CleanupStack::PushL(serviceClassUuids);
		
		if(aProfileVersion == AvrcpSdp::KAvrcpProfileVersion13)
			{
			serviceClassUuids->StartListL()
					->BuildUUIDL(TUUID(TUint16(KAVRemoteControlUUID)))
			->EndListL();
			}
		else
			{
			serviceClassUuids->StartListL()
					->BuildUUIDL(TUUID(TUint16(KAVRemoteControlUUID)))
					->BuildUUIDL(TUUID(TUint16(KAVRemoteControlControllerUUID)))
			->EndListL();
			}
		
		aSdpDatabase.CreateServiceRecordL(*serviceClassUuids, aRecHandle);
		CleanupStack::PopAndDestroy(serviceClassUuids);

		aSdpDatabase.UpdateAttributeL(aRecHandle,
			KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceName,
			AvrcpSdp::KAvrcpControllerServiceName
			);
		}
	else
		{
		// New service record with service class attribute containing
		// 0x110c (for A/V Remote Control Target) 
		aSdpDatabase.CreateServiceRecordL(KAVRemoteControlTargetUUID, aRecHandle);
		
		aSdpDatabase.UpdateAttributeL(aRecHandle,
			KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceName,
			AvrcpSdp::KAvrcpTargetServiceName
			);
		}

	aSdpDatabase.UpdateAttributeL(aRecHandle,
		KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetProviderName,
		AvrcpSdp::KAvrcpProviderName
		);
	aSdpDatabase.UpdateAttributeL(aRecHandle,
		KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceDescription,
		AvrcpSdp::KAvrcpServiceDescription
		);	
	}
Esempio n. 3
0
void CBCTestKeymap::TestNextKey()
    {
    TBool isAppend = ETrue;
    iMap->StartMapping(EPtiKey3, EPtiCaseLower);
    AssertIntL( TUint16('e'), iMap->NextKey(EPtiKey3, isAppend, EPtiCaseLower),
        _L("press 3, press 3 got 'e'"));

    AssertTrueL( !isAppend, _L("and 'e' is not append"));

    AssertIntL( TUint16('F'), iMap->NextKey(EPtiKey3, isAppend, EPtiCaseUpper),
        _L("then, press Shift 3 got 'F'"));

    AssertIntL( TUint16('g'), iMap->NextKey(EPtiKey4, isAppend, EPtiCaseLower),
        _L("then press 4 as next key, got 'g'"));
    }
Esempio n. 4
0
void RatioPrint2(const char* aTitle, const SRatio& aR1, const SRatio& aR2)
	{
	TPtrC8 t8((const TUint8*)aTitle);
	TBuf<256> t16;
	t16.Copy(t8);
	test.Printf(_L("%S: %08x %04x   %08x %04x\n"), &t16, aR1.iM, TUint16(aR1.iX), aR2.iM, TUint16(aR2.iX));
	}
Esempio n. 5
0
MSdpElementBuilder* CRFCommAttribs::BuildUUIDL(const TUUID& aUUID)
/**
	Go and get RFComm UUID info.
*/
	{
#ifdef _DEBUG
	TBuf8<40> desUUID;
	desUUID = aUUID.ShortestForm();
	TBuf<40> readableUUID;
	readableUUID.Copy(desUUID);

	LOG1(_L("CRFCommAttribs::BuildUUIDL(%S) main entry\n"), &readableUUID);
#endif
	if (iPortAttrib!=NULL)
		{
		LOG(_L("iPortAttrib already exists, returning it."));
		return iPortAttrib; // i.e go to the get RFComm port 'snatching' state
		// although this will not always be correct, but suits us for now
		}
	if(aUUID==TUUID(TUint16(KSDPRFCommUUID)))  
		{		
#ifdef _DEBUG
		LOG1(_L("CRFCommAttribs::BuildUUIDL(%S) if =RFCOMMUUID\n"), &readableUUID);
#endif
		iRfcommUUID=TUUID(aUUID);
		LOG(_L("CRFCommPortAttribs NewL"));
		iPortAttrib = CRFCommPortAttrib::NewL(this);
		LOG(_L("CRFCommPortAttribs - NewL survived"));
		return iPortAttrib;
		}

	LOG2(_L("CRFCommAttribs - return this = 0x%08x, iPortAttrib = 0x%08x"), this, iPortAttrib);
	return this;
	}
Esempio n. 6
0
void AvrcpSdpUtils::UpdateAdditionalProtocolDescriptorListL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle)
	{
	CSdpAttrValueDES *attrValDES = CSdpAttrValueDES::NewDESL(0);
	CleanupStack::PushL(attrValDES);
	attrValDES->StartListL()
		->BuildDESL()->StartListL()
			->BuildUUIDL(TUUID(TUint16(KL2CAP)))				// L2CAP
			->BuildUintL(TSdpIntBuf<TUint16>(0x1b))				// PSM = AVCTP_browse
		->EndListL()
		->BuildDESL()->StartListL()
			->BuildUUIDL(TUUID(TUint16(KAVCTP)))					// AVCTP
			->BuildUintL(TSdpIntBuf<TUint16>(AvrcpSdp::KAvctpProtocolVersion13))// 0x0103
		->EndListL()
	->EndListL();
	aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdAdditionalProtocolDescriptorList, *attrValDES);
	CleanupStack::PopAndDestroy(attrValDES);
	}
void ChangePathSeparator( TDes& aDesPtr, TUint aPathSeperatorFrom, TUint aPathSeperatorTo )
	{
	for( TInt offset = aDesPtr.Length() - 1; offset >= 0; offset-- )
		{
		if ( aDesPtr[offset] == aPathSeperatorFrom )
			{	
				aDesPtr[offset] = TUint16( aPathSeperatorTo );
			}
		}
	}
Esempio n. 8
0
void AvrcpSdpUtils::UpdateBrowseListL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle)
	{
	CSdpAttrValueDES *attrValDES = CSdpAttrValueDES::NewDESL(0);
	CleanupStack::PushL(attrValDES);
	attrValDES->StartListL()
			  	->BuildUUIDL(TUUID(TUint16(KPublicBrowseGroupUUID)))	 // Public browse group										
		      	->EndListL();
	aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdBrowseGroupList, *attrValDES);
	CleanupStack::PopAndDestroy(attrValDES);
	}
Esempio n. 9
0
void CBCTestKeymap::TestReplaceMappingL()
    {
    TBool isAppend = ETrue;
    _LIT(KNewMapLower, "!@#$");
    _LIT(KNewMapUpper, "%:=&");
    TBuf<5> lowerMap(KNewMapLower);
    TBuf<5> upperMap(KNewMapUpper);

    AssertIntL( KErrNone, iMap->ReplaceKeyMapL(EPtiKey1, lowerMap, EPtiCaseLower),
        _L("Lower case mapping for Key 1 change to !@#$"));
    AssertIntL( KErrNone, iMap->ReplaceKeyMapL(EPtiKey1, upperMap, EPtiCaseUpper),
        _L("Upper case mapping for Key 1 change to %:=&"));

    AssertIntL( TUint('!'), iMap->StartMapping(EPtiKey1, EPtiCaseLower),
        _L("press 1 got '!'"));
    AssertIntL( TUint16('@'), iMap->NextKey(EPtiKey1, isAppend, EPtiCaseLower),
        _L("press 1, again got '@'"));
    AssertIntL( TUint16('='), iMap->NextKey(EPtiKey1, isAppend, EPtiCaseUpper),
        _L("then, press Shift 1 got '@'"));
    AssertIntL( TUint16('a'), iMap->NextKey(EPtiKey2, isAppend, EPtiCaseLower),
        _L("then press 2 as next key, got 'a'"));
    }
Esempio n. 10
0
TInt SdpReqHandler::RunError(TInt aError, const TSdpPdu& /*aReqPdu*/, TSdpPdu &aRespPdu)
#endif
/**
	Send an appropriate error.

	Parameter format is
 @verbatim
		Error Code					TUint16
		Error Info					Variable (0 in 1.0B)
 @endverbatim
**/
	{
	TSdpErrorCodes code;
	switch (aError)
		{
	case KErrNotSupported:
		code = EInvalidSdpVersion;
		break;
	case KErrBadHandle:
		code = EInvalidServiceRecordHandle;
		break;
	case KErrOverflow: 
	case KErrUnderflow:
	case KErrTooBig:
		code = EInvalidPduSize;
		break;
	case KErrNotReady:
	case KErrUnknown:
	case KErrLocked:
		code = EInvalidContinuationState;
		break;
	case KErrNoMemory:
	case KErrHardwareNotAvailable:
		code = EInsufficientResources;
		break;
	case KErrCorrupt:
	case KErrArgument:
	default:
		code = EInvalidRequestSyntax;
		break;
		}
	aRespPdu.iPduId = EErrorResponse;
	aRespPdu.iParams.SetLength(2);
	BigEndian::Put16(&aRespPdu.iParams[0], TUint16(code));

	LOG1(_L("SdpReqHandler::RunError(%d)"), aError);
	
	return KErrNone;
	}
Esempio n. 11
0
/**
Function to Insert the {aCount,aValue} pair into the already sorted array of nodes
@internalComponent
@released
*/
void InsertInOrder(TNode* aNodes, TInt aSize, TUint aCount, TInt aVal)
{
	// Uses Insertion sort following a binary search...
	TInt l=0, r=aSize;
	while (l < r)
	{
		TInt m = (l+r) >> 1;
		if (aNodes[m].iCount<aCount)
			r=m;
		else
			l=m+1;
	}
	memmove(aNodes+l+1,aNodes+l,sizeof(TNode)*(aSize-l));
	aNodes[l].iCount=aCount;
	aNodes[l].iRight=TUint16(aVal);
}
MSdpElementBuilder* CSdpAttrIdMatchList::BuildUintL(const TDesC8& aUint)
/** This should be one or two 16 bit integers, representing an AttrId of range thereof respectively. */
	{
	TInt len = aUint.Length();
	if (len != 2 && len != 4)
		{// Bad Uint size
		User::Leave(KErrCorrupt);
		}

	// Get either the two or four byte version
	TUint attrId = SdpUtil::GetUint(aUint);
	TAttrRange range;
	range.iStart = TUint16(len == 4 ? attrId >> 16 : attrId);
	range.iEnd = TUint16(attrId);

	// Add in place (optimised for incoming stream ordered -- but we will cope if isn't
	// Will leave if a bad range is supplied
	AddL(range);
	return this;
	}
/**
This routine is used to convert Arabic-Indic, Eastern Arabic-Indic
or Devanagari digits to European digits. 

@param aDes Parameter to change
*/
void CResourceLoader::LanguageSpecificNumberConverter::ConvertToWesternNumbers( TDes &aDes )
    {   
    const TChar toArea = 0x030;
    const TInt KLastDevanagariDigit = 0x96F;
    const TInt KFirstDevanagariDigit = 0x966;
    const TInt length = aDes.Length();

    for( TInt i=0; i<length; i++ )
        {
        TChar character = aDes[i];
        TChar fromArea = NumberToBase( character );
        TChar::TBdCategory cat = character.GetBdCategory();

        if ( cat == TChar::EArabicNumber || cat == TChar::EEuropeanNumber ||
           ( KFirstDevanagariDigit <= character && character <= KLastDevanagariDigit ) )
            {
            character += toArea;
            character -= fromArea;
            aDes[i] = TUint16( character );    
            }        
        }
    }
/**
This routine is used to convert between European digits and 
Arabic-Indic, Eastern Arabic-Indic, Devanagari or Thai digits 
based on existing digit type setting. 

@param aDes  Parameter to change
*/
void CResourceLoader::LanguageSpecificNumberConverter::Convert( TDes &aDes )
    {   
    TLocale locale;
    locale.Refresh();
    const TDigitType digitType = locale.DigitType();
    TChar toArea = 0x030;
    switch( digitType )
        {
        case EDigitTypeWestern:
        case EDigitTypeArabicIndic:
        case EDigitTypeEasternArabicIndic:
        case EDigitTypeDevanagari:
        case EDigitTypeThai:
            toArea = digitType;
            break;
        case EDigitTypeUnknown:
        case EDigitTypeAllTypes:
            return;
        }
    
    const TInt length = aDes.Length();
    for( TInt i = 0; i < length; i++ )
        {
        TChar character = aDes[i];
        TChar fromArea = NumberToBase( character );
        TChar::TBdCategory cat = character.GetBdCategory();
        switch( cat )
            {
            case TChar::EArabicNumber:
            case TChar::EEuropeanNumber:
                character += toArea;
                character -= fromArea;
                aDes[i] = TUint16( character );
                break;
            default: 
                break;
            }
        }
    }
Esempio n. 15
0
void CHCEmulator::GetConnHandle(THCIConnHandle& aConnH, const TUint8* aPacket)
	{
	// ignore the ACL flags
    aConnH = TUint16(((aPacket[1]&~KPacketDataFlagMask)<<8) | aPacket[0]);
//	iParsePtr+=2;
	}
Esempio n. 16
0
/**
Standard 2nd phase constructor, perform initialisation which could leave
*/
void CBtService::ConstructL(const TUUID& aServiceUUID, RSdp& aSdpSession, const TBTServiceSecurity* aSecurity)
	{
	LOG_FN_TRACE((_L("+CBtService::ConstructL")));

	//open handle so it is certain to be valid in the destructor
	iServiceRecord.Open(aSdpSession);

	//First, create a listening socket
	if(iProtocol == KL2CAP)
		{
		iAcceptorSocket = CBluetoothSocket::NewL(*this, iSocketServer, KSockSeqPacket, KL2CAP);
		//bind the socket to a port
		TL2CAPSockAddr addr;
		addr.SetPort(KL2CAPPassiveAutoBind); //allow the stack to choose a free port automatically
		if(aSecurity)
			{
			addr.SetSecurity(*aSecurity); //set security requirements, if present
			}
		User::LeaveIfError(iAcceptorSocket->Bind(addr));
		}
	else if(iProtocol == KRFCOMM)
		{
		iAcceptorSocket = CBluetoothSocket::NewL(*this, iSocketServer, KSockStream, KRFCOMM);
		//bind the socket to a port
		TRfcommSockAddr addr;
		addr.SetPort(KRfcommPassiveAutoBind); //allow the stack to choose a free port automatically
		if(aSecurity)
			{
			addr.SetSecurity(*aSecurity); //set security requirements, if present
			}
		User::LeaveIfError(iAcceptorSocket->Bind(addr));
		}
	User::LeaveIfError(iAcceptorSocket->Listen(1)); 

	//Now, register in the SDP database
	TUint port = iAcceptorSocket->LocalPort(); //get the port chosen by the stack
	LOG_INFO((_L("Listening for connections on port %d"), port));
	iServiceRecord.CreateServiceRecordL(aServiceUUID, iServiceRecordHandle);
	
	// Set attr 4 (protocol list) to L2CAP, and RFCOMM
	CSdpAttrValueDES *attrValDES;

	//This following code is doing these steps
	//1. create a DES (data element set) attribute
	//2. within that list, create a DES for each protocol, L2CAP and optionally RFCOMM
	//3. each protocol is a list of elements, the UUID of the protocol, and the port to connect to.
	//4. the service record is updated to include the new attribute
	//5. discard the attribute we built, as it has been copied to the SDP server
	attrValDES = CSdpAttrValueDES::NewDESL(NULL);
	CleanupStack::PushL(attrValDES);
	if(iProtocol == KL2CAP)
		{
		LOG_INFO((_L("Registering SDP PDL for L2CAP")));
		//This code will register an L2CAP (datagram) service
		attrValDES
			->StartListL()
				->BuildDESL()
					->StartListL()
						->BuildUUIDL(TUUID(TUint16(KL2CAP)))	// L2CAP
						->BuildUintL(TSdpIntBuf<TUint16>(TUint16(port)))	// The Protocol Service Multiplexor (port) for our service
					->EndListL()
			->EndListL();
		}
	else if(iProtocol == KRFCOMM)
		{
		LOG_INFO((_L("Registering SDP PDL for RFCOMM")));
		//This code will register an RFCOMM (stream) service
		attrValDES
			->StartListL()
				->BuildDESL()
					->StartListL()
						->BuildUUIDL(TUUID(TUint16(KL2CAP))) // L2CAP
					->EndListL()
				->BuildDESL()
					->StartListL()
						->BuildUUIDL(TUUID(TUint16(KRFCOMM))) // RFCOMM
						->BuildUintL(TSdpIntBuf<TUint8>(TUint8(port)))
					->EndListL()
			->EndListL();
		}
	iServiceRecord.UpdateAttributeL(iServiceRecordHandle, KSdpAttrIdProtocolDescriptorList, *attrValDES);
	CleanupStack::PopAndDestroy(attrValDES);
	attrValDES = NULL;
	LOG_FN_TRACE((_L("-CBtService::ConstructL")));
	}
Esempio n. 17
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;
}
Esempio n. 18
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;
	}
Esempio n. 19
0
// this is a real dummy database which doesn't conform to the service class attribute numbering
CSdpDatabase *BuildDbL()
	{
	CSdpDatabase *theDb = CSdpDatabase::NewL();
	
	// First Record
	CSdpServRecord *theRec = CSdpServRecord::NewL();

	// Set Attr 0 (Record handle) to 0
	theRec->BuildUintL(TSdpIntBuf<TUint16>(0))->BuildUintL(TSdpIntBuf<TUint32>(0));
	// Set Attr 0x100 (default Name) to string
	theRec->BuildUintL(TSdpIntBuf<TUint16>(0x100))->BuildStringL(_L8("SDP Server"));
	// Set Attr 0x102 (def. provider) to Symbian
	theRec->BuildUintL(TSdpIntBuf<TUint16>(0x102))->BuildStringL(_L8("Symbian Ltd."));
	// Set Attr 0x101 (def. description) to string
	theRec->BuildUintL(TSdpIntBuf<TUint16>(0x101))->BuildStringL(_L8("EPOC SDP server test suite"));
	// Set Attr 1 (service class list) to list with one UUID = 0x1000 (SDP server service)
	theRec->BuildUintL(TSdpIntBuf<TUint16>(1))->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint32(0x1000)))
		->EndListL();
	// Add the record into the database
	theDb->AddRecord(theRec);

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

	// Set Attr 0 (Record handle) to 0x11223344
	theRec->BuildUintL(TSdpIntBuf<TUint16>(0))->BuildUintL(TSdpIntBuf<TUint32>(0x11223344));
	// Set Attr 0x100 (default Name) to string
	theRec->BuildUintL(TSdpIntBuf<TUint16>(0x100))->BuildStringL(_L8("Dummy Service"));
	// Set Attr 0x101 (def. description) to string
	theRec->BuildUintL(TSdpIntBuf<TUint16>(0x101))->BuildStringL(_L8("A Test SDP record"));
	// Set Attr 1 (service class list) to list with Two UUID = 0x1000, 0x55667788
	theRec->BuildUintL(TSdpIntBuf<TUint16>(1))->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint32(0x1000)))
			->BuildUUIDL(TUUID(TUint32(0x55667788)))
		->EndListL();
	// Set Attr 3 (service ID) to a bogoid 0x9999
	theRec->BuildUintL(TSdpIntBuf<TUint16>(3))->BuildUUIDL(TUUID(TUint16(0x9999)));
	// Add the record into the database
	theDb->AddRecord(theRec);

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

	// Set Attr 0 (Record handle) to 0x9899
	theRec->BuildUintL(TSdpIntBuf<TUint16>(0))->BuildUintL(TSdpIntBuf<TUint32>(0x9899));
	// Set Attr 0x100 (default Name) to string
	theRec->BuildUintL(TSdpIntBuf<TUint16>(0x100))->BuildStringL(_L8("Another dummy service"));
	// Set Attr 0x101 (def. description) to string
	theRec->BuildUintL(TSdpIntBuf<TUint16>(0x101))->BuildStringL(_L8("This is the second service on SDP"));
	// Set Attr 1 (service class list) to list with one UUID = 0x1105 (OBEX Push)
	theRec->BuildUintL(TSdpIntBuf<TUint16>(1))->BuildDESL()
		->StartListL()
			->BuildUUIDL(TUUID(TUint32(0x1105)))
		->EndListL();
	// Set attr 4 (protocol list) to L2CAP, RFCOMM (DLCI=5)

	theRec->BuildUintL(TSdpIntBuf<TUint16>(4))->BuildDESL()
		->StartListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP
			->EndListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0003))) // RFCOMM
				->BuildUintL(TSdpIntBuf<TUint32>(5))	// DLCI = 5
			->EndListL()
			->BuildDESL()
			->StartListL()
				->BuildUUIDL(TUUID(TUint16(0x0008))) // OBEX
			->EndListL()
		->EndListL();

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

	return theDb;
	}
Esempio n. 20
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);
}
Esempio n. 21
0
bool CCpu::SingleStep()
{
    ServiceInterruptRequest();
    
    //Save incoming PC to compare with the outgoing one. If they are identical
    //this indicates a "halt" instruction.
    TUint16 incommingPc = iRegMap.iPC;
    
    //Read the instruction, and decode the op code.
    TUint16 inst = iMemMap[iRegMap.iPC++];
    TUint op = Decode::BasicOpCode(inst);
    
    //All opcodes need to read and/or write operand A.
    TUint16& a = Decode::OperandA(iRegMap, iMemMap, Decode::A(inst));
    
    if(op != Decode::EOpCodeSPECIAL)
    {
        //All basic instructions need to read A and read and/or write B.
        TUint16& b = Decode::OperandB(iRegMap, iMemMap, Decode::B(inst));
        
        switch(op)
        {
            case Decode::EOpCodeSET:
            {
                b = a;
                AddCycles(1);
                break;
            }
                
            case Decode::EOpCodeADD:
            {
                TUint32 u32 = TUint32(b) + TUint32(a);
                b = TUint16(u32 & 0xffff);
                iRegMap.iEX = TUint16(u32 >> 16);
                AddCycles(2);
                break;
            }
                
            case Decode::EOpCodeSUB:
            {
                TUint32 u32 = TUint32(b) - TUint32(a);
                b = TUint16(u32 & 0xffff);
                iRegMap.iEX = TUint16(u32 >> 16);
                AddCycles(2);
                break;
            }
                
            case Decode::EOpCodeMUL:
            {
                TUint32 u32 = TUint32(b) * TUint32(a);
                b = TUint16(u32 & 0xffff);
                iRegMap.iEX = TUint16(u32 >> 16);
                AddCycles(2);
                break;
            }
                
            case Decode::EOpCodeMLI:
            {
                TInt32 i32 = TInt32(b) * TInt32(a);
                b = TUint16(i32 & 0x7fff);
                iRegMap.iEX = TUint16(i32 >> 16);
                AddCycles(2);
                break;
            }
                
            case Decode::EOpCodeDIV:
            {
                if(a == 0)
                {
                    b = 0;
                    iRegMap.iEX = 0;
                }
                else
                {
                    b /= a;
                    iRegMap.iEX = TUint16(((TUint32(b) << 16) / TUint32(a)));
                }
                AddCycles(3);
                break;
            }
                
            case Decode::EOpCodeDVI:
            {
                if(a == 0)
                {
                    b = 0;
                    iRegMap.iEX = 0;
                }
                else
                {
                    TInt32 sa = TInt32(a);
                    TInt32 sb = TInt32(b);
                    b = TUint16(sb / sa);
                    iRegMap.iEX = TUint16((sb << 16) / sa);
                }
                AddCycles(3);
                break;
            }
                
            case Decode::EOpCodeMOD:
            {
                if(a == 0)
                {
                    b = 0;
                } 
                else 
                {
                    b = TUint16(TInt32(b) % TInt32(a));
                }
                AddCycles(3);
                break;
            }
                
            case Decode::EOpCodeMDI:
            {
                if(a == 0)
                {
                    b = 0;
                }
                else
                {
                    b = TUint16(TInt32(b) % TInt32(a));
                }
                AddCycles(3);
                break;
            }
                
            case Decode::EOpCodeAND:
            {
                b &= a;
                AddCycles(1);
                break;
            }
                
            case Decode::EOpCodeBOR:
            {
                b |= a;
                AddCycles(1);
                break;
            }
                
            case Decode::EOpCodeXOR:
            {
                b ^= a;
                AddCycles(1);
                break;
            }
                
            case Decode::EOpCodeSHR:
            {
                b >>= a;
                iRegMap.iEX = TUint16(((TUint32(b) << 16) >> TUint32(a)));
                AddCycles(1);
                break;
            }
                
            case Decode::EOpCodeASR:
            {
                TInt32 sb = TInt32(b);
                b = TUint16(sb >> a);
                iRegMap.iEX = TUint16((TInt32(sb) << 16) >> TUint32(a));
                AddCycles(1);
                break;
            }
                
            case Decode::EOpCodeSHL:
            {
                TUint32 u32 = TUint32(b) << TUint32(a);
                b = TUint16(u32 & 0xffff);
                iRegMap.iEX = TUint16(u32 >> 16);
                AddCycles(1);
                break;
            }

            case Decode::EOpCodeIFB:
            {
                if((b & a) == 0)
                {
                    SkipInstructions();
                }
                AddCycles(2);
                break;
            }
                
            case Decode::EOpCodeIFC:
            {
                if((b & a) != 0)
                {
                    SkipInstructions();
                }
                AddCycles(2);
                break;
            }
                
            case Decode::EOpCodeIFE:
            {
                if(b != a)
                {
                    SkipInstructions();
                }
                AddCycles(2);
                break;
            }
                
            case Decode::EOpCodeIFN:
            {
                if(b == a)
                {
                    SkipInstructions();
                }
                AddCycles(2);
                break;
            }
                
            case Decode::EOpCodeIFG:
            {
                if(b <= a)
                {
                    SkipInstructions();
                }
                AddCycles(2);
                break;
            }
                
            case Decode::EOpCodeIFA:
            {
                if(TInt32(b) <= TInt32(a))
                {
                    SkipInstructions();
                }
                AddCycles(2);
                break;
            }
                
            case Decode::EOpCodeIFL:
            {
                if(b >= a)
                {
                    SkipInstructions();
                }
                AddCycles(2);
                break;
            }
                
            case Decode::EOpCodeIFU:
            {
                if(TInt32(b) >= TInt32(a))
                {
                    SkipInstructions();
                }
                AddCycles(2);
                break;
            }
                
            case Decode::EOpCodeADX:
            {
                TUint32 u32 = TUint32(b) + TUint32(a) + TUint32(iRegMap.iEX);
                b = TUint16(u32 & 0xffff);
                iRegMap.iEX = TUint16(u32 >> 16);
                AddCycles(3);
                break;
            }
                
            case Decode::EOpCodeSBX:
            {
                TUint32 u32 = TUint32(b) - TUint32(a) + TUint32(iRegMap.iEX);
                b = TUint16(u32 & 0xffff);
                iRegMap.iEX = TUint16(u32 >> 16);
                AddCycles(3);
                break;
            }
                
            case Decode::EOpCodeSTI:
            {
                b = a;
                iRegMap.iI++;
                iRegMap.iJ++;
                AddCycles(2);
                break;
            }
                
            case Decode::EOpCodeSTD:
            {
                b = a;
                iRegMap.iI--;
                iRegMap.iJ--;
                AddCycles(2);
                break;
            }
                
            default: assert("Unknown basic op code" && false);
        }
    }
Esempio n. 22
0
LOCAL_C TInt WavRecord()
	{
	// Parse the commandline and get a filename to use
	TLex l(CommandLine);
	TParse destinationName;
	if (destinationName.SetNoWild(l.NextToken(),0,0)!=KErrNone)
		{
		Test.Printf(_L("No arg, skipping\r\n"));
		return(KErrArgument);
		}
	Test.Next(_L("Record Wav file"));

	// Open the file for writing
	TInt r;
	RFile destination;
	r = destination.Replace(Fs,destinationName.FullName(),EFileWrite);
	if (r!=KErrNone)
		{
		Test.Printf(_L("Open file for write failed(%d)\n"), r);
		return(r);
		}		
	Test.Printf(_L("File opened for write\r\n"));
	
	Test.Next(_L("Preparing to record"));
	
	// Get the rate
	TLex cl(l.NextToken());
	TUint32 tmpRate;
	TSoundRate rate;
	r = cl.Val(tmpRate,EDecimal);
	if (r == KErrNone && (r=SamplesPerSecondToRate(tmpRate,rate))==KErrNone)
		{
		Test.Printf(_L("Parsed rate: %d\r\n"), tmpRate);
		RecordFormatBuf().iRate = rate;
		}
	else
		{
		Test.Printf(_L("Parse rate failed(%d)\r\n"),r);
		RecordFormatBuf().iRate = ESoundRate32000Hz;
		}

	// Get number of channels
	TLex cl_chan(l.NextToken());
	TUint32 tmpChannels;
	r = cl_chan.Val(tmpChannels,EDecimal);
	if (r == KErrNone)
		{
		Test.Printf(_L("Parsed %d channels\r\n"),tmpChannels);
		RecordFormatBuf().iChannels = tmpChannels;
		}
	else
		{
		Test.Printf(_L("Parse channels failed(%d)\r\n"), r);
		RecordFormatBuf().iChannels = 2;
		}

	RecordFormatBuf().iEncoding = ESoundEncoding16BitPCM;
	
	// Set the record buffer configuration.
	RChunk chunk;
	TTestSharedChunkBufConfig bufferConfig;
	bufferConfig.iNumBuffers=4;
	bufferConfig.iBufferSizeInBytes=RecordBufferSizeInBytes(RecordFormatBuf());
	if (RecordCapsBuf().iRequestMinSize)
		bufferConfig.iBufferSizeInBytes&=~(RecordCapsBuf().iRequestMinSize-1); 	// Keep the buffer length valid for the driver.
	bufferConfig.iFlags=0;	
	PrintBufferConf(bufferConfig,Test);
	TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
	r=RxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk);
	if (r!=KErrNone)
		{
		Test.Printf(_L("Buffer configuration not supported(%d)\r\n"),r);
		return(r);
		}
	
	// Set the audio record configuration.
	RxSoundDevice.SetVolume(KSoundMaxVolume);
	PrintConfig(RecordFormatBuf(),Test);
	r=RxSoundDevice.SetAudioFormat(RecordFormatBuf);
	if (r!=KErrNone)
		{
		Test.Printf(_L("Format not supported\r\n"));
		return(r);
		}

	// Get length in seconds
	TLex cl_seconds(l.NextToken());
	TUint32 tmpSeconds;
	r = cl_seconds.Val(tmpSeconds,EDecimal);
	if (r == KErrNone)
		{
		Test.Printf(_L("Parsed %d seconds\r\n"),tmpSeconds);
		}
	else
		{
		Test.Printf(_L("Parse seconds failed(%d)\r\n"),r);
		tmpSeconds=10;
		}
	TInt bytesToRecord = BytesPerSecond(RecordFormatBuf())*tmpSeconds;	
		
	Test.Next(_L("Recording..."));
	
	// Lay down a file header
	WAVEheader header;
	TPtr8 headerDes((TUint8 *)&header, sizeof(struct WAVEheader), sizeof(struct WAVEheader));

	// "RIFF"
	header.ckID[0] = 'R'; header.ckID[1] = 'I';
	header.ckID[2] = 'F'; header.ckID[3] = 'F';
	// "WAVE"
	header.wave_ckID[0] = 'W'; header.wave_ckID[1] = 'A';
	header.wave_ckID[2] = 'V'; header.wave_ckID[3] = 'E';
	// "fmt "
	header.fmt_ckID[0] = 'f'; header.fmt_ckID[1] = 'm';
	header.fmt_ckID[2] = 't'; header.fmt_ckID[3] = ' ';
	// "data"
	header.data_ckID[0] = 'd'; header.data_ckID[1] = 'a';
	header.data_ckID[2] = 't'; header.data_ckID[3] = 'a';

	header.nChannels		= (TUint16)RecordFormatBuf().iChannels;
	header.nSamplesPerSec	= RateInSamplesPerSecond(RecordFormatBuf().iRate);
	header.nBitsPerSample	= 16;
	header.nBlockAlign		= TUint16((RecordFormatBuf().iChannels == 2) ? 4 : 2);
	header.formatTag		= 1;	// type 1 is PCM
	header.fmt_ckSize		= 16;
	header.nAvgBytesPerSec	= BytesPerSecond(RecordFormatBuf());
	header.data_ckSize		= bytesToRecord;
	header.ckSize			= bytesToRecord + sizeof(struct WAVEheader) - 8;

	Test.Printf(_L("Header rate:%d channels:%d tag:%d bits:%d (%d bytes/s) align %d datalen:%d fmt_ckSize:%d ckSize:%d\r\n"),
			header.nSamplesPerSec, header.nChannels, header.formatTag, header.nBitsPerSample,
			header.nAvgBytesPerSec, header.nBlockAlign, header.data_ckSize, header.fmt_ckSize, header.ckSize, sizeof(struct WAVEheader));

	r = destination.Write(headerDes);

	TRequestStatus stat;
	TInt length;
	TPtrC8 buf;

	TTime startTime;
	startTime.HomeTime();
	
	// Start off by issuing a record request.
	TTime starttime;
	starttime.HomeTime();
	TInt bytesRecorded = 0;
	RxSoundDevice.RecordData(stat,length);

	TInt pausesToDo = 10;
	pausesToDo = 0;
	FOREVER
		{
		// Wait for the outstanding record request to complete.
        User::After(6000);

		User::WaitForAnyRequest();
		if (stat==KRequestPending)
			return(KErrGeneral);

		TTime currentTime;
		currentTime.HomeTime();
		TInt64 elapsedTime = currentTime.Int64()-startTime.Int64();	// us
		TTimeIntervalMicroSecondsBuf timeRecordedBuf;
		if(RxSoundDevice.TimeRecorded(timeRecordedBuf) == KErrNone)
			{
			// Compare TimeRecorded with the actual elapsed time. They should be different, but not drift apart too badly...
			TInt32 offset = TInt32(elapsedTime - timeRecordedBuf().Int64());
			Test.Printf(_L("\telapsedTime - TimeRecorded = %d ms\n"), offset/1000);
			}		
			
		// Check whether the record request was succesful.
		TInt retOffset=stat.Int();
		if (retOffset<0)
			{
			Test.Printf(_L("Record failed(%d)\r\n"),retOffset);
			return(retOffset);
			}
		
		// Successfully recorded another buffer so write the recorded data to the record file and release the buffer.
		buf.Set((const TUint8*)(chunk.Base()+retOffset),length);
		r=destination.Write(buf);
		if (r!=KErrNone)
			{
			Test.Printf(_L("File write failed(%d)\r\n"),r);
			return(r);
			}
		r=RxSoundDevice.ReleaseBuffer(retOffset);
		if (r!=KErrNone)
			{
			Test.Printf(_L("Release buffer failed(%d)\r\n"),r);
			return(r);
			}
		
		Test.Printf(_L("Recorded %d more bytes - %d\r\n"),length,retOffset);

		if((pausesToDo > 0) && (bytesRecorded > bytesToRecord/2))
			{
			--pausesToDo;
			Test.Printf(_L("Pause\r\n"));
			RxSoundDevice.Pause();
			Test.Printf(_L("Paused, sleeping for 0.5 seconds\r\n"));
			User::After(500*1000);
            Test.Printf(_L("Resume\r\n"));
			RxSoundDevice.Resume();
			}
		
		// Check whether we have now recorded all the data. If more to record then queue a further request
		bytesRecorded+=length;
		if (bytesRecorded<bytesToRecord)
		    {
            Test.Printf(_L("RecordData\r\n"));
			RxSoundDevice.RecordData(stat,length);
		    }
		else
			break;
		}
	
	RxSoundDevice.CancelRecordData();	// Stop the driver from recording.
	
	TTime endtime;
	endtime.HomeTime();

	TInt64 elapsedTime = endtime.Int64()-starttime.Int64();	// us
	Test.Printf(_L("Delta time = %d\r\n"),I64LOW(elapsedTime));
	Test.Printf(_L("Seconds in buffer: %d (%d)\r\n"), bytesRecorded / header.nAvgBytesPerSec, (bytesRecorded / header.nAvgBytesPerSec)*1000000);

	if (I64LOW(elapsedTime) <= (bytesRecorded / header.nAvgBytesPerSec)*1000000)
		{
		Test.Printf(_L("Time travelling; record took less time than it should have done\r\n"));
		return(KErrGeneral);
		}
	
	chunk.Close();
	destination.Close();

	Test.Printf(_L("Record finished\r\n"));
	return(KErrNone);
	}
Esempio n. 23
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;
	}
Esempio n. 24
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;
	}