MSRP Chat and File Sharing FrameWork - Initial Contribution from Nokia.
MSRP Implementation as per RFC 4975 and RCS specifications that supports
1. Multiple one to one chat data sessions as per RCS/RFC 4975 specifications.
2. Multiple file Sharing sessions as per RCS.
3. Data Chunking requirements as per 4975.
3. MSRP Connection sharing requirements as per RFC 4975
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
// Name : TSIPLogLineParser.cpp
// Part of : Logging
// Version : SIP/2.0
//
#include "TSIPLogLineParser.h"
// -----------------------------------------------------------------------------
// TSIPLogLineParser::TSIPLogLineParser
// -----------------------------------------------------------------------------
//
TSIPLogLineParser::TSIPLogLineParser (const TDesC8& aMessage,
TUint aMaxLineLength)
: iMaxLineLength(aMaxLineLength),
iMessage(aMessage),
iCurrentPos(0)
{
}
// -----------------------------------------------------------------------------
// TSIPLogLineParser::End
// -----------------------------------------------------------------------------
//
TBool TSIPLogLineParser::End ()
{
return (iCurrentPos >= iMessage.Length());
}
// -----------------------------------------------------------------------------
// TSIPLogLineParser::GetLine
// -----------------------------------------------------------------------------
//
TPtrC8 TSIPLogLineParser::GetLine ()
{
if (End()) return TPtrC8();
TPtrC8 ptr(iMessage.Mid(iCurrentPos));
TUint lineEndOffset = 0;
TInt nextLineEndPos = FindNextLineEndPos(ptr,lineEndOffset);
TUint length;
if (nextLineEndPos == KErrNotFound)
{
if (ptr.Length() < iMaxLineLength)
{
length = ptr.Length();
}
else
{
length = iMaxLineLength;
}
}
else
{
if (nextLineEndPos <= iMaxLineLength)
{
length = nextLineEndPos;
iCurrentPos += lineEndOffset;
}
else
{
length = iMaxLineLength;
}
}
iCurrentPos += length;
return ptr.Left(length);
}
// -----------------------------------------------------------------------------
// TSIPLogLineParser::FindNextLineEndPos
// -----------------------------------------------------------------------------
//
TInt TSIPLogLineParser::FindNextLineEndPos (const TDesC8& aDes,
TUint& aLineEndOffset)
{
TInt crPos = aDes.Locate ('\r');
TInt lfPos = aDes.Locate ('\n');
TInt pos = KErrNotFound;
if (!(crPos == KErrNotFound))
{
aLineEndOffset = 1;
if (!(lfPos == KErrNotFound))
{
if (crPos < lfPos)
{
if (crPos+1 == lfPos) aLineEndOffset = 2;
pos = crPos;
}
else
{
pos = lfPos;
}
}
else
{
pos = crPos;
}
}
else
{
if (!(lfPos == KErrNotFound))
{
aLineEndOffset = 1;
pos = lfPos;
}
}
return pos;
}