void CReferenceHandler::CreateReferenceObject2L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport) { //Reset the object (also resets the buffer) aObject.Reset(); const TUint KNumOfObjects = 2; aObjectBuf.ResizeL(KNumOfObjects * 20); //populate the buffer... _LIT8(KRefDesc2, "*Reference Object 2*"); TUint i; for (i=0; i<KNumOfObjects; i++) { aObjectBuf.Write(20*i, KRefDesc2); } //populate the object aObject.SetNameL(KRef2Name); aObject.SetTypeL(KRefType); aObject.SetLengthL(aObjectBuf.Size()); const TTime KRef2Time = TDateTime(2002, EJanuary, 0, 0, 0, 0, 0); aObject.SetTimeL(KRef2Time); // Set up the MF description header const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters HBufC* descBuf = HBufC::NewLC(KDescLength); ASSERT(descBuf); TPtr ptr(descBuf->Des()); ptr.Zero(); for (i=0; i<KDescLength; i++) { ptr.AppendNumFixedWidth(i%10, EDecimal, 1); } aObject.SetDescriptionL(ptr); CleanupStack::PopAndDestroy(descBuf); aObject.SetTargetL(KRefIrMCTarget); aObject.SetHeaderMask(KObexHdrName | KObexHdrType | KObexHdrLength | KObexHdrTime | KObexHdrDescription | KObexHdrTarget); }
void CReferenceHandler::CreateReferenceObject5L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport) { //Reset the object (also resets the buffer) aObject.Reset(); const TUint KNumOfAlphabets = 200; aObjectBuf.ResizeL(KNumOfAlphabets * 30); //populate the buffer... TBuf8<4> buf; TUint i; for (i=0; i<KNumOfAlphabets; i++) { buf.Zero(); buf.AppendNumFixedWidth(i, EDecimal, 4); aObjectBuf.Write(30*i, buf); aObjectBuf.Write(30*i + 4, KAlphabet); } //populate the object aObject.SetNameL(KRef5Name); aObject.SetTypeL(KRefImageJpegType); aObject.SetLengthL(aObjectBuf.Size()); const TTime KRef5Time = TDateTime(2001, EFebruary, 14, 15, 38, 24, 0);//set time to 15:38:24.0 on 14th Feb 2001 - obex doesn't transfer microseconds!! aObject.SetTimeL(KRef5Time); _LIT8(KRef1HTTP, "Accept: text/*"); _LIT8(KRef2HTTP, "Location: http://www.w3.org"); _LIT8(KRef3HTTP, "Date: Tue, 10 Nov 2002 09:17:21 GMT"); aObject.AddHttpL(KRef1HTTP); aObject.AddHttpL(KRef2HTTP); aObject.AddHttpL(KRef3HTTP); // Set up the MF description header const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters HBufC* descBuf = HBufC::NewLC(KDescLength); ASSERT(descBuf); TPtr ptr(descBuf->Des()); ptr.Zero(); for (i=0; i<KDescLength; i++) { ptr.AppendNumFixedWidth(i%10, EDecimal, 1); } aObject.SetDescriptionL(ptr); CleanupStack::PopAndDestroy(descBuf); aObject.SetTargetL(KRefTarget); aObject.SetHeaderMask(KObexHdrName | KObexHdrType | KObexHdrTime | KObexHdrLength | KObexHdrTime | KObexHdrDescription | KObexHdrHttp | KObexHdrTarget); }
void CReferenceHandler::CreateReferenceObject4L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport) { //Reset the object (also resets the buffer) aObject.Reset(); const TUint KNumOfAlphabets = 200; aObjectBuf.ResizeL(KNumOfAlphabets * 30); //populate the buffer... TBuf8<4> buf; TUint i; for (i=0; i<KNumOfAlphabets; i++) { buf.Zero(); buf.AppendNumFixedWidth(i, EDecimal, 4); aObjectBuf.Write(30*i, buf); aObjectBuf.Write(30*i + 4, KAlphabet); } //populate the object aObject.SetNameL(KRef4Name); aObject.SetLengthL(aObjectBuf.Size()); // Set up the MF description header const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters HBufC* descBuf = HBufC::NewLC(KDescLength); ASSERT(descBuf); TPtr ptr(descBuf->Des()); ptr.Zero(); for (i=0; i<KDescLength; i++) { ptr.AppendNumFixedWidth(i%10, EDecimal, 1); } aObject.SetDescriptionL(ptr); CleanupStack::PopAndDestroy(descBuf); aObject.SetTargetL(KRefTarget); TBuf8<40> param; param.Copy(_L("\x04")); param.Append(_L("\x03")); param.Append(_L("App params 456")); aObject.SetAppParamL(param); aObject.SetHeaderMask(KObexHdrName | KObexHdrLength | KObexHdrDescription | KObexHdrTarget | KObexHdrAppParam); }
void CBlueJackImpl::SendMessageL(const TBTDevAddr& aToAddress, const TDesC& aWithDeviceName, const TDesC& aWithMessageName, const TDesC8& aMessage, TInt aConnectCount) { CALLSTACKITEM_N(_CL("CBlueJackImpl"), _CL("SendMessageL")); #ifndef NO_BT iSettings->SetLocalBTName(aWithDeviceName); #endif iBuffer->Reset(); iBuffer->InsertL(0, aMessage); iObject->SetTypeL(_L8("text/plain")); iObject->SetNameL(aWithMessageName); iObject->SetDescriptionL(_L("description of message")); iObex->SendMessage(aToAddress, iObject, aConnectCount); }
void CReferenceHandler::CreateReferenceObject1L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport) { //Reset the object (also resets the buffer) aObject.Reset(); const TUint KNumOfAlphabets = 2; aObjectBuf.ResizeL(KNumOfAlphabets * 30); //populate the buffer... TBuf8<4> buf; TUint i; for (i=0; i<KNumOfAlphabets; i++) { buf.Zero(); buf.AppendNumFixedWidth(i, EDecimal, 4); aObjectBuf.Write(30*i, buf); aObjectBuf.Write(30*i + 4, KAlphabet); } //populate the object aObject.SetNameL(KRef2Name); // check the deletecurrentheader method aObject.SetNameL(KRef1Name); _LIT8(KRef1HTTP, "Accept: text/*"); _LIT8(KRef2HTTP, "Location: http://www.w3.org"); _LIT8(KRef3HTTP, "Date: Tue, 10 Nov 2002 09:17:21 GMT"); // add Http header using old API // /* aObject.AddHttpL(KRef1HTTP); aObject.AddHttpL(KRef1HTTP); aObject.AddHttpL(KRef2HTTP); aObject.AddHttpL(KRef3HTTP); aObject.AddHttpL(KRef1HTTP); aObject.AddHttpL(KRef2HTTP); aObject.AddHttpL(KRef3HTTP); aObject.AddHttpL(KRef1HTTP); aObject.AddHttpL(KRef2HTTP); aObject.AddHttpL(KRef3HTTP); // USE THE HEADER MASK TO REMOVE HTTP HEADERS FROM HEADERSET // THIS DOES NOT REMOVE THE ITEMS FROM iHttp LIST - this tests // the Http() function which should remove items from iHttp list // TObexMatchHeader* headerMask = new(ELeave) TObexMatchHeader; headerMask->SetHeader(TObexInternalHeader::EName); aObject.HeaderSet().SetMask(headerMask); aObject.HeaderSet().DeleteMasked(); aObject.HeaderSet().SetMask(NULL); delete headerMask; */ aObject.AddHttpL(KRef1HTTP); aObject.AddHttpL(KRef1HTTP); aObject.AddHttpL(KRef1HTTP); aObject.AddHttpL(KRef2HTTP); aObject.AddHttpL(KRef3HTTP); /* if (aObject.Http()) { NULL; } */ // add a Count header using new API // CObexHeader* tempheader = CObexHeader::NewL(); CleanupStack::PushL(tempheader); tempheader->SetFourByte(TObexInternalHeader::ECount, 0xFE22FF54); aObject.AddHeaderL(*tempheader); CleanupStack::Pop(tempheader); // add an Http header using new API // tempheader = CObexHeader::NewL(); CleanupStack::PushL(tempheader); tempheader->SetByteSeqL(TObexInternalHeader::EHttp, KRef1HTTP); aObject.AddHeaderL(*tempheader); CleanupStack::Pop(tempheader); aObject.SetTypeL(KRefType); // set again to check header update functionality aObject.SetTypeL(KRefType); aObject.SetLengthL(aObjectBuf.Size()); // set again to check header update functionality aObject.SetLengthL(aObjectBuf.Size()); TBuf8<40> param; param.Copy(_L("\x04")); param.Append(_L("\x03")); param.Append(_L("App params 123")); aObject.SetAppParamL(param); // set again to check header update functionality aObject.SetAppParamL(param); const TTime KRef1Time = TDateTime(2003, EApril, 29, 10, 10, 10, 0); aObject.SetTimeL(KRef1Time); // set again to check header update functionality aObject.SetTimeL(KRef1Time); // Set up the MF description header const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters HBufC* descBuf = HBufC::NewLC(KDescLength); ASSERT(descBuf); TPtr ptr(descBuf->Des()); ptr.Zero(); for (i=0; i<KDescLength; i++) { ptr.AppendNumFixedWidth(i%10, EDecimal, 1); } aObject.SetDescriptionL(ptr); // set again to check header update functionality aObject.SetDescriptionL(ptr); CleanupStack::PopAndDestroy(descBuf); aObject.SetTargetL(KRefTarget); // set again to check header update functionality aObject.SetTargetL(KRefTarget); CObexHeader* header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetUnicodeL(0x30, KRef1Name); aObject.AddHeaderL(*header); CleanupStack::Pop(header); header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetFourByte(TObexInternalHeader::ECreatorID, 0x5F3A2343); aObject.AddHeaderL(*header); CleanupStack::Pop(header); header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetUnicodeL(0x36, KRef5Name); aObject.AddHeaderL(*header); CleanupStack::Pop(header); header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetByteSeqL(TObexInternalHeader::EWanUUID, KRefTarget); aObject.AddHeaderL(*header); CleanupStack::Pop(header); header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetUnicodeL(0x3F, KRef5Name); aObject.AddHeaderL(*header); CleanupStack::Pop(header); header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetByte(0xB0, 0x03); aObject.AddHeaderL(*header); CleanupStack::Pop(header); header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetByte(0xBF, 0x12); aObject.AddHeaderL(*header); CleanupStack::Pop(header); header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetByte(0xBE, 0x12); aObject.AddHeaderL(*header); CleanupStack::Pop(header); header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetFourByte(0xF0, 0x54545454); aObject.AddHeaderL(*header); CleanupStack::Pop(header); // THIS NEXT HEADER IS A NEGATIVE TEST. It should cause a panic // 0x2F header doesnt have a FourByte HI Type. /* header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetFourByte(0x2F, 0x54); aObject.AddHeaderL(*header); CleanupStack::Pop(header); */ header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetFourByte(0xFF, 0x00111243); aObject.AddHeaderL(*header); CleanupStack::Pop(header); header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetByteSeqL(0x73, KRefTarget); aObject.AddHeaderL(*header); CleanupStack::Pop(header); header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetByteSeqL(TObexInternalHeader::EObjectClass, KRefTarget); aObject.AddHeaderL(*header); CleanupStack::Pop(header); aObject.SetHeaderMask(KObexHdrName |KObexHdrType | KObexHdrLength | KObexHdrTime | KObexHdrDescription | KObexHdrTarget | KObexHdrHttp | KObexHdrCount | KObexHdrAppParam | KObexHdrUserDefined | KObexHdrObjectClass | KObexHdrWanUUID | KObexHdrCreatorID); }
void CReferenceHandler::CreateReferenceObject3L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport) { //Reset the object (also resets the buffer) aObject.Reset(); const TUint KNumOfAlphabets = 1000; aObjectBuf.ResizeL(KNumOfAlphabets * 30); //populate the buffer... TBuf8<4> buf; TUint i; for (i=0; i<KNumOfAlphabets; i++) { buf.Zero(); buf.AppendNumFixedWidth(i, EDecimal, 4); aObjectBuf.Write(30*i, buf); aObjectBuf.Write(30*i + 4, KAlphabet); } //populate the object aObject.SetNameL(KRef3Name); aObject.SetTypeL(KRefRichTextType); aObject.SetLengthL(aObjectBuf.Size()); const TTime KRef3Time = TDateTime(2002, EJanuary, 0, 0, 0, 0, 0); aObject.SetTimeL(KRef3Time); // Set up the MF description header const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters HBufC* descBuf = HBufC::NewLC(KDescLength); ASSERT(descBuf); TPtr ptr(descBuf->Des()); ptr.Zero(); for (i=0; i<KDescLength; i++) { ptr.AppendNumFixedWidth(i%10, EDecimal, 1); } aObject.SetDescriptionL(ptr); CleanupStack::PopAndDestroy(descBuf); aObject.SetTargetL(KRefTarget); CObexHeader* header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetUnicodeL(0x30, KRef1Name); aObject.AddHeaderL(*header); CleanupStack::Pop(header); header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetUnicodeL(0x36, KRef5Name); aObject.AddHeaderL(*header); CleanupStack::Pop(header); header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetUnicodeL(0x3F, KRef5Name); aObject.AddHeaderL(*header); CleanupStack::Pop(header); header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetByte(0xB0, 0x03); aObject.AddHeaderL(*header); CleanupStack::Pop(header); header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetByte(0xBF, 0x12); aObject.AddHeaderL(*header); CleanupStack::Pop(header); header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetFourByte(0xF0, 0x54); aObject.AddHeaderL(*header); CleanupStack::Pop(header); // THIS NEXT HEADER IS A NEGATIVE TEST. It should cause a panic // 0x2F header doesnt have a FourByte HI Type. /* header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetFourByte(0x2F, 0x54); aObject.AddHeaderL(*header); CleanupStack::Pop(header); */ header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetFourByte(0xFF, 0x43); aObject.AddHeaderL(*header); CleanupStack::Pop(header); header = CObexHeader::NewL(); CleanupStack::PushL(header); header->SetByteSeqL(0x73, KRefTarget); aObject.AddHeaderL(*header); CleanupStack::Pop(header); aObject.SetHeaderMask(KObexHdrName | KObexHdrType | KObexHdrLength | KObexHdrTime | KObexHdrDescription | KObexHdrTarget | KObexHdrUserDefined); }