Пример #1
0
void CReferenceHandler::CreateReferenceObject6L(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(KRef6Name);
    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");
    /*
    	TObexMatchHeader* headerMask = new(ELeave) TObexMatchHeader;

    	headerMask->SetHeader(TObexInternalHeader::EName);
    	aObject.HeaderSet().SetMask(headerMask);
    	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef2HTTP);
    	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef3HTTP);
    	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef3HTTP);
    	if (aObject.Http())
    		{
    		NULL;
    		}
    	aObject.HeaderSet().SetMask(headerMask);
    	aObject.HeaderSet().DeleteMasked();
    	aObject.AddHttpL(KRef3HTTP);
    	aObject.AddHttpL(KRef2HTTP);
    	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef3HTTP);
    	aObject.AddHttpL(KRef3HTTP);
    	if (aObject.Http())
    		{
    		NULL;
    		}
    	aObject.HeaderSet().SetMask(headerMask);
    	aObject.HeaderSet().DeleteMasked();
    	aObject.AddHttpL(KRef2HTTP);
    	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef2HTTP);
    	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef1HTTP);
    	aObject.AddHttpL(KRef3HTTP);


    	if (aObject.Http())
    		{
    		NULL;
    		}

    	aObject.HeaderSet().SetMask(headerMask);
    	aObject.HeaderSet().DeleteMasked();
    	delete headerMask;
    */

    aObject.AddHttpL(KRef3HTTP);
    aObject.AddHttpL(KRef3HTTP);
    aObject.AddHttpL(KRef1HTTP);
    aObject.AddHttpL(KRef2HTTP);
    aObject.AddHttpL(KRef2HTTP);

    /*
    	if (aObject.Http())
    		{
    		NULL;
    		}


    	aObject.HeaderSet().SetMask(NULL);
    */

    // 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  | KObexHdrTime | KObexHdrLength | KObexHdrHttp | KObexHdrTarget | KObexHdrUserDefined );
}
Пример #2
0
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);
}