|
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 : TTCPMsgState.cpp |
|
15 // Part of : ConnectionMgr |
|
16 // Version : SIP/4.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "TTCPMsgState.h" |
|
22 #include "MMsgAssemblerContext.h" |
|
23 |
|
24 |
|
25 // ---------------------------------------------------------------------------- |
|
26 // TTCPMsgState::TTCPMsgState |
|
27 // ---------------------------------------------------------------------------- |
|
28 // |
|
29 TTCPMsgState::TTCPMsgState( MMsgAssemblerContext& aMsgAssembler ) |
|
30 : iMsgAssembler( aMsgAssembler ) |
|
31 { |
|
32 } |
|
33 |
|
34 // ---------------------------------------------------------------------------- |
|
35 // TTCPMsgState::FindHeaderStartPosition |
|
36 // ---------------------------------------------------------------------------- |
|
37 // |
|
38 TInt TTCPMsgState::FindHeaderStartPosition( TDesC8& aData ) |
|
39 { |
|
40 TLex8 lex(aData); |
|
41 lex.SkipSpace(); |
|
42 return lex.Offset(); |
|
43 } |
|
44 |
|
45 // ---------------------------------------------------------------------------- |
|
46 // TTCPMsgState::FindHeaderEndPosition |
|
47 // ---------------------------------------------------------------------------- |
|
48 // |
|
49 TInt TTCPMsgState::FindHeaderEndPosition( TDesC8& aData ) |
|
50 { |
|
51 _LIT8(KCRLFCRLF, "\r\n\r\n"); |
|
52 _LIT8(KCRCRLF, "\r\r\n"); |
|
53 _LIT8(KLFCRLF, "\n\r\n"); |
|
54 |
|
55 TInt endPosition = KErrNotFound; |
|
56 TInt cRLFCRLFPosition = aData.Find(KCRLFCRLF); |
|
57 TInt cRCRLFPosition = aData.Find(KCRCRLF); |
|
58 TInt lFCRLFPosition = aData.Find(KLFCRLF); |
|
59 |
|
60 if (cRLFCRLFPosition >= 0) |
|
61 { |
|
62 endPosition = cRLFCRLFPosition + KCRLFCRLF().Length(); |
|
63 } |
|
64 |
|
65 if (cRCRLFPosition >= 0) |
|
66 { |
|
67 GetHeaderPartEndPosition(cRCRLFPosition, |
|
68 KCRCRLF().Length(), |
|
69 endPosition); |
|
70 } |
|
71 |
|
72 if (lFCRLFPosition >= 0) |
|
73 { |
|
74 GetHeaderPartEndPosition(lFCRLFPosition, |
|
75 KLFCRLF().Length(), |
|
76 endPosition); |
|
77 } |
|
78 |
|
79 return endPosition; |
|
80 } |
|
81 |
|
82 // ---------------------------------------------------------------------------- |
|
83 // TTCPMsgState::GetHeaderPartEndPosition |
|
84 // ---------------------------------------------------------------------------- |
|
85 // |
|
86 void TTCPMsgState::GetHeaderPartEndPosition ( TInt aEndMarkPosition, |
|
87 TInt aEndMarkLength, |
|
88 TInt& aHeaderEndPosition ) |
|
89 { |
|
90 aEndMarkPosition = aEndMarkPosition + aEndMarkLength; |
|
91 |
|
92 if (aHeaderEndPosition > 0) |
|
93 { |
|
94 if (aEndMarkPosition < aHeaderEndPosition ) |
|
95 { |
|
96 aHeaderEndPosition = aEndMarkPosition; |
|
97 } |
|
98 } |
|
99 else |
|
100 { |
|
101 aHeaderEndPosition = aEndMarkPosition; |
|
102 } |
|
103 } |