|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Name : TTCPMsgHeaderStart.cpp |
|
15 // Part of : ConnectionMgr |
|
16 // Implementation |
|
17 // Version : SIP/4.0 |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 #include "TTCPMsgHeaderStart.h" |
|
23 #include "MMsgAssemblerContext.h" |
|
24 |
|
25 // ---------------------------------------------------------------------------- |
|
26 // TTCPMsgHeaderStart::DataReceivedL |
|
27 // ---------------------------------------------------------------------------- |
|
28 // |
|
29 void TTCPMsgHeaderStart::DataReceivedL( TPtr8 aData, TUint& aNextLength ) |
|
30 { |
|
31 // if there are existing data in msg buffer |
|
32 if ( iMsgAssembler.MsgBuffer().Size() > 0 ) |
|
33 { |
|
34 // insert the received data to msg buffer. |
|
35 iMsgAssembler.MsgBuffer().InsertL( |
|
36 iMsgAssembler.MsgBuffer().Size(), aData ); |
|
37 iMsgAssembler.MsgBuffer().Compress(); |
|
38 // delete content of received data. |
|
39 aData.Delete( 0, aData.Length() ); |
|
40 TPtr8 bufPtr = iMsgAssembler.MsgBuffer().Ptr( 0 ); |
|
41 |
|
42 // check if header end mark can be found from msg buffer, |
|
43 // if so, allocate new data from msg buffer, and clear msg buffer |
|
44 // enter to Msg header end state. |
|
45 if (FindHeaderEndPosition( bufPtr ) >= 0) |
|
46 { |
|
47 HBufC8* newData = HBufC8::NewLC( bufPtr.Length() ); |
|
48 // copy the msg buffer data to new data |
|
49 TPtr8 newDataPtr = newData->Des(); |
|
50 newDataPtr.Append( bufPtr ); |
|
51 // clean the msg buffer |
|
52 iMsgAssembler.MsgBuffer().Reset(); |
|
53 iMsgAssembler.MsgBuffer().Compress(); |
|
54 |
|
55 iMsgAssembler.ChangeState( MMsgAssemblerContext::EMsgHeaderEnd ); |
|
56 iMsgAssembler.CurrentState().DataReceivedL( newDataPtr, |
|
57 aNextLength ); |
|
58 CleanupStack::PopAndDestroy(newData); |
|
59 } |
|
60 } |
|
61 else if ( FindHeaderEndPosition( aData ) >= 0 ) |
|
62 { |
|
63 iMsgAssembler.ChangeState( MMsgAssemblerContext::EMsgHeaderEnd ); |
|
64 iMsgAssembler.CurrentState().DataReceivedL( aData, aNextLength ); |
|
65 } |
|
66 // if the header end mark is not found, it means the received data |
|
67 // contains only part of SIP message header, copy the received data to |
|
68 // a buffer and wait for next part of message header |
|
69 else |
|
70 { |
|
71 iMsgAssembler.MsgBuffer().InsertL( |
|
72 iMsgAssembler.MsgBuffer().Size(), aData ); |
|
73 iMsgAssembler.MsgBuffer().Compress(); |
|
74 } |
|
75 } |