/**
Test MSdpElementBuilder::EndListL()
*/
void CT_DataSdpElementBuilder::DoCmdEndListL(MSdpElementBuilder& aElementBuilder)
{
    iDataWrapper.INFO_PRINTF1(_L("MSdpElementBuilder EndListL Call"));

    TRAPD(err, aElementBuilder.EndListL());
    if(err != KErrNone)
    {
        iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder EndListL failed with error %d"), err);
        iDataWrapper.SetError(err);
    }
}
// ----------------------------------------------------------------------------
// QBtServiceAdvertiserPrivate::StartAdvertiser(const QBtService& service)
//
// start service advertiser on given channel.  an entry to service discovery
// database will be entered describing our advertised service.
// ----------------------------------------------------------------------------
void QBtServiceAdvertiserPrivate::StartAdvertiser (const QBtService& service)
{
   //localService = new QBtService(service);

   // open sdp session
   User::LeaveIfError(iSdp.Connect());

   // open sdp database session
   User::LeaveIfError(iSdpDB.Open(iSdp));

   // create a record of the correct service class
   //QBtUuid uuid = service.getClass();

   TUUID uuid = QBtUuidToSymbianUuid (service.getClass() );
   iSdpDB.CreateServiceRecordL (uuid, iRecord);


   // add a protocol to the record
   CSdpAttrValueDES* protocolDescriptorList = CSdpAttrValueDES::NewDESL(NULL);
   CleanupStack::PushL(protocolDescriptorList);

   TBuf8<1> channel;
   channel.Append((TChar)service.getPort());

   // create protocol list for our service
   MSdpElementBuilder* e = protocolDescriptorList->StartListL();

      QBtService::ProtocolList protocolList = service.getProtocols();
      for (int i=0; i < protocolList.size(); i++)
      {
         e = e->BuildDESL();
         e = e->StartListL();

            TUUID u = QBtUuidToSymbianUuid (protocolList[i]);
            e = e->BuildUUIDL (u);

            if (u == TUUID (KRFCOMM) )
               e = e->BuildUintL(channel);

         e = e->EndListL();
       }

   e->EndListL();

   // set protocol list to the record
   iSdpDB.UpdateAttributeL(iRecord, KSdpAttrIdProtocolDescriptorList,
         *protocolDescriptorList);
   CleanupStack::PopAndDestroy(protocolDescriptorList);


   // add a name to the record
   TPtrC16 servName(service.getName().utf16());

   iSdpDB.UpdateAttributeL(iRecord,
         KSdpAttrIdBasePrimaryLanguage +
         KSdpAttrIdOffsetServiceName,
         servName);


   // add a description to the record
   TPtrC16 servDescr(service.getDescription().utf16());

   iSdpDB.UpdateAttributeL(iRecord,
         KSdpAttrIdBasePrimaryLanguage +
         KSdpAttrIdOffsetServiceDescription,
         servDescr);

   // set service available
   UpdateAvailability(ETrue);

   // notify
   QT_TRYCATCH_LEAVING (emit p_ptr->advertisingStarted(service) );


}
Exemple #3
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;
	}