# HG changeset patch # User shivsood # Date 1276333211 -19800 # Node ID 505ad3f0ce5cf18f2c4b7c0623a7fb7f1897125e # Parent f1578314b8da3a80cafe2d265a987ad73c846688 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 diff -r f1578314b8da -r 505ad3f0ce5c Msrp/Group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/Group/bld.inf Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +PRJ_PLATFORMS + DEFAULT + + +#include "../MsrpHeader/group/bld.inf" +#include "../MsrpClient/group/bld.inf" +#include "../MsrpServer/group/bld.inf" + + +PRJ_EXPORTS +./msrp.iby CORE_MW_LAYER_IBY_EXPORT_PATH(msrp.iby) +../inc/MsrpCommon.h MW_LAYER_PLATFORM_EXPORT_PATH(MsrpCommon.h) + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/Group/msrp.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/Group/msrp.iby Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + + +#ifndef __MSRP_IBY__ +#define __MSRP_IBY__ + +file=ABI_DIR\urel\msrpserver.exe PROGRAMS_DIR\msrpserver.exe + +file=ABI_DIR\urel\msrpclient.dll SHARED_LIB_DIR\msrpclient.dll + +file=ABI_DIR\urel\msrpheader.dll SHARED_LIB_DIR\msrpheader.dll + + +#endif \ No newline at end of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/bwins/msrpclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/bwins/msrpclientu.def Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,24 @@ +EXPORTS + ?ReceiveFile@CMSRPSession@@QAEHABV?$TBuf@$0BAA@@@HABVTDesC8@@@Z @ 1 NONAME ; int CMSRPSession::ReceiveFile(class TBuf<256> const &, int, class TDesC8 const &) + ?NewL@CMSRPSessionParams@@SAPAV1@XZ @ 2 NONAME ; class CMSRPSessionParams * CMSRPSessionParams::NewL(void) + ?SendFile@CMSRPSession@@QAEHABV?$TBuf@$0BAA@@@ABVTDesC8@@@Z @ 3 NONAME ; int CMSRPSession::SendFile(class TBuf<256> const &, class TDesC8 const &) + ?CancelSending@CMSRPSession@@QAEHAAVTDesC8@@@Z @ 4 NONAME ; int CMSRPSession::CancelSending(class TDesC8 &) + ??1CMSRPSessionParams@@UAE@XZ @ 5 NONAME ; CMSRPSessionParams::~CMSRPSessionParams(void) + ?SuccessReportHeader@CMSRPSessionParams@@QAE?AW4TReportStatus@@XZ @ 6 NONAME ; enum TReportStatus CMSRPSessionParams::SuccessReportHeader(void) + ?NewLC@CMSRP@@SAPAV1@ABVTUid@@@Z @ 7 NONAME ; class CMSRP * CMSRP::NewLC(class TUid const &) + ?Listen@CMSRPSession@@QAEHABVTDesC8@@@Z @ 8 NONAME ; int CMSRPSession::Listen(class TDesC8 const &) + ?SetReportHeadersL@CMSRPSessionParams@@QAEXW4TReportStatus@@0@Z @ 9 NONAME ; void CMSRPSessionParams::SetReportHeadersL(enum TReportStatus, enum TReportStatus) + ?SendBuffer@CMSRPSession@@QAEPAVHBufC8@@ABVTDesC8@@0@Z @ 10 NONAME ; class HBufC8 * CMSRPSession::SendBuffer(class TDesC8 const &, class TDesC8 const &) + ?Connect@CMSRPSession@@QAEHABVTDesC8@@@Z @ 11 NONAME ; int CMSRPSession::Connect(class TDesC8 const &) + ?FailureReportHeader@CMSRPSessionParams@@QAE?AW4TReportStatus@@XZ @ 12 NONAME ; enum TReportStatus CMSRPSessionParams::FailureReportHeader(void) + ??1CMSRP@@UAE@XZ @ 13 NONAME ; CMSRP::~CMSRP(void) + ?CancelReceiveFile@CMSRPSession@@QAEHXZ @ 14 NONAME ; int CMSRPSession::CancelReceiveFile(void) + ?SetSessionParams@CMSRPSession@@QAEXAAVCMSRPSessionParams@@@Z @ 15 NONAME ; void CMSRPSession::SetSessionParams(class CMSRPSessionParams &) + ?CloseMSRPSession@CMSRP@@QAEXPAVCMSRPSession@@@Z @ 16 NONAME ; void CMSRP::CloseMSRPSession(class CMSRPSession *) + ?CancelFileSending@CMSRPSession@@QAEHXZ @ 17 NONAME ; int CMSRPSession::CancelFileSending(void) + ?ConstructL@CMSRP@@AAEXABVTUid@@@Z @ 18 NONAME ; void CMSRP::ConstructL(class TUid const &) + ?LocalMSRPPath@CMSRPSession@@QAEAAVTDesC8@@XZ @ 19 NONAME ; class TDesC8 & CMSRPSession::LocalMSRPPath(void) + ?CreateMSRPSessionL@CMSRP@@QAEPAVCMSRPSession@@AAVMMSRPSessionObserver@@I@Z @ 20 NONAME ; class CMSRPSession * CMSRP::CreateMSRPSessionL(class MMSRPSessionObserver &, unsigned int) + ?NotifyProgress@CMSRPSession@@QAEXH@Z @ 21 NONAME ; void CMSRPSession::NotifyProgress(int) + ?NewL@CMSRP@@SAPAV1@ABVTUid@@@Z @ 22 NONAME ; class CMSRP * CMSRP::NewL(class TUid const &) + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/eabi/msrpclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/eabi/msrpclientu.def Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,48 @@ +EXPORTS + _ZN12CMSRPSession10SendBufferERK6TDesC8S2_ @ 1 NONAME + _ZN12CMSRPSession11ReceiveFileERK4TBufILi256EEiRK6TDesC8 @ 2 NONAME + _ZN12CMSRPSession13CancelSendingER6TDesC8 @ 3 NONAME + _ZN12CMSRPSession13LocalMSRPPathEv @ 4 NONAME + _ZN12CMSRPSession14NotifyProgressEi @ 5 NONAME + _ZN12CMSRPSession16SetSessionParamsER18CMSRPSessionParams @ 6 NONAME + _ZN12CMSRPSession17CancelFileSendingEv @ 7 NONAME + _ZN12CMSRPSession17CancelReceiveFileEv @ 8 NONAME + _ZN12CMSRPSession6ListenERK6TDesC8 @ 9 NONAME + _ZN12CMSRPSession7ConnectERK6TDesC8 @ 10 NONAME + _ZN12CMSRPSession8SendFileERK4TBufILi256EERK6TDesC8 @ 11 NONAME + _ZN18CMSRPSessionParams17SetReportHeadersLE13TReportStatusS0_ @ 12 NONAME + _ZN18CMSRPSessionParams19FailureReportHeaderEv @ 13 NONAME + _ZN18CMSRPSessionParams19SuccessReportHeaderEv @ 14 NONAME + _ZN18CMSRPSessionParams4NewLEv @ 15 NONAME + _ZN18CMSRPSessionParamsD0Ev @ 16 NONAME + _ZN18CMSRPSessionParamsD1Ev @ 17 NONAME + _ZN18CMSRPSessionParamsD2Ev @ 18 NONAME + _ZN5CMSRP10ConstructLERK4TUid @ 19 NONAME + _ZN5CMSRP16CloseMSRPSessionEP12CMSRPSession @ 20 NONAME + _ZN5CMSRP18CreateMSRPSessionLER20MMSRPSessionObserverj @ 21 NONAME + _ZN5CMSRP4NewLERK4TUid @ 22 NONAME + _ZN5CMSRP5NewLCERK4TUid @ 23 NONAME + _ZN5CMSRPD0Ev @ 24 NONAME + _ZN5CMSRPD1Ev @ 25 NONAME + _ZN5CMSRPD2Ev @ 26 NONAME + _ZTI12CMSRPSession @ 27 NONAME + _ZTI12RMSRPSession @ 28 NONAME + _ZTI17CMSRPListenerBase @ 29 NONAME + _ZTI18CMSRPSessionParams @ 30 NONAME + _ZTI19CMSRPImplementation @ 31 NONAME + _ZTI21CMSRPIncomingListener @ 32 NONAME + _ZTI23CMSRPConnectionListener @ 33 NONAME + _ZTI23CMSRPSendResultListener @ 34 NONAME + _ZTI26CMSRPSessionImplementation @ 35 NONAME + _ZTI5CMSRP @ 36 NONAME + _ZTV12CMSRPSession @ 37 NONAME + _ZTV12RMSRPSession @ 38 NONAME + _ZTV17CMSRPListenerBase @ 39 NONAME + _ZTV18CMSRPSessionParams @ 40 NONAME + _ZTV19CMSRPImplementation @ 41 NONAME + _ZTV21CMSRPIncomingListener @ 42 NONAME + _ZTV23CMSRPConnectionListener @ 43 NONAME + _ZTV23CMSRPSendResultListener @ 44 NONAME + _ZTV26CMSRPSessionImplementation @ 45 NONAME + _ZTV5CMSRP @ 46 NONAME + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/group/MSRPClient.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/group/MSRPClient.mmp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + + + +TARGET msrpclient.dll +TARGETTYPE dll +UID 0x1000008d 0x2002B59C + +OS_LAYER_SYSTEMINCLUDE +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../../inc +USERINCLUDE ../inc +USERINCLUDE ../../MsrpHeader/inc + +SOURCEPATH ../src +SOURCE CMSRP.cpp +SOURCE CMSRPImplementation.cpp +SOURCE CMSRPSession.cpp +SOURCE CMSRPSessionImplementation.cpp +SOURCE CMSRPSessionParams.cpp +SOURCE RMSRP.cpp +SOURCE RMSRPSession.cpp +SOURCE CMSRPListenerBase.cpp +SOURCE CMSRPConnectionListener.cpp +SOURCE CMSRPIncomingListener.cpp +SOURCE CMSRPSendResultListener.cpp + + + +// In order to use .def files to freeze code you must use one or more DEFFILE lines; +// see the ones commented out below for examples. +// By default, the build tools look for the WINSCW def file in a BWINS directory +// (at the same level as the directory containing the mmp file), +// the GCC ARM def file in a BMARM directory, and the ARMV5 def file in a EABI directory. +// If your .def files are stored in these default locations, you can simply specify the +// .def filename(s) with no path. If you want to store .def files in non-default +// locations, you will need to specify the paths in the DEFFILE statement(s). + +//The following commented out code shows how the build system uses the implicit +// location for defiles. To create the DEF files Choose Project > Freeze Exports from Carbide +// or run 'abld freeze' from the command-line +//#if defined (WINS) +// DEFFILE ..\bwins\MSRPClient.def +//#elif defined (GCC32) +// DEFFILE ..\bmarm\MSRPClient.def +//#else +// DEFFILE ..\eabi\MSRPClient.def +//#endif + +CAPABILITY All -Tcb + +LIBRARY euser.lib +LIBRARY msrpheader.lib +LIBRARY inetprotutil.lib +LIBRARY estor.lib +LIBRARY bafl.lib + +DEBUGLIBRARY flogger.lib + +#ifdef ENABLE_ABIV2_MODE +DEBUGGABLE_UDEBONLY +#endif + +EXPORTUNFROZEN + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/group/bld.inf Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +../inc/CMSRP.h MW_LAYER_PLATFORM_EXPORT_PATH(CMSRP.h) +../inc/CMSRPSession.h MW_LAYER_PLATFORM_EXPORT_PATH(CMSRPSession.h) +../inc/MMSRPSessionObserver.h MW_LAYER_PLATFORM_EXPORT_PATH(MMSRPSessionObserver.h) +../inc/CMSRPSessionParams.h MW_LAYER_PLATFORM_EXPORT_PATH(CMSRPSessionParams.h) + + +PRJ_MMPFILES +msrpclient.mmp \ No newline at end of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/inc/CMSRP.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/inc/CMSRP.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// This file defines the API for MSRPClient.dll + +#ifndef CMSRP_H_ +#define CMSRP_H_ + +// @platform + +// Include Files + +#include +#include + + +// Forward Declarations +class CMSRPSession; +class CMSRPImplementation; +class MMSRPSessionObserver; + + +// Class declaration. +class CMSRP : public CBase + { +public: + + /** + * Object Creation + * @param aUid the UID of the application that is set by the client + */ + IMPORT_C static CMSRP* NewL( const TUid& aUid ); + + /** + * Object Creation + * @param aUid the UID of the application that is set by the client + */ + IMPORT_C static CMSRP* NewLC( const TUid& aUid ); + + IMPORT_C ~CMSRP(); + + /** + * Creates an msrp session for the client + * @param aObserver a reference to the session observer created by the client. + * This client-side observer receives callbacks from the msrp stack, in order to + * notify it of varous events + * @param aIapId the IAP on which the connection has to start for this session + * @return the created session object which can be used by the client + */ + IMPORT_C CMSRPSession* CreateMSRPSessionL( MMSRPSessionObserver& aObserver, + const TUint aIapId ); + + /** + * Closes the msrp session that the client had created. + * All the resources associated with the session are freed + * @param aMsrpSession the session that needs to be closed + */ + IMPORT_C void CloseMSRPSession( CMSRPSession* aMsrpSession ); + +private: + + void ConstructL( const TUid& aUid ); + +private: + + CMSRPImplementation* iMSRPImpl; + + }; + +#endif // CMSRP_H_ + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/inc/CMSRPConnectionListener.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/inc/CMSRPConnectionListener.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPCONNECTIONLISTENER_H_ +#define CMSRPCONNECTIONLISTENER_H_ + + +// INCLUDES +#include "CMSRPListenerBase.h" + +// CONSTANTS + +// FORWARD DECLARATIONS +class CMsrpListenerBase; +class CMSRPSessionImplementation; +class MMSRPServerInterface; + + +// CLASS DECLARATION + +/* + * The active object for all connection related events + */ + +class CMSRPConnectionListener : public CMSRPListenerBase + { +public: + + static CMSRPConnectionListener* NewL(CMSRPSessionImplementation& aSessionImpl, + MMSRPServerInterface& aServerInterface); + + virtual ~CMSRPConnectionListener(); + +public: + + void ConnectL( const TDesC8& aRemoteHost, + const TUint aRemotePort, + const TDesC8& aRemoteSessionID ); + +protected: //from base class + + // CActive + void RunL(); + void DoCancel(); + +private: + CMSRPConnectionListener( CMSRPSessionImplementation& aSessionImpl, + MMSRPServerInterface& aServerInterface ); + + }; + +#endif /* CMSRPCONNECTIONLISTENER_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/inc/CMSRPImplementation.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/inc/CMSRPImplementation.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPIMPLEMENTATION_H_ +#define CMSRPIMPLEMENTATION_H_ + +// @internal + +// System Includes +#include + +// Forward Declarations +class CMSRPSession; +class CMSRP; +class MMSRPSessionObserver; +class RMSRP; + + +class CMSRPImplementation : public CBase + { +public: + + static CMSRPImplementation* NewL( const TUid& aUid ); + + static CMSRPImplementation* NewLC( const TUid& aUid ); + + ~CMSRPImplementation(); + + CMSRPSession* CreateMSRPSessionL( MMSRPSessionObserver& aObserver, + const TUint aIapId ); + + void CloseMSRPSession( CMSRPSession* aMsrpSession ); + +private: + + CMSRPImplementation( const TUid& aUid ); + + void ConstructL(); + +private: + + TUid iUid; + + RMSRP* iMSRP; + + //Array of MSRP sessions that it is serving + RPointerArray iMSRPSessionsArray; + + }; +#endif /* CMSRPIMPLEMENTATION_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/inc/CMSRPIncomingListener.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/inc/CMSRPIncomingListener.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPINCOMINGLISTENER_H_ +#define CMSRPINCOMINGLISTENER_H_ + + +// INCLUDES + +// FORWARD DECLARATIONS +class CMsrpListenerBase; +class CMSRPSessionImplementation; +class MMSRPServerInterface; + + + +/** +* The active object handler for incoming messages +*/ +class CMSRPIncomingListener : public CMSRPListenerBase + { +public: + + static CMSRPIncomingListener* NewL( + CMSRPSessionImplementation& aSessionImpl, + MMSRPServerInterface& aServerInterface ); + + + virtual ~CMSRPIncomingListener(); + +public: + + void ListenConnections( const TDesC8& aRemoteHost, + const TUint aRemotePort, + const TDesC8& aRemoteSessionID ); + + void ListenMessages( ); + +protected: //From base classes + + // From CActive + void RunL(); + void DoCancel(); + +private: + + CMSRPIncomingListener( + CMSRPSessionImplementation& aSessionImpl, + MMSRPServerInterface& aServerInterface ); + +private: + + // incoming connection or message + TBool iIsMessage; + + }; + + +#endif /* CMSRPINCOMINGLISTENER_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/inc/CMSRPListenerBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/inc/CMSRPListenerBase.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPLISTENERBASE_H_ +#define CMSRPLISTENERBASE_H_ + +// EXTERNAL INCLUDES + +// CONSTANTS + +// FORWARD DECLARATIONS +class CMSRPSessionImplementation; +class MMSRPServerInterface; + +// CLASS DECLARATION +/** +* Class provides a generic base class for all listeners +*/ +class CMSRPListenerBase : public CActive + { +public: // Constructors and destructors + + /** + * Destructor, deletes the resources of CMSRPListenerBase. + */ + virtual ~CMSRPListenerBase(); + +protected: // Constructors + + /** + * Constructor + */ + CMSRPListenerBase( CMSRPSessionImplementation& aSessionImpl, + MMSRPServerInterface& aServerInterface, + TInt aPriority ); + +protected: // data + + CMSRPSessionImplementation& iSessionImpl; + + // interface to MSRP server + MMSRPServerInterface& iServerInterface; + }; + + +#endif /* CMSRPLISTENERBASE_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/inc/CMSRPSendResultListener.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/inc/CMSRPSendResultListener.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPSENDRESULTLISTENER_H_ +#define CMSRPSENDRESULTLISTENER_H_ + + +// INCLUDES +#include "CMsrpListenerBase.h" + + +// FORWARD DECLARATIONS +class CMsrpListenerBase; +class CMSRPSessionImplementation; +class MMSRPServerInterface; + + +/** +* The active object handler for listening to the result of a SendMessage +*/ +class CMSRPSendResultListener : public CMSRPListenerBase + { +public: + + static CMSRPSendResultListener* NewL( + CMSRPSessionImplementation& aSessionImpl, + MMSRPServerInterface& aServerInterface, + const TDesC8& aSessionId ); + + virtual ~CMSRPSendResultListener(); + +public: + + void ListenSendResultL( ); + +protected: //From base classes + + //From CActive + void RunL(); + void DoCancel(); + +private: + + CMSRPSendResultListener( CMSRPSessionImplementation& aSessionImpl, + MMSRPServerInterface& aServerInterface, + const TDesC8& aSessionID ); + +private: + + TBuf8< KMaxLengthOfSessionId > iSessionID; + + }; + + +#endif /* CMSRPSENDRESULTLISTENER_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/inc/CMSRPSession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/inc/CMSRPSession.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,140 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPSESSION_H_ +#define CMSRPSESSION_H_ + +// System Includes +#include + +// Forward Declarations +class CMSRPSessionImplementation; +class MMSRPSessionObserver; +class RMSRP; +class CMSRPMessage; +class CMSRPSessionParams; + + +class CMSRPSession : public CBase + { + friend class CMSRPImplementation; + +public: + + /** + * Object Creation. This is not exported to the client. It is called + * while attempting to create an msrp session. + * @param aRMSRP an instance of the client server session + * @param aObserver the session observer that is created by the client + * @param aIapId IAP id of the application + * @return session object + */ + static CMSRPSession* NewL( RMSRP& aRMSRP, + MMSRPSessionObserver& aObserver, + const TUint aIapId ); + + /** + * Object Creation. This is not exported to the client. It is called + * while attempting to create an msrp session. + * @param aRMSRP an instance of the client server session + * @param aObserver the session observer that is created by the client + * @param aIapId IAP id of the application + * @return session object + */ + static CMSRPSession* NewLC( RMSRP& aRMSRP, + MMSRPSessionObserver& aObserver, + const TUint aIapId ); + +public: + + // === Post Creation; SDP negotiation parameter fetching. + + /** + * Gives the local MSRP path that is used in the "a" line of SDP + * @return local msrp path + */ + IMPORT_C TDesC8& LocalMSRPPath(); + + /** + * Sets the various parameters related to an MSRP session + * @param aSessionParams the session settings object from which the + * settings need to be incorporated into the msrp session. + * Eg. SR and FR report headers can be set using this + */ + IMPORT_C void SetSessionParams( CMSRPSessionParams& aSessionParams ); + + + // === Post SDP Negotiation; Connection Setup. + + /** + * Connects to the remote node + * @param aRemoteMsrpPath the msrp path of the remote node + * This is obtained through the SDP negotiation + * @return KErrNone or system wide error codes + */ + IMPORT_C TInt Connect( const TDesC8& aRemoteMsrpPath ); + + /** + * Listens for connections from the remote node + * @param aRemoteMsrpPath the msrp path of the remote node + * This is obtained through the SDP negotiation + * @return KErrNone or system wide error codes + */ + IMPORT_C TInt Listen ( const TDesC8& aRemoteMsrpPath ); + + + // === Post Connection setup; Data Trasfer. + + /** + * Sends a message to the remote note that is connected + * @param aMessage the data that needs to be sent + * @param aMimeType the mime type of the data + * @return the id of the message that was sent by the msrp stack + */ + IMPORT_C HBufC8* SendBuffer( const TDesC8& aMessage, const TDesC8& aMimeType ); + + /** + * Cancels the send operation initiated by the client + * @param aMessageId the id of the message that needs to be cancelled + * @return KErrNone or system wide error codes + */ + IMPORT_C TInt CancelSending( TDesC8& aMessageId ); + + IMPORT_C TInt SendFile( const TFileName& aFileName, const TDesC8& aMimeType ); + + IMPORT_C TInt CancelFileSending(); + + IMPORT_C TInt ReceiveFile(const TFileName& aFileName,const TInt aFileSize, const TDesC8& aMimeType ); + + IMPORT_C TInt CancelReceiveFile(); + + IMPORT_C void NotifyProgress(TBool aFlag); + + +private: + void ConstructL( RMSRP& aRMSRP, + MMSRPSessionObserver& aObserver, + const TUint aIapId ); + + ~CMSRPSession(); + +private: + + CMSRPSessionImplementation* iMSRPSessionImpl; + + }; + +#endif /* CMSRPSESSION_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/inc/CMSRPSessionImplementation.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/inc/CMSRPSessionImplementation.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,133 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPSESSIONIMPLEMENTATION_H_ +#define CMSRPSESSIONIMPLEMENTATION_H_ + +// INCLUDES +#include "MsrpCommon.h" + +// Forward declarations. +class CMSRP; +class MMSRPSessionObserver; +class CUri8; +class RMSRPSession; +class CMSRPConnectionListener; +class CMSRPIncomingListener; +class CMSRPSendResultListener; +class CMSRPMessage; +class RMSRP; +class CMSRPSessionParams; + + +class CMSRPSessionImplementation : public CBase + { +public: + static CMSRPSessionImplementation* NewL( RMSRP& aRMSRP, + MMSRPSessionObserver& aObserver, + const TUint aIapId ); + + static CMSRPSessionImplementation* NewLC( RMSRP& aRMSRP, + MMSRPSessionObserver& aObserver, + const TUint aIapId ); + + ~CMSRPSessionImplementation(); + +public: + + TDesC8& LocalMSRPPath(); + + void SetSessionParams( CMSRPSessionParams& aSessionParams ); + + void ConnectL( const TDesC8& aRemoteMsrpPath ); + + void ListenL( const TDesC8& aRemoteMsrpPath ); + + HBufC8* SendBufferL( const TDesC8& aMessage, const TDesC8& aMimeType ); + + void CancelSendingL( TDesC8& aMessageId ); + + + void ConnectionEstablishedL( TInt aStatus ); + + void HandleIncomingMessageL( const TDesC8& aIncomingMessage, + TInt aStatus ); + void ReceiveProgress(TInt aBytesReceived, TInt aTotalBytes); + + void SendProgress(TInt aBytesSent, TInt aTotalBytes); + + void SendStatusL( TInt aStatus, const TDesC8& aMessageid ); + + void HandleConnectionErrors( TInt aErrorStatus ); + + void SendFileL( const TFileName& aFileName,const TDesC8& aMimeType ); + + void NotifyProgress(TBool aFlag); + + void ReceiveFileL(const TFileName& aFileName,const TInt aFileSize, const TDesC8& aMimeType); + +private: + + CMSRPMessage* CreateMsrpMessageL( const TDesC8& aMessage, const TDesC8& aToPath, + const TDesC8& aFromPath, const TDesC8& aMimeType ); + + void SendMessageL( CMSRPMessage* aMessage ); + + void GetRemotePathComponentsL( TPtrC8& aRemoteHost, TUint& aRemotePort, TPtrC8& aRemoteSessionID ); + + CMSRPMessage* SetFileParamsL(const TFileName& aFileName,const TDesC8& aToPath, + const TDesC8& aFromPath, + const TDesC8& aMimeType ); +private: + + CMSRPSessionImplementation( RMSRP& aRMSRP, + MMSRPSessionObserver& aObserver ); + + void ConstructL( const TUint aIapId ); + +private: + + RMSRP& iRMSRP; + + MMSRPSessionObserver& iSessionObserver; + + RMSRPSession* iMSRPSession; + + RBuf8 iLocalMsrpPath; + + RBuf8 iRemoteMsrpPath; + + TReportStatus iSuccessReport; + + TReportStatus iFailureReport; + + TBuf8< KMaxLengthOfIncomingMessageExt > iExtMessageBuffer; + + CMSRPConnectionListener* iConnectionListener; + + CMSRPIncomingListener* iIncomingListener; + + CMSRPSendResultListener* iSendResultListener; + + RPointerArray< CMSRPMessage > iSentMessages; + + TBool iProgress; + + TBool isSendFile; + TBool isReceiveFile; + }; + +#endif /* CMSRPSESSIONIMPLEMENTATION_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/inc/CMSRPSessionParams.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/inc/CMSRPSessionParams.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPSESSIONPARAMS_H_ +#define CMSRPSESSIONPARAMS_H_ + + +class CMSRPSessionParams : public CBase + { +public: + + /** + * Creates the CMSRPSessionParams object required to set + * some of the msrp session parameters + */ + IMPORT_C static CMSRPSessionParams* NewL( ); + + IMPORT_C ~CMSRPSessionParams(); + +public: + + /** + * Sets the Success and Failure Report headers in the msrp message. + * This can be done at any point of time in an msrp session when there + * is a need to change these headers. + * @param aSuccessReport Success Report header value EYes/ENo + * @param aFailureReport Failure Report header value EYEs/ENo/EPartial + * Giving the default values will not include the header in the message + * SR value ignored as of now since REPORTs are not supported + * SR header never addded in outgoing message + */ + IMPORT_C void SetReportHeadersL( TReportStatus aSuccessReport, TReportStatus aFailureReport ); + + /** + * Fetches the value of the Success Report header + * @return SR header value + */ + IMPORT_C TReportStatus SuccessReportHeader( ); + + /** + * Fetches the value of the Failure Report header + * @return FR header value + */ + IMPORT_C TReportStatus FailureReportHeader( ); + +private: + CMSRPSessionParams( ); + +private: + + TReportStatus iSuccessReport; + TReportStatus iFailureReport; + + }; + + +#endif /* CMSRPSESSIONPARAMS_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/inc/MMSRPServerInterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/inc/MMSRPServerInterface.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef MMSRPSERVERINTERFACE_H_ +#define MMSRPSERVERINTERFACE_H_ + + +// INCLUDES +#include "MsrpCommon.h" + +// FORWARD DECLARATIONS + +// CLASS DECLARATION + +/** +* An interface to be implemented by RMSRPSession class +* Interface allows communication to and from the MSRP server +*/ +class MMSRPServerInterface + { +public: + + virtual void GetLocalPathL( TDes8 &aLocalHost, + TDes8 &aSessionID ) = 0; + + virtual void Connect( const TDesC8& aRemoteHost, + const TUint aRemotePort, + const TDesC8& aRemoteSessionID, + TRequestStatus& aStatus ) = 0; + + virtual void ListenConnections( const TDesC8& aRemoteHost, + const TUint aRemotePort, + const TDesC8& aRemoteSessionID, + TBool aIsMessage, + TRequestStatus& aStatus ) = 0; + + virtual void ListenMessages( TBool aIsMessage, + TRequestStatus& aStatus ) = 0; + + virtual void ListenSendResult( const TDesC8& aSessionID, + TRequestStatus& aStatus) = 0; + + virtual TInt SendMessage( TDesC8& aMessageBuffer ) = 0; + + virtual TInt CancelSending( TDesC8& aMessageId ) = 0; + + virtual void CancelReceiving( ) = 0; + virtual void CancelSendResultListening( ) = 0; + + virtual const TDesC8& GetMessageIdOfSentMessage() const = 0 ; + virtual TInt GetStatusOfSentMessage() const = 0 ; + virtual TInt GetStatusOfReceivedMessage() const = 0; + virtual const TDesC8& GetReceivedMessage() const = 0; + + virtual TBool GetListenProgress() const = 0; + virtual TInt GetBytesReceived() const = 0; + virtual TInt GetTotalBytesReceived() const = 0; + + virtual TBool GetSendProgress() const = 0; + virtual TInt GetBytesSent() const = 0; + virtual TInt GetTotalBytes() const = 0; + + }; + +#endif /* MMSRPSERVERINTERFACE_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/inc/MMSRPSessionObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/inc/MMSRPSessionObserver.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,105 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef MMSRPSESSIONOBSERVER_H_ +#define MMSRPSESSIONOBSERVER_H_ + +// INCLUDES +#include "MsrpCommon.h" + +// FORWARD DECLARATIONS +class CMSRPMessage; + + +class MMSRPSessionObserver + { + public: + + /** + * An MSRP SEND request has been received from the network. + * The content of the request is given to the client, along with the + * status of receiving the request. Ownership of the content is transferred. + * @param aMessageContent the received message content + * @param aStatus KErrNone with complete message, KErrCancel if terminated + */ + virtual void IncomingMessage( HBufC8* aMessageContent, TInt aStatus ) = 0; + + /** + * An MSRP REPORT request has been received from the network. + * This function is called to notify the client that a recipient wishes + * to indicate a range of bytes as received, or to indicate an error. + * However, it is the client's responsibility to handle this information. + * @param aStatus status code from the REPORT request + * @param aRangeStart start of the byte range being reported + * @param aRangeEnd end of the byte range being reported + * @param aTotal total number of bytes in the message + * NOTE: This callback not issued currently, REPORTs support not present + */ + virtual void IncomingReport( TInt aStatus, TInt aRangeStart, + TInt aRangeEnd, TInt aTotal ) = 0; + + /** + * Result of the send operation initiated by the client + * @param aStatus error code as defined in MsrpCommon::TErrorCode + * @param aMessageId message identifier of the sent message that + * was returned by the SendBuffer call + */ + virtual void SendResult( TInt aStatus, const TDesC8& aMessageid ) = 0; + + /** + * Indicates a failure in connection establishment + * or in case of any error in an established connection + * @param aStatus a system wide error code + */ + virtual void ListenPortFailure( TInt aStatus ) = 0; + + /** + * Result of the connection attempt made by the client. This callback is + * issued, both while initiating a connection with ConnectL and while + * receiving a connection with ListenL, once the call completes. + * Client must wait for this callback before trying to send out any + * messages to the remote user. + * @param aStatus KErrNone or a system wide error code + */ + virtual void ConnectStatus( TInt aStatus ) = 0; + + /** + * Notifies that the entire file has been sent successfully + */ + virtual void SendFileNotification(TBool aStatus) = 0; + + /** + * Notifies that the entire file has been received successfully + */ + virtual void ReceiveFileNotification(TBool status) = 0; + + /** + * File data transfer progress. returns the progress of data transfer + * @param aTransferred number of bytes transferred + * @param aTotal Total amount of bytes to be transferred + */ + virtual void FileSendProgress( TInt aTransferred, TInt aTotal ) = 0; + + /** + * File receive progress, number of bytes received from incoming data + * @param aReceived number of bytes received + * @param aTotal Total amount of bytes to be received + */ + virtual void FileReceiveProgress( TInt aReceived, TInt aTotal ) = 0; + + }; + +#endif /* MMSRPSESSIONOBSERVER_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/inc/RMSRP.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/inc/RMSRP.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef RMSRP_H_ +#define RMSRP_H_ + + +// Include Files + +#include +#include + +// Forward Declarations + +// Class declaration + +class RMSRP : public RSessionBase + { +public: + /** + * constructor. + */ + RMSRP(); + +public: + /** + * Opens a Session to MSRP Server + * @return Status of the operation + */ + TInt CreateServerSession(); + + /** + * The client API version. + */ + TVersion Version() const; + +private: + /** + * Starts the MSRP server + * @return Status indicating whether server was started + */ + TInt StartServer() const; + +private: + + }; + + +#endif /* RMSRP_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/inc/RMSRPSession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/inc/RMSRPSession.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,120 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef RMSRPSESSION_H_ +#define RMSRPSESSION_H_ + + +// Include Files +#include +#include + +// INCLUDES +#include "MMSRPServerInterface.h" + + +// Forward Declarations +class RMSRP; + + +// Class declaration + +class RMSRPSession : public RSubSessionBase, public MMSRPServerInterface + { +public: + /** + * constructor. + */ + RMSRPSession(); + +public: // New functions + /** + * Opens a Sub-Session to MSRP Server + * @return Status of the operation + */ + TInt CreateServerSubSession( RMSRP& aRMSRP, + const TUint32 aIapId ); + + void CloseServerSubSession( ); + + +public: // From base class + + // From MMSRPServerInterface + + void GetLocalPathL( TDes8 &aLocalHost, + TDes8 &aSessionID ); + + void Connect( const TDesC8& aRemoteHost, + const TUint aRemotePort, + const TDesC8& aRemoteSessionID, + TRequestStatus& aStatus ); + + void ListenConnections( const TDesC8& aRemoteHost, + const TUint aRemotePort, + const TDesC8& aRemoteSessionID, + TBool aIsMessage, + TRequestStatus& aStatus ); + + void ListenMessages( TBool aIsMessage, + TRequestStatus& aStatus ); + + void ListenSendResult( const TDesC8& aSessionID, + TRequestStatus& aStatus ); + + TInt SendMessage( TDesC8& aMessageBuffer ); + + TInt CancelSending( TDesC8& aMessageId ); + + void CancelReceiving( ); + void CancelSendResultListening( ); + + const TDesC8& GetMessageIdOfSentMessage( ) const; + TInt GetStatusOfSentMessage( ) const; + TInt GetStatusOfReceivedMessage( ) const; + const TDesC8& GetReceivedMessage( ) const; + + TBool GetListenProgress() const; + TInt GetBytesReceived() const; + TInt GetTotalBytesReceived() const; + + TBool GetSendProgress() const; + TInt GetBytesSent() const; + TInt GetTotalBytes() const; + + + TInt SendFileL(TDesC8& aFileParamBuffer); + TInt ReceiveFileL(TDesC8& aFileParamBuffer); +private: //variables + + // Local path data to be recived from the server + TPckgBuf< TLocalPathMSRPData > iLocalPathMSRPDataPckg; + + // Connection data to be sent to server + TPckgBuf< TConnectMSRPData > iConnectMSRPDataPckg; + + // Message sending data to be sent to server + TPckgBuf< TSendMSRPData > iSendMSRPDataPckg; + + // Listen for incoming messages data package + TPckgBuf< TListenMSRPData > iListenMSRPDataPckg; + + // Listen for response to sent messages data package + TPckgBuf< TListenSendResultMSRPData > iSendResultListenMSRPDataPckg; + + }; + +#endif /* RMSRPSESSION_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/src/CMSRP.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/src/CMSRP.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// Include Files +#include "MsrpCommon.h" +#include "CMSRP.h" +#include "CMSRPImplementation.h" + + +// Member Functions + +EXPORT_C CMSRP* CMSRP::NewL( const TUid& aUid ) + { + MSRPLOG("CMSRP.. NewL"); + CMSRP* self = CMSRP::NewLC(aUid); + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CMSRP* CMSRP::NewLC( const TUid& aUid ) + { + MSRPLOG("CMSRP.. NewLC"); + CMSRP* self = new (ELeave) CMSRP; + CleanupStack::PushL(self); + self->ConstructL(aUid); + return self; + } + +EXPORT_C void CMSRP::ConstructL( const TUid& aUid ) + { + MSRPLOG("CMSRP.. ConstructL"); + iMSRPImpl = CMSRPImplementation::NewL(aUid); + } + +EXPORT_C CMSRP::~CMSRP() + { + MSRPLOG("CMSRP.. Dtor"); + if(NULL!=iMSRPImpl) + delete iMSRPImpl; + } + +EXPORT_C CMSRPSession* CMSRP::CreateMSRPSessionL( MMSRPSessionObserver& aObserver, + const TUint aIapId ) + { + // Creates and Returns a MSRP Session. + // No paramers are taken at this stage. Primarily because + // this is the first step the MSRP user is expected to do before + // SDP negotiation. + // At this stage the user expects to get the session-id, + // avaible trasport etc. + + MSRPLOG("CMSRP.. Create MSRP session"); + + return iMSRPImpl->CreateMSRPSessionL( aObserver, aIapId ); + } + +EXPORT_C void CMSRP::CloseMSRPSession( CMSRPSession* aMsrpSession ) + { + + MSRPLOG("CMSRP.. Close MSRP session"); + + return iMSRPImpl->CloseMSRPSession( aMsrpSession ); + } + + + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/src/CMSRPConnectionListener.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/src/CMSRPConnectionListener.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + + +// Include Files +#include "MsrpCommon.h" +#include "CMSRPConnectionListener.h" +#include "CMSRPSessionImplementation.h" +#include "MMSRPServerInterface.h" + + +// Member Functions + +CMSRPConnectionListener* CMSRPConnectionListener::NewL( + CMSRPSessionImplementation& aSessionImpl, + MMSRPServerInterface& aServerInterface ) + { + // Perform construction. + CMSRPConnectionListener* self = + new ( ELeave ) CMSRPConnectionListener( + aSessionImpl, aServerInterface ); + return self; + } + + +CMSRPConnectionListener::~CMSRPConnectionListener() + { + // Cancel any outstanding requests. + Cancel(); + } + + +CMSRPConnectionListener::CMSRPConnectionListener( + CMSRPSessionImplementation& aSessionImpl, + MMSRPServerInterface& aServerInterface ) + : CMSRPListenerBase( aSessionImpl, aServerInterface, EPriorityStandard ) + { + } + + +void CMSRPConnectionListener::ConnectL( const TDesC8& aRemoteHost, + const TUint aRemotePort, + const TDesC8& aRemoteSessionID ) + { + if ( !IsActive() ) + { + // Connection request to server + iServerInterface.Connect( aRemoteHost, aRemotePort, aRemoteSessionID, iStatus ); + + // Set this handler to active so that it can receive requests. + SetActive(); + } + else + { + User::Leave( KErrInUse ); + } + } + + +void CMSRPConnectionListener::RunL() + { + iSessionImpl.ConnectionEstablishedL( iStatus.Int() ); + } + + +void CMSRPConnectionListener::DoCancel() + { + // not possible to cancel the connect/disconnect sequence + } diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/src/CMSRPImplementation.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/src/CMSRPImplementation.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + + +// Include Files +#include "MsrpCommon.h" +#include "RMSRP.h" +#include "CMSRPSession.h" +#include "CMSRPImplementation.h" +#include "MMSRPSessionObserver.h" + + +// Member Functions + +CMSRPImplementation* CMSRPImplementation::NewL( const TUid& aUid ) + { + MSRPLOG("CMSRP Impl.. NewL"); + CMSRPImplementation* self = CMSRPImplementation::NewLC(aUid); + CleanupStack::Pop(self); + return self; + } + + +CMSRPImplementation* CMSRPImplementation::NewLC( const TUid& aUid ) + { + MSRPLOG("CMSRP Impl.. NewLC"); + CMSRPImplementation* self = new (ELeave) CMSRPImplementation(aUid); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + + +void CMSRPImplementation::ConstructL() + { + MSRPLOG("CMSRP Impl.. ConstructL"); + iMSRP = new ( ELeave ) RMSRP(); + User::LeaveIfError(iMSRP->CreateServerSession()); + } + + +CMSRPImplementation::CMSRPImplementation( const TUid& aUid ) + :iUid(aUid) + { + MSRPLOG("CMSRP Impl.. Ctor"); + } + + +CMSRPImplementation::~CMSRPImplementation() + { + MSRPLOG("CMSRP Impl.. Dtor"); + + if( iMSRPSessionsArray.Count() ) + { + for(TUint i=0; iClose(); + delete iMSRP; + + } + + +CMSRPSession* CMSRPImplementation::CreateMSRPSessionL( MMSRPSessionObserver& aObserver, + const TUint aIapId ) + { + // Creates and Returns a MSRP Session. + // No paramers are taken at this stage. Primarily because + // this is the first step the MSRP user is expected to do before + // SDP negotiation. + // At this stage the user expects to get the session-id, + // avaible trasport etc. + + MSRPLOG("CMSRP Impl.. Create MSRP session"); + + CMSRPSession* msrpSession + = CMSRPSession::NewL( *iMSRP, aObserver, aIapId ); + + // CMSRPImplementation would like to keep a tab on number of MSRP sessions + // that it is serving.Append the MSRPSession to a session array. + + iMSRPSessionsArray.AppendL(msrpSession); + + return msrpSession; + + } + + +void CMSRPImplementation::CloseMSRPSession( CMSRPSession* aMsrpSession ) + { + + MSRPLOG("CMSRP Impl.. Close MSRP session"); + + TInt index = iMSRPSessionsArray.Find(aMsrpSession); + + delete iMSRPSessionsArray[index]; + iMSRPSessionsArray.Remove(index); + + } + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/src/CMSRPIncomingListener.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/src/CMSRPIncomingListener.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,126 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + + +// Include Files +#include "MsrpCommon.h" +#include "CMSRPListenerBase.h" +#include "CMSRPIncomingListener.h" +#include "CMSRPSessionImplementation.h" +#include "MMSRPServerInterface.h" + + +// Member Functions + +CMSRPIncomingListener* CMSRPIncomingListener::NewL( + CMSRPSessionImplementation& aSessionImpl, + MMSRPServerInterface& aServerInterface ) + { + CMSRPIncomingListener* self = + new ( ELeave ) CMSRPIncomingListener( + aSessionImpl, aServerInterface ); + + return self; + } + + +CMSRPIncomingListener::CMSRPIncomingListener( + CMSRPSessionImplementation& aSessionImpl, + MMSRPServerInterface& aServerInterface ) + : CMSRPListenerBase( aSessionImpl, aServerInterface, EPriorityStandard ) + { + } + + +CMSRPIncomingListener::~CMSRPIncomingListener() + { + Cancel(); + } + + +void CMSRPIncomingListener::ListenConnections( + const TDesC8& aRemoteHost, + const TUint aRemotePort, + const TDesC8& aRemoteSessionID ) + { + if ( !IsActive() ) + { + iIsMessage = EFalse; + iServerInterface.ListenConnections( aRemoteHost, aRemotePort, aRemoteSessionID, iIsMessage, iStatus ); + + // Set this handler to active so that it can receive requests. + SetActive(); + } + } + + +void CMSRPIncomingListener::ListenMessages( ) + { + if ( !IsActive() ) + { + iIsMessage = ETrue; + iServerInterface.ListenMessages( iIsMessage, iStatus ); + + // Set this handler to active so that it can receive requests. + SetActive(); + } + } + + +void CMSRPIncomingListener::RunL() + { + if ( !iIsMessage ) + { + // connection was made + iSessionImpl.ConnectionEstablishedL( iStatus.Int() ); + } + else + { + if(iStatus == KErrNone) + { + if(iServerInterface.GetListenProgress()) + { + //handle listen progress + iSessionImpl.ReceiveProgress(iServerInterface.GetBytesReceived(), iServerInterface.GetTotalBytesReceived()); + } + else + { + // Handle incoming message by reading it from server interface + iSessionImpl.HandleIncomingMessageL( iServerInterface.GetReceivedMessage( ), + iServerInterface.GetStatusOfReceivedMessage() ); + } + + // issue a new request + iServerInterface.ListenMessages( iIsMessage, iStatus ); + SetActive(); + } + else + { + // Error scenario. + iSessionImpl.HandleConnectionErrors(iStatus.Int()); + } + } + } + + +void CMSRPIncomingListener::DoCancel() + { + if ( IsActive() ) + { + iServerInterface.CancelReceiving(); + } + + } diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/src/CMSRPListenerBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/src/CMSRPListenerBase.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + + +// Include Files +#include +#include "CMSRPListenerBase.h" + + +// Member Functions + +CMSRPListenerBase::CMSRPListenerBase( + CMSRPSessionImplementation& aSessionImpl, + MMSRPServerInterface& aServerInterface, + TInt aPriority ) + : CActive( aPriority ), + iSessionImpl( aSessionImpl ), + iServerInterface( aServerInterface ) + { + CActiveScheduler::Add( this ); // add to active scheduler + } + + +CMSRPListenerBase::~CMSRPListenerBase() + { + } + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/src/CMSRPSendResultListener.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/src/CMSRPSendResultListener.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + + +// Include Files +#include "MsrpCommon.h" +#include "CMSRPSendResultListener.h" +#include "CMSRPSessionImplementation.h" +#include "MMSRPServerInterface.h" + + +// Member Functions + +CMSRPSendResultListener* CMSRPSendResultListener::NewL( + CMSRPSessionImplementation& aSessionImpl, + MMSRPServerInterface& aServerInterface, + const TDesC8& aSessionID ) + { + + CMSRPSendResultListener* self = + new ( ELeave ) CMSRPSendResultListener( + aSessionImpl, aServerInterface, aSessionID ); + return self; + } + + +CMSRPSendResultListener::CMSRPSendResultListener( + CMSRPSessionImplementation& aSessionImpl, + MMSRPServerInterface& aServerInterface, + const TDesC8& aSessionID ) + : CMSRPListenerBase( aSessionImpl, aServerInterface, EPriorityStandard ), + iSessionID( aSessionID ) + { + } + + +CMSRPSendResultListener::~CMSRPSendResultListener() + { + // Cancel any outstanding requests. + MSRPLOG("~CMSRPSendResultListener"); + Cancel(); + MSRPLOG("~CMSRPSendResultListener Exit"); + } + + +void CMSRPSendResultListener::ListenSendResultL( ) + { + if ( !IsActive() ) + { + // sending message to server + iServerInterface.ListenSendResult( iSessionID, iStatus ); + + // Set this handler to active so that it can receive requests. + SetActive(); + } + else + { + User::Leave( KErrInUse ); + } + } + + +void CMSRPSendResultListener::RunL() + { + MSRPLOG2( "CMSRPSendResultListener::RunL enter, status = %d", iStatus.Int() ) + /*RProcess proc; + RThread thread; + MSRPLOG2( "CMSRPServerSession::ServiceL... Client Process Priority%d", proc.Priority()); + MSRPLOG2( "CMSRPServerSession::ServiceL... Client Thread Priority%d", thread.Priority());*/ + + if ( iStatus.Int() == KErrNone ) + { + if(iServerInterface.GetSendProgress()) + { + iSessionImpl.SendProgress(iServerInterface.GetBytesSent(), iServerInterface.GetTotalBytes()); + //handle send progress + //to session observer + } + else + { + iSessionImpl.SendStatusL( iServerInterface.GetStatusOfSentMessage(), + iServerInterface.GetMessageIdOfSentMessage() ); + //iSessionImpl.SendStatusL( iStatus.Int(), iServerInterface.GetMessageIdOfSentMessage() ); + } + } + else + { + MSRPLOG( "CMSRPSendResultListener::RunL enter, status error") + iSessionImpl.SendStatusL( iStatus.Int(), iServerInterface.GetMessageIdOfSentMessage() ); + } + + iServerInterface.ListenSendResult( iSessionID, iStatus ); + SetActive(); + } + + +void CMSRPSendResultListener::DoCancel() + { + if ( IsActive() ) + { + MSRPLOG( "CMSRPSendResultListener::DoCancel ... canceling"); + iServerInterface.CancelSendResultListening( ); + } + + } diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/src/CMSRPSession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/src/CMSRPSession.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,158 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// System Includes +#include + + +// Include Files +#include "CMSRPSession.h" +#include "CMSRPSessionImplementation.h" + + +// Member Functions + +CMSRPSession* CMSRPSession::NewL( RMSRP& aRMSRP, + MMSRPSessionObserver& aObserver, + const TUint aIapId ) + { + MSRPLOG("CMSRP Session.. NewL"); + CMSRPSession* self = CMSRPSession::NewLC( aRMSRP, aObserver, aIapId ); + CleanupStack::Pop(self); + return self; + } + + +CMSRPSession* CMSRPSession::NewLC( RMSRP& aRMSRP, + MMSRPSessionObserver& aObserver, + const TUint aIapId ) + { + MSRPLOG("CMSRP Session.. NewLC"); + CMSRPSession* self = new (ELeave) CMSRPSession; + CleanupStack::PushL(self); + self->ConstructL( aRMSRP, aObserver, aIapId ); + return self; + } + + +void CMSRPSession::ConstructL( RMSRP& aRMSRP, + MMSRPSessionObserver& aObserver, + const TUint aIapId ) + { + MSRPLOG("CMSRP Session.. ConstructL"); + iMSRPSessionImpl = CMSRPSessionImplementation::NewL( aRMSRP, aObserver, aIapId ); + } + + +CMSRPSession::~CMSRPSession() + { + MSRPLOG("CMSRP Session.. Dtor"); + if(NULL != iMSRPSessionImpl) + delete iMSRPSessionImpl; + } + + +EXPORT_C TDesC8& CMSRPSession::LocalMSRPPath() + { + MSRPLOG("CMSRP Session.. LocalMSRPPath"); + return iMSRPSessionImpl->LocalMSRPPath(); + } + + +EXPORT_C void CMSRPSession::SetSessionParams( CMSRPSessionParams& aSessionParams ) + { + MSRPLOG("CMSRP Session.. SetSessionParams"); + iMSRPSessionImpl->SetSessionParams( aSessionParams ); + } + + +EXPORT_C TInt CMSRPSession::Connect( const TDesC8& aRemoteMsrpPath ) + { + MSRPLOG("CMSRP Session.. Connect"); + TRAPD( err, iMSRPSessionImpl->ConnectL( aRemoteMsrpPath )); + return err; + } + + +EXPORT_C TInt CMSRPSession::Listen( const TDesC8& aRemoteMsrpPath ) + { + MSRPLOG("CMSRP Session.. Listen"); + TRAPD( err, iMSRPSessionImpl->ListenL( aRemoteMsrpPath )); + return err; + } + + +EXPORT_C HBufC8* CMSRPSession::SendBuffer( + const TDesC8& aMessage, + const TDesC8& aMimeType ) + { + MSRPLOG("CMSRP Session.. SendBuffer"); + // send the Message + HBufC8* messageId = NULL; + TRAPD( err, messageId = iMSRPSessionImpl->SendBufferL( aMessage, aMimeType ) ); + if ( err ) + { + return NULL; + } + return messageId; + } + +EXPORT_C TInt CMSRPSession::SendFile( + const TFileName& aFileName, + const TDesC8& aMimeType ) + { + + MSRPLOG("CMSRP Session.. SendFile"); + TRAPD( err,iMSRPSessionImpl->SendFileL(aFileName, aMimeType ) ); + return err; + + } + +EXPORT_C TInt CMSRPSession::CancelFileSending( ) + { + MSRPLOG("CMSRP Session.. CancelFileSending"); +/* TInt err; + return err;*/ + return 0; + } + +EXPORT_C TInt CMSRPSession::ReceiveFile( + const TFileName& aFileName, + const TInt aFileSize, + const TDesC8& aMimeType) + { + MSRPLOG("CMSRP Session.. ReceiveFile"); + TRAPD( err,iMSRPSessionImpl->ReceiveFileL(aFileName,aFileSize,aMimeType )); + return err; + } + +EXPORT_C TInt CMSRPSession::CancelReceiveFile() + { + return 0; + } + +EXPORT_C void CMSRPSession::NotifyProgress(TBool aFlag) + { + iMSRPSessionImpl->NotifyProgress(aFlag); + } + +EXPORT_C TInt CMSRPSession::CancelSending( TDesC8& aMessageId ) + { + MSRPLOG("CMSRP Session.. CancelSending"); + TRAPD( err, iMSRPSessionImpl->CancelSendingL( aMessageId ) ); + return err; + } + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/src/CMSRPSessionImplementation.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/src/CMSRPSessionImplementation.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,633 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// Include Files +#include "CMSRPSessionImplementation.h" +#include "msrpstrings.h" +#include "MSRPStrConsts.h" +#include "RMSRPSession.h" +#include "MMSRPSessionObserver.h" +#include "CMSRPConnectionListener.h" +#include "CMSRPIncomingListener.h" +#include "CMSRPSendResultListener.h" +#include "CMSRPMessage.h" +#include "CMSRPToPathHeader.h" +#include "CMSRPFromPathHeader.h" +#include "CMSRPMessageIdHeader.h" +#include "CMSRPSuccessReportHeader.h" +#include "CMsrpFailureReportHeader.h" +#include "CMsrpContentTypeHeader.h" +#include "CMSRPSessionParams.h" + + +// SYSTEM INCLUDES +#include + + +// Constants +const TInt KMsrpFixedLength=19; // fixed length of a uri + + +// Member Functions + +CMSRPSessionImplementation* CMSRPSessionImplementation::NewL( RMSRP& aRMSRP, + MMSRPSessionObserver& aObserver, + const TUint aIapId ) + { + MSRPLOG("CMSRPSessionImplementation::NewL"); + CMSRPSessionImplementation *self = CMSRPSessionImplementation::NewLC( aRMSRP, aObserver, aIapId ); + + CleanupStack::Pop(self); + return self; + } + + +CMSRPSessionImplementation* CMSRPSessionImplementation::NewLC( RMSRP& aRMSRP, + MMSRPSessionObserver& aObserver, + const TUint aIapId ) + { + MSRPLOG("CMSRPSessionImplementation::NewLC"); + CMSRPSessionImplementation *self = new (ELeave) CMSRPSessionImplementation( aRMSRP, aObserver ); + + CleanupStack::PushL(self); + self->ConstructL( aIapId ); + return self; + } + +CMSRPSessionImplementation::CMSRPSessionImplementation( RMSRP& aRMSRP, + MMSRPSessionObserver& aObserver ) + :iRMSRP(aRMSRP), + iSessionObserver(aObserver), + iSuccessReport(ENo), + iFailureReport(EYes) + { + MSRPLOG("CMSRPSessionImplementation::Ctor"); + } + + +void CMSRPSessionImplementation::ConstructL( const TUint aIapId ) + { + MSRPLOG("CMSRPSessionImplementation::ConstructL enter"); + + MSRPStrings::OpenL(); + iMSRPSession = new ( ELeave ) RMSRPSession(); + + User::LeaveIfError(iMSRPSession->CreateServerSubSession( iRMSRP, aIapId ) ); + MSRPLOG("Sub session opened successfully!"); + + RBuf8 sessionID; + sessionID.CreateL( KMaxLengthOfSessionId ); + CleanupClosePushL( sessionID ); + + RBuf8 localHost; + localHost.CreateL( KMaxLengthOfHost ); + CleanupClosePushL( localHost ); + + iMSRPSession->GetLocalPathL( localHost, sessionID ); + + iLocalMsrpPath.CreateL( KMsrpUriScheme, KMsrpFixedLength + localHost.Length() + sessionID.Length() ); + + iLocalMsrpPath.Append( localHost ); + iLocalMsrpPath.Append( KColon ); + iLocalMsrpPath.AppendNum( KMsrpPort ); + iLocalMsrpPath.Append( KForwardSlash ); + iLocalMsrpPath.Append( sessionID ); + iLocalMsrpPath.Append( KSemicolon ); + iLocalMsrpPath.Append( KTransport ); + + + iConnectionListener = CMSRPConnectionListener::NewL( + *this, *iMSRPSession ); + iIncomingListener = CMSRPIncomingListener::NewL( + *this, *iMSRPSession ); + iSendResultListener = CMSRPSendResultListener::NewL( + *this, *iMSRPSession, sessionID ); + + CleanupStack::PopAndDestroy(2); //sessionID and localHost + MSRPLOG("CMSRPSessionImplementation::ConstructL exit"); + } + + +CMSRPSessionImplementation::~CMSRPSessionImplementation() + { + MSRPLOG("CMSRPSessionImplementation::Dtor Entered"); + + MSRPStrings::Close(); + iLocalMsrpPath.Close(); + iRemoteMsrpPath.Close(); + + delete iConnectionListener; + delete iIncomingListener; + delete iSendResultListener; + + iSentMessages.ResetAndDestroy(); + iSentMessages.Close(); + + if( iMSRPSession ) + { + iMSRPSession->CloseServerSubSession(); + } + delete iMSRPSession; + + MSRPLOG("CMSRPSessionImplementation::Dtor Exit"); + } + + +TDesC8& CMSRPSessionImplementation::LocalMSRPPath() + { + MSRPLOG("CMSRPSessionImplementation::LocalMSRPPath"); + return iLocalMsrpPath; + } + + +void CMSRPSessionImplementation::SetSessionParams( CMSRPSessionParams& aSessionParams ) + { + MSRPLOG("CMSRPSessionImplementation::SetSessionParams"); + iSuccessReport = aSessionParams.SuccessReportHeader(); + iFailureReport = aSessionParams.FailureReportHeader(); + } + + +void CMSRPSessionImplementation::GetRemotePathComponentsL( TPtrC8& aRemoteHost, TUint& aRemotePort, TPtrC8& aRemoteSessionID ) + { + MSRPLOG("CMSRPSessionImplementation::GetRemotePathComponentsL enter"); + TUriParser8 parser; + User::LeaveIfError( parser.Parse( iRemoteMsrpPath ) ); + + aRemoteHost.Set( parser.Extract( EUriHost ) ); + + const TDesC8& remPort = parser.Extract( EUriPort ); + + TLex8 portLex(remPort); + User::LeaveIfError( portLex.Val( aRemotePort ) ); + + const TDesC8& remotePath = parser.Extract( EUriPath ); + + TInt loc = remotePath.Find( KSemicolon ); + aRemoteSessionID.Set( remotePath.Mid( 1, loc-1) ); + MSRPLOG("CMSRPSessionImplementation::GetRemotePathComponentsL exit"); + } + + +void CMSRPSessionImplementation::ConnectL( const TDesC8& aRemoteMsrpPath ) + { + MSRPLOG("CMSRPSessionImplementation::ConnectL enter"); + + iRemoteMsrpPath.CreateL( aRemoteMsrpPath ); + + TPtrC8 remoteHost; + TPtrC8 remoteSessionID; + TUint remotePort; + + GetRemotePathComponentsL( remoteHost, remotePort, remoteSessionID ); + + iConnectionListener->ConnectL( remoteHost, remotePort, remoteSessionID ); + MSRPLOG("CMSRPSessionImplementation::ConnectL exit"); + } + + +void CMSRPSessionImplementation::ListenL( const TDesC8& aRemoteMsrpPath ) + { + MSRPLOG("CMSRPSessionImplementation::ListenL enter"); + + iRemoteMsrpPath.CreateL( aRemoteMsrpPath ); + + TPtrC8 remoteHost; + TPtrC8 remoteSessionID; + TUint remotePort; + + GetRemotePathComponentsL( remoteHost, remotePort, remoteSessionID ); + + iIncomingListener->ListenConnections( remoteHost, remotePort, remoteSessionID ); + MSRPLOG("CMSRPSessionImplementation::ListenL exit"); + } + + +void CMSRPSessionImplementation::ConnectionEstablishedL( TInt aStatus ) + { + + MSRPLOG("CMSRPSessionImplementation::ConnectionEstablished enter"); + + iSessionObserver.ConnectStatus(aStatus); + if ( aStatus == KErrNone ) + { + // start listening to incoming messages directed to this session + iIncomingListener->ListenMessages( ); + + // start listening when message has been sent, to responses + iSendResultListener->ListenSendResultL( ); + } + + MSRPLOG("CMSRPSessionImplementation::ConnectionEstablished exit"); + } + + +void CMSRPSessionImplementation::HandleIncomingMessageL( + const TDesC8& aIncomingMessage, TInt aStatus ) + { + MSRPLOG( "CMSRPSessionImplementation::HandleIncomingMessageL enter" ) + + // the incoming buffer must be internalized + RDesReadStream readStream( aIncomingMessage ); + + if ( CMSRPMessage::IsMessage( aIncomingMessage ) ) + { + CMSRPMessage* message = NULL; + message = CMSRPMessage::InternalizeL( readStream ); + CleanupStack::PushL(message); + + HBufC8* messageContent = NULL; + if(message->IsContent()) + { + messageContent = HBufC8::NewL(message->Content().Length()); + CleanupStack::PushL( messageContent ); + *messageContent = message->Content(); + } + else + { + messageContent = HBufC8::NewL(KNullDesC8().Length()); + CleanupStack::PushL( messageContent ); + *messageContent = KNullDesC8(); + } + + iSessionObserver.IncomingMessage( messageContent, aStatus ); + CleanupStack::Pop( messageContent ); + CleanupStack::PopAndDestroy(message); + } + else + { + User::Leave( KErrArgument ); + } + + MSRPLOG( "CMSRPSessionImplementation::HandleIncomingMessageL exit" ) + } + +void CMSRPSessionImplementation::ReceiveProgress(TInt aBytesReceived, TInt aTotalBytes) + { + iSessionObserver.FileReceiveProgress(aBytesReceived, aTotalBytes); + } + +void CMSRPSessionImplementation::SendProgress(TInt aBytesSent, TInt aTotalBytes) + { + iSessionObserver.FileSendProgress(aBytesSent, aTotalBytes); + } + +CMSRPMessage* CMSRPSessionImplementation::CreateMsrpMessageL( + const TDesC8& aMessage, const TDesC8& aToPath, + const TDesC8& aFromPath, const TDesC8& aMimeType ) + { + + MSRPLOG( "CMSRPSessionImplementation::CreateMsrpMessageL enter" ) + + // To path + CMSRPMessage* msrpMessage = new ( ELeave ) CMSRPMessage(); + CleanupStack::PushL( msrpMessage ); + CMSRPToPathHeader* toPath = CMSRPToPathHeader::DecodeL( aToPath ); + msrpMessage->SetToPathHeader( toPath ); + + // from path + CMSRPFromPathHeader* fromPath = CMSRPFromPathHeader::DecodeL( aFromPath ); + msrpMessage->SetFromPathHeader( fromPath ); + + // message id header + TTime now; + now.HomeTime(); + TInt64 seed = now.Int64(); + // Create a random number as the session ID + TInt random = Math::Rand( seed ); + TBuf8< 100 > idString; + idString.AppendNum( random ); + CMSRPMessageIdHeader* messageIdHeader = CMSRPMessageIdHeader::NewL( idString ); + msrpMessage->SetMessageIdHeader( messageIdHeader ); + + // success report header + if( iSuccessReport != ENo ) + { + RStringF string = MSRPStrings::StringF( MSRPStrConsts::EYes ); + CMSRPSuccessReportHeader* successReportHeader = CMSRPSuccessReportHeader::NewL( string ); + msrpMessage->SetSuccessReportHeader( successReportHeader ); + } + + // failure report header + if( iFailureReport != EYes ) + { + RStringF string; + CleanupClosePushL(string); + if( iFailureReport == ENo ) + { + string = MSRPStrings::StringF( MSRPStrConsts::ENo ); + } + else + { + string = MSRPStrings::StringF( MSRPStrConsts::EPartial ); + } + CMSRPFailureReportHeader* failureReportHeader = CMSRPFailureReportHeader::NewL( string ); + msrpMessage->SetFailureReportHeader( failureReportHeader ); + CleanupStack::PopAndDestroy(); // string + } + + // content type + if(aMimeType.Length()) + { + CMSRPContentTypeHeader* contentType = CMSRPContentTypeHeader::NewL( aMimeType ); + msrpMessage->SetContentTypeHeader( contentType ); + + if(aMessage.Length()) + { + // content of the message + HBufC8* contentOfMessage = HBufC8::NewL( aMessage.Length() ); + *contentOfMessage = aMessage; + + msrpMessage->SetContent( contentOfMessage ); + } + } + + CleanupStack::Pop(msrpMessage); + MSRPLOG( "CMSRPSessionImplementation::CreateMsrpMessageL exit" ) + return msrpMessage; + } + + +void CMSRPSessionImplementation::SendMessageL( CMSRPMessage* aMessage ) + { + MSRPLOG( "CMSRPSessionImplementation::SendMessageL enter" ) + + iSentMessages.AppendL( aMessage ); + + // making sure the required headers are included + if ( !aMessage->FromPathHeader() || !aMessage->ToPathHeader() || !aMessage->MessageIdHeader() ) + { + User::Leave( KErrArgument ); + } + + CBufSeg* buf1 = CBufSeg::NewL( 256 ); // expandsize 256 + CleanupStack::PushL( buf1 ); + RBufWriteStream writeStream( *buf1 ); + CleanupClosePushL( writeStream ); + + aMessage->ExternalizeL( writeStream ); + writeStream.CommitL(); + + // MSRP message externalized to buffer, now let's move it to flat buffer + if ( buf1->Size() > KMaxLengthOfIncomingMessageExt ) + { + // invalid message size + User::Leave( KErrArgument ); + } + + buf1->Read( 0, iExtMessageBuffer, buf1->Size() ); + CleanupStack::PopAndDestroy( 2 ); // buf1, writestream + + // message creation complete, send the message + // synchronously sent the message + User::LeaveIfError( iMSRPSession->SendMessage( iExtMessageBuffer ) ); + + MSRPLOG( "CMSRPSessionImplementation::SendMessageL exit" ) + } + + +HBufC8* CMSRPSessionImplementation::SendBufferL( + const TDesC8& aMessage, + const TDesC8& aMimeType ) + { + MSRPLOG( "CMSRPSessionImplementation::SendBufferL enter" ) + + if(aMessage.Length() && !aMimeType.Length()) + { + User::Leave( KErrArgument ); + } + + CMSRPMessage* msrpMessage = CreateMsrpMessageL( + aMessage, iRemoteMsrpPath, iLocalMsrpPath, aMimeType ); + CleanupStack::PushL( msrpMessage ); + SendMessageL( msrpMessage ); + HBufC8* messageId = msrpMessage->MessageIdHeader()->ToTextValueLC(); + CleanupStack::Pop(messageId); + CleanupStack::Pop( msrpMessage ); + MSRPLOG( "CMSRPSessionImplementation::SendBufferL exit" ) + return messageId; + } + + +void CMSRPSessionImplementation::CancelSendingL( TDesC8& aMessageId ) + { + MSRPLOG( "CMSRPSessionImplementation::CancelSendingL " ) + // then let's send a message to server to cancel sending + User::LeaveIfError( iMSRPSession->CancelSending( aMessageId ) ); + } + + +void CMSRPSessionImplementation::SendStatusL( TInt aStatus, const TDesC8& aMessageid ) + { + MSRPLOG2( "CMSRPSessionImplementation::SendStatus = %d", aStatus ) + if(isReceiveFile || isSendFile ) + { + if(isReceiveFile) + { + iSessionObserver.ReceiveFileNotification( aStatus ); + + } + if(isSendFile) + { + iSessionObserver.SendFileNotification( aStatus ); + } + } + else + { + for ( TInt i = 0; i < iSentMessages.Count(); i++ ) + { + HBufC8* messageid = iSentMessages[ i ]->MessageIdHeader()->ToTextValueLC(); + if ( *messageid == aMessageid ) + { + // match + delete iSentMessages[ i ]; + iSentMessages.Remove( i ); + iSessionObserver.SendResult( aStatus, aMessageid ); + CleanupStack::PopAndDestroy(messageid); // messageid from above + break; + } + CleanupStack::PopAndDestroy(messageid); // messageid from above + } + } + + MSRPLOG( "CMSRPSessionImplementation::SendStatus exit" ) + } + +void CMSRPSessionImplementation::HandleConnectionErrors( TInt aErrorStatus ) + { + MSRPLOG2( "CMSRPSessionImplementation::HandleConnectionErrors Error = %d", aErrorStatus ) + iSessionObserver.ListenPortFailure(aErrorStatus); + + } + +void CMSRPSessionImplementation::SendFileL(const TFileName& aFileName, const TDesC8& aMimeType) + { + MSRPLOG( "CMSRPSessionImplementation::SendFileL enter" ); + + if(aFileName.Length() && !aMimeType.Length()) + { + User::Leave( KErrArgument ); + } + isSendFile = ETrue; + CMSRPMessage* iFile = SetFileParamsL(aFileName,iRemoteMsrpPath, iLocalMsrpPath,aMimeType ); + + //Set progress indication + iFile->SetNotifyProgress(iProgress); + + CBufSeg* buf = CBufSeg::NewL( 100 ); // expandsize to 100 + + //todo need to check what's optimal value here + CleanupStack::PushL( buf ); + RBufWriteStream writeStr( *buf ); + CleanupClosePushL( writeStr ); + iFile->ExternalizeL( writeStr ); + writeStr.CommitL(); + + // MSRP message externalized to buffer, now let's move it to flat buffer + if ( buf->Size() > KMaxLengthOfIncomingMessageExt ) + { + // invalid message size + User::Leave( KErrArgument ); + } + + buf->Read( 0, iExtMessageBuffer, buf->Size() ); + CleanupStack::PopAndDestroy( 2 ); // buf, writestream + + delete iFile; + iFile = NULL; + // send the filename + User::LeaveIfError( iMSRPSession->SendFileL( iExtMessageBuffer ) ); + MSRPLOG( "CMSRPSessionImplementation::SendFileL exit" ); + } + +void CMSRPSessionImplementation::ReceiveFileL(const TFileName& aFileName,const TInt aFileSize, const TDesC8& aMimeType) + { + MSRPLOG( "CMSRPSessionImplementation::ReceiveFileL enter" ); + isReceiveFile = ETrue; + if(aFileName.Length() && !aMimeType.Length()) + { + User::Leave( KErrArgument ); + } + CMSRPMessage* iFile = SetFileParamsL(aFileName,iRemoteMsrpPath, iLocalMsrpPath,aMimeType ); + + //Set FileSize + iFile->SetFileSize(aFileSize); + + //Set progress indication + iFile->SetNotifyProgress(iProgress); + + CBufSeg* buf = CBufSeg::NewL( 100 ); // expandsize to 100 + + //todo need to check what's optimal value here + CleanupStack::PushL( buf ); + RBufWriteStream writeStr( *buf ); + CleanupClosePushL( writeStr ); + iFile->ExternalizeL( writeStr ); + writeStr.CommitL(); + + // MSRP message externalized to buffer, now let's move it to flat buffer + if ( buf->Size() > KMaxLengthOfIncomingMessageExt ) + { + // invalid message size + User::Leave( KErrArgument ); + } + + buf->Read( 0, iExtMessageBuffer, buf->Size() ); + CleanupStack::PopAndDestroy( 2 ); // buf, writestream + + delete iFile; + iFile = NULL; + // send the filename + User::LeaveIfError( iMSRPSession->ReceiveFileL( iExtMessageBuffer ) ); + + + } + +CMSRPMessage* CMSRPSessionImplementation::SetFileParamsL(const TFileName& aFileName,const TDesC8& aToPath, + const TDesC8& aFromPath, + const TDesC8& aMimeType ) + { + MSRPLOG( "CMSRPSessionImplementation::SetFileParamsL enter" ); + + CMSRPMessage* msrpMessage = new ( ELeave ) CMSRPMessage(); + CleanupStack::PushL( msrpMessage ); + + //set filename + msrpMessage->SetFileName( aFileName ); + + //set to path + CMSRPToPathHeader* toPath = CMSRPToPathHeader::DecodeL( aToPath ); + msrpMessage->SetToPathHeader( toPath ); + + //set from path + CMSRPFromPathHeader* fromPath = CMSRPFromPathHeader::DecodeL( aFromPath ); + msrpMessage->SetFromPathHeader( fromPath ); + + //set content type + if(aMimeType.Length()) + { + CMSRPContentTypeHeader* contentType = CMSRPContentTypeHeader::NewL( aMimeType ); + msrpMessage->SetContentTypeHeader( contentType ); + } + + //set message id header + TTime now; + now.HomeTime(); + TInt64 seed = now.Int64(); + // Create a random number as the session ID + TInt random = Math::Rand( seed ); + TBuf8< 100 > idString; + idString.AppendNum( random ); + CMSRPMessageIdHeader* messageIdHeader = CMSRPMessageIdHeader::NewL( idString ); + msrpMessage->SetMessageIdHeader( messageIdHeader ); + + // success report header + if( iSuccessReport != ENo ) + { + RStringF string = MSRPStrings::StringF( MSRPStrConsts::EYes ); + CMSRPSuccessReportHeader* successReportHeader = CMSRPSuccessReportHeader::NewL( string ); + msrpMessage->SetSuccessReportHeader( successReportHeader ); + } + + // failure report header + if( iFailureReport != EYes ) + { + RStringF string; + CleanupClosePushL(string); + if( iFailureReport == ENo ) + { + string = MSRPStrings::StringF( MSRPStrConsts::ENo ); + } + else + { + string = MSRPStrings::StringF( MSRPStrConsts::EPartial ); + } + CMSRPFailureReportHeader* failureReportHeader = CMSRPFailureReportHeader::NewL( string ); + msrpMessage->SetFailureReportHeader( failureReportHeader ); + CleanupStack::PopAndDestroy(); // string + } + + CleanupStack::Pop(msrpMessage); // msrpMessage + + MSRPLOG( "CMSRPSessionImplementation::SetFileParamsL enter" ); + return msrpMessage; + } + + +void CMSRPSessionImplementation::NotifyProgress(TBool aFlag) + { + iProgress = aFlag; + } diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/src/CMSRPSessionParams.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/src/CMSRPSessionParams.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + + +// Include Files +#include "MsrpCommon.h" +#include "CMSRPSessionParams.h" + + +// Member Functions + +EXPORT_C CMSRPSessionParams* CMSRPSessionParams::NewL( ) + { + CMSRPSessionParams* self = new ( ELeave ) CMSRPSessionParams( ); + return self; + } + + +EXPORT_C CMSRPSessionParams::~CMSRPSessionParams() + { + } + + +CMSRPSessionParams::CMSRPSessionParams( ) : iSuccessReport(ENo), + iFailureReport(EYes) + { + } + + +EXPORT_C void CMSRPSessionParams::SetReportHeadersL( TReportStatus aSuccessReport, TReportStatus aFailureReport ) + { + if(aSuccessReport == EPartial) + { + User::Leave( KErrArgument ); + } + iSuccessReport = ENo; // Since Reports are not supported now, the SR value given is ignored + iFailureReport = aFailureReport; + } + + +EXPORT_C TReportStatus CMSRPSessionParams::SuccessReportHeader( ) + { + return iSuccessReport; + } + + +EXPORT_C TReportStatus CMSRPSessionParams::FailureReportHeader( ) + { + return iFailureReport; + } diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/src/RMSRP.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/src/RMSRP.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// Include Files +#include "MsrpCommon.h" +#include "RMSRP.h" + + +// Member Functions + +RMSRP::RMSRP() : + RSessionBase() + { + MSRPLOG("RMSRP.. Ctor"); + } + +TInt RMSRP::CreateServerSession() + { + MSRPLOG("RMSRP.. "); + TInt result = StartServer(); + if (( result == KErrNone) || (result == KErrAlreadyExists)) + { + MSRPLOG("RMSRP.. Create client-server session"); + result = CreateSession( KMSRPServerName, Version() ); + } + + return result; + } + +TVersion RMSRP::Version() const + { + + MSRPLOG("RMSRP.. Get version"); + + return TVersion( + KMSRPServerMajorVersionNumber, + KMSRPServerMinorVersionNumber, + KMSRPServerBuildVersionNumber ); + } + +TInt RMSRP::StartServer( ) const + { + + MSRPLOG("RMSRP.. Start transient server"); + + RProcess p; // codescanner::resourcenotoncleanupstack + TRequestStatus status; + + TBuf< KSizeOfProgramPath > serverPath; + serverPath.Append( KMSRPExe ); + + TInt err = p.Create( serverPath, KNullDesC ); + if ( err == KErrAlreadyExists ) + { + return KErrNone; + } + + if ( err != KErrNone ) + { + return err; + } + + // wait for server + p.Rendezvous( status ); + + if ( status != KRequestPending ) + { + p.Kill(0); // abort startup + p.Close(); + return KErrGeneral; + } + else + { + p.Resume(); // logon OK - start the server + } + + User::WaitForRequest( status ); // codescanner::userWaitForRequest + + if (p.ExitType()==EExitPanic) + { + status = KErrServerTerminated; + } + + if ( status != KErrNone ) + { + p.Close(); + return status.Int(); + } + p.Close(); + + return KErrNone; + } + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpClient/src/RMSRPSession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpClient/src/RMSRPSession.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,226 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef RMSRPSESSION_CPP_ +#define RMSRPSESSION_CPP_ + + +// Include Files +#include "MsrpCommon.h" +#include "RMSRPSession.h" +#include "RMSRP.h" + + +// Member Functions + +RMSRPSession::RMSRPSession() : + RSubSessionBase() + { + MSRPLOG("RMSRP Session.. Ctor"); + } + + +TInt RMSRPSession::CreateServerSubSession( RMSRP& aRMSRP, const TUint32 aIapId ) + { + MSRPLOG("RMSRP Session.. Create client-server SubSession"); + + return CreateSubSession( aRMSRP, EMSRPCreateSubSession, TIpcArgs( aIapId ) ); + } + + +void RMSRPSession::CloseServerSubSession( ) + { + MSRPLOG("RMSRP Session.. Close client-server SubSession"); + CloseSubSession(EMSRPCloseSubSession); + } + + +void RMSRPSession::GetLocalPathL( TDes8 &aLocalHost, TDes8 &aSessionID ) + { + MSRPLOG("RMSRP Session.. GetLocalPath"); + + User::LeaveIfError( SendReceive(EMSRPLocalPath, TIpcArgs( &iLocalPathMSRPDataPckg )) ); + + aLocalHost = iLocalPathMSRPDataPckg().iLocalHost; + aSessionID = iLocalPathMSRPDataPckg().iSessionID; + } + + +void RMSRPSession::Connect( const TDesC8& aRemoteHost, + const TUint aRemotePort, + const TDesC8& aRemoteSessionID, + TRequestStatus& aStatus ) + { + MSRPLOG("RMSRP Session.. Connect"); + + iConnectMSRPDataPckg().iRemoteHost = aRemoteHost; + iConnectMSRPDataPckg().iRemotePort = aRemotePort; + iConnectMSRPDataPckg().iRemoteSessionID = aRemoteSessionID; + + SendReceive( EMSRPConnect, TIpcArgs( &iConnectMSRPDataPckg ), aStatus ); + } + + +void RMSRPSession::ListenConnections( const TDesC8& aRemoteHost, + const TUint aRemotePort, + const TDesC8& aRemoteSessionID, + TBool aIsMessage, + TRequestStatus& aStatus ) + { + MSRPLOG("RMSRP Session.. Listen for incoming connections"); + + iListenMSRPDataPckg().iRemoteHost = aRemoteHost; + iListenMSRPDataPckg().iRemotePort = aRemotePort; + iListenMSRPDataPckg().iRemoteSessionID = aRemoteSessionID; + iListenMSRPDataPckg().iIsMessage = aIsMessage; + + SendReceive( EMSRPListenConnections, TIpcArgs( &iListenMSRPDataPckg ), aStatus ); + } + + +void RMSRPSession::ListenMessages( TBool aIsMessage, + TRequestStatus& aStatus ) + { + MSRPLOG("RMSRP Session.. Listen for incoming messages"); + + iListenMSRPDataPckg().iIsMessage = aIsMessage; + + SendReceive( EMSRPListenMessages, TIpcArgs( &iListenMSRPDataPckg ), aStatus ); + } + + +void RMSRPSession::ListenSendResult( const TDesC8& aSessionID, TRequestStatus& aStatus ) + { + MSRPLOG("RMSRP Session.. ListenSendResult"); + + iSendResultListenMSRPDataPckg().iSessionID = aSessionID; + + SendReceive( EMSRPListenSendResult, TIpcArgs( &iSendResultListenMSRPDataPckg ), aStatus ); + } + + +TInt RMSRPSession::SendMessage( TDesC8& aMessageBuffer ) + { + MSRPLOG("RMSRP Session.. SendMessage"); + + iSendMSRPDataPckg().iExtMessageBuffer = aMessageBuffer; + + return SendReceive( EMSRPSendMessage, TIpcArgs( &iSendMSRPDataPckg ) ); + } + + +TInt RMSRPSession::CancelSending( TDesC8& aMessageId ) + { + MSRPLOG("RMSRP Session.. CancelSending"); + return SendReceive( EMSRPCancelSending, TIpcArgs( &aMessageId ) ); + } + + +void RMSRPSession::CancelReceiving( ) + { + MSRPLOG("RMSRP Session.. CancelReceiving Entered"); + SendReceive( EMSRPCancelReceiving ); + MSRPLOG("RMSRP Session.. CancelReceiving Done "); + } + + +void RMSRPSession::CancelSendResultListening( ) + { + MSRPLOG("RMSRP Session.. CancelSendRespListening"); + SendReceive( EMSRPCancelSendRespListening ); + } + + +const TDesC8& RMSRPSession::GetMessageIdOfSentMessage() const + { + MSRPLOG("RMSRP Session.. GetMessageIdOfSentMessage"); + return iSendResultListenMSRPDataPckg().iMessageId; + } + + +TInt RMSRPSession::GetStatusOfSentMessage() const + { + MSRPLOG("RMSRP Session.. GetStatusOfSentMessage"); + return iSendResultListenMSRPDataPckg().iStatus; + } + + +TInt RMSRPSession::GetStatusOfReceivedMessage() const + { + MSRPLOG("RMSRP Session.. GetStatusOfReceivedMessage"); + return iListenMSRPDataPckg().iStatus; + } + + +const TDesC8& RMSRPSession::GetReceivedMessage() const + { + MSRPLOG("RMSRP Session.. GetReceivedMessage"); + return iListenMSRPDataPckg().iExtMessageBuffer; + } + +TBool RMSRPSession::GetListenProgress() const + { + MSRPLOG("RMSRP Session.. GetListenProgress"); + return iListenMSRPDataPckg().iIsProgress; + } + +TInt RMSRPSession::GetBytesReceived() const + { + MSRPLOG("RMSRP Session.. GetBytesReceived"); + return iListenMSRPDataPckg().iBytesRecvd; + } + +TInt RMSRPSession::GetTotalBytesReceived() const + { + MSRPLOG("RMSRP Session.. GetTotalBytesReceived"); + return iListenMSRPDataPckg().iTotalBytes; + } + +TBool RMSRPSession::GetSendProgress() const + { + MSRPLOG("RMSRP Session.. GetSendProgress"); + return iSendResultListenMSRPDataPckg().iIsProgress; + } + +TInt RMSRPSession::GetBytesSent() const + { + MSRPLOG("RMSRP Session.. GetBytesSent"); + return iSendResultListenMSRPDataPckg().iBytesSent; + } + +TInt RMSRPSession::GetTotalBytes() const + { + MSRPLOG("RMSRP Session.. GetTotalBytes"); + return iSendResultListenMSRPDataPckg().iTotalBytes; + } + + +TInt RMSRPSession::SendFileL(TDesC8& aFileParamBuffer) + { + /* Send File Params to the sub-session */ + MSRPLOG("RMSRP Session.. SendFileParams"); + iSendMSRPDataPckg().iExtMessageBuffer = aFileParamBuffer; + return SendReceive( EMSRPSendFile, TIpcArgs( &iSendMSRPDataPckg ) ); + } + +TInt RMSRPSession::ReceiveFileL(TDesC8& aFileParamBuffer) + { + /* Send File Params to the sub-session */ + MSRPLOG("RMSRP Session.. SendFileParams"); + iSendMSRPDataPckg().iExtMessageBuffer = aFileParamBuffer; + return SendReceive( EMSRPReceiveFile, TIpcArgs( &iSendMSRPDataPckg ) ); + } +#endif /* RMSRPSESSION_CPP_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/bwins/msrpheaderu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/bwins/msrpheaderu.def Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,96 @@ +EXPORTS + ?SetStatusCodeL@CMSRPResponse@@QAEXI@Z @ 1 NONAME ; void CMSRPResponse::SetStatusCodeL(unsigned int) + ?DecodeL@CMSRPFromPathHeader@@SAPAV1@ABVTDesC8@@@Z @ 2 NONAME ; class CMSRPFromPathHeader * CMSRPFromPathHeader::DecodeL(class TDesC8 const &) + ?SetToPathHeader@CMSRPMessageBase@@QAEXPAVCMSRPToPathHeader@@@Z @ 3 NONAME ; void CMSRPMessageBase::SetToPathHeader(class CMSRPToPathHeader *) + ?InternalizeValueL@CMSRPFromPathHeader@@SAPAV1@AAVRReadStream@@@Z @ 4 NONAME ; class CMSRPFromPathHeader * CMSRPFromPathHeader::InternalizeValueL(class RReadStream &) + ?InternalizeValueL@CMSRPFailureReportHeader@@SAPAV1@AAVRReadStream@@@Z @ 5 NONAME ; class CMSRPFailureReportHeader * CMSRPFailureReportHeader::InternalizeValueL(class RReadStream &) + ?Close@MSRPStrings@@SAXXZ @ 6 NONAME ; void MSRPStrings::Close(void) + ?ReasonPhrase@CMSRPResponse@@QBE?AVRStringF@@XZ @ 7 NONAME ; class RStringF CMSRPResponse::ReasonPhrase(void) const + ?OpenL@MSRPStrings@@SAXXZ @ 8 NONAME ; void MSRPStrings::OpenL(void) + ?SetEndPosition@CMSRPByteRangeHeader@@QAEXH@Z @ 9 NONAME ; void CMSRPByteRangeHeader::SetEndPosition(int) + ?NewLC@CMSRPByteRangeHeader@@SAPAV1@HHH@Z @ 10 NONAME ; class CMSRPByteRangeHeader * CMSRPByteRangeHeader::NewLC(int, int, int) + ?IsContent@CMSRPMessage@@QBEHXZ @ 11 NONAME ; int CMSRPMessage::IsContent(void) const + ?InternalizeValueL@CMSRPSuccessReportHeader@@SAPAV1@AAVRReadStream@@@Z @ 12 NONAME ; class CMSRPSuccessReportHeader * CMSRPSuccessReportHeader::InternalizeValueL(class RReadStream &) + ?ToTextValueLC@CMSRPHeaderBase@@QBEPAVHBufC8@@XZ @ 13 NONAME ; class HBufC8 * CMSRPHeaderBase::ToTextValueLC(void) const + ??1CMSRPMessageBase@@UAE@XZ @ 14 NONAME ; CMSRPMessageBase::~CMSRPMessageBase(void) + ?NewL@CMSRPToPathHeader@@SAPAV1@PAVCUri8@@@Z @ 15 NONAME ; class CMSRPToPathHeader * CMSRPToPathHeader::NewL(class CUri8 *) + ?NewLC@CMSRPSuccessReportHeader@@SAPAV1@ABVRStringF@@@Z @ 16 NONAME ; class CMSRPSuccessReportHeader * CMSRPSuccessReportHeader::NewLC(class RStringF const &) + ?ExternalizeValueL@CMSRPFailureReportHeader@@QBEXAAVRWriteStream@@@Z @ 17 NONAME ; void CMSRPFailureReportHeader::ExternalizeValueL(class RWriteStream &) const + ??0CMSRPResponse@@QAE@IVRStringF@@@Z @ 18 NONAME ; CMSRPResponse::CMSRPResponse(unsigned int, class RStringF) + ??1CMSRPFromPathHeader@@UAE@XZ @ 19 NONAME ; CMSRPFromPathHeader::~CMSRPFromPathHeader(void) + ?ExternalizeL@CMSRPMessage@@UAEXAAVRWriteStream@@@Z @ 20 NONAME ; void CMSRPMessage::ExternalizeL(class RWriteStream &) + ??1CMSRPMessageIdHeader@@UAE@XZ @ 21 NONAME ; CMSRPMessageIdHeader::~CMSRPMessageIdHeader(void) + ?SetSuccessReportHeader@CMSRPMessageBase@@QAEXPAVCMSRPSuccessReportHeader@@@Z @ 22 NONAME ; void CMSRPMessageBase::SetSuccessReportHeader(class CMSRPSuccessReportHeader *) + ?InternalizeL@CMSRPMessage@@SAPAV1@AAVRReadStream@@@Z @ 23 NONAME ; class CMSRPMessage * CMSRPMessage::InternalizeL(class RReadStream &) + ?NewLC@CMSRPToPathHeader@@SAPAV1@PAVCUri8@@@Z @ 24 NONAME ; class CMSRPToPathHeader * CMSRPToPathHeader::NewLC(class CUri8 *) + ?ToTextLC@CMSRPHeaderBase@@QBEPAVHBufC8@@XZ @ 25 NONAME ; class HBufC8 * CMSRPHeaderBase::ToTextLC(void) const + ?InternalizeValueL@CMSRPToPathHeader@@SAPAV1@AAVRReadStream@@@Z @ 26 NONAME ; class CMSRPToPathHeader * CMSRPToPathHeader::InternalizeValueL(class RReadStream &) + ??1CMSRPFromToHeaderBase@@UAE@XZ @ 27 NONAME ; CMSRPFromToHeaderBase::~CMSRPFromToHeaderBase(void) + ??8CMSRPFromToHeaderBase@@QBEHABV0@@Z @ 28 NONAME ; int CMSRPFromToHeaderBase::operator==(class CMSRPFromToHeaderBase const &) const + ?SuccessReportHeader@CMSRPMessageBase@@QBEPBVCMSRPSuccessReportHeader@@XZ @ 29 NONAME ; class CMSRPSuccessReportHeader const * CMSRPMessageBase::SuccessReportHeader(void) const + ?ExternalizeValueL@CMSRPContentTypeHeader@@QBEXAAVRWriteStream@@@Z @ 30 NONAME ; void CMSRPContentTypeHeader::ExternalizeValueL(class RWriteStream &) const + ?InternalizeValueL@CMSRPMessageIdHeader@@SAPAV1@AAVRReadStream@@@Z @ 31 NONAME ; class CMSRPMessageIdHeader * CMSRPMessageIdHeader::InternalizeValueL(class RReadStream &) + ?TotalLength@CMSRPByteRangeHeader@@QBEHXZ @ 32 NONAME ; int CMSRPByteRangeHeader::TotalLength(void) const + ?SetMessageIdHeader@CMSRPMessageBase@@QAEXPAVCMSRPMessageIdHeader@@@Z @ 33 NONAME ; void CMSRPMessageBase::SetMessageIdHeader(class CMSRPMessageIdHeader *) + ?NewL@CMSRPFailureReportHeader@@SAPAV1@ABVRStringF@@@Z @ 34 NONAME ; class CMSRPFailureReportHeader * CMSRPFailureReportHeader::NewL(class RStringF const &) + ?FromPathHeader@CMSRPMessageBase@@QBEPBVCMSRPFromPathHeader@@XZ @ 35 NONAME ; class CMSRPFromPathHeader const * CMSRPMessageBase::FromPathHeader(void) const + ?DecodeL@CMSRPToPathHeader@@SAPAV1@ABVTDesC8@@@Z @ 36 NONAME ; class CMSRPToPathHeader * CMSRPToPathHeader::DecodeL(class TDesC8 const &) + ?ToPathHeader@CMSRPMessageBase@@QBEPBVCMSRPToPathHeader@@XZ @ 37 NONAME ; class CMSRPToPathHeader const * CMSRPMessageBase::ToPathHeader(void) const + ??0CMSRPResponse@@QAE@XZ @ 38 NONAME ; CMSRPResponse::CMSRPResponse(void) + ?OpenL@MSRPStrings@@SAXAAVRStringPool@@@Z @ 39 NONAME ; void MSRPStrings::OpenL(class RStringPool &) + ??1CMSRPContentTypeHeader@@UAE@XZ @ 40 NONAME ; CMSRPContentTypeHeader::~CMSRPContentTypeHeader(void) + ?NewL@CMSRPFromPathHeader@@SAPAV1@PAVCUri8@@@Z @ 41 NONAME ; class CMSRPFromPathHeader * CMSRPFromPathHeader::NewL(class CUri8 *) + ?FailureReportHeader@CMSRPMessageBase@@QBEPBVCMSRPFailureReportHeader@@XZ @ 42 NONAME ; class CMSRPFailureReportHeader const * CMSRPMessageBase::FailureReportHeader(void) const + ??1CMSRPHeaderBase@@UAE@XZ @ 43 NONAME ; CMSRPHeaderBase::~CMSRPHeaderBase(void) + ?ExternalizeValueL@CMSRPMessageIdHeader@@QBEXAAVRWriteStream@@@Z @ 44 NONAME ; void CMSRPMessageIdHeader::ExternalizeValueL(class RWriteStream &) const + ?NewLC@CMSRPMessageIdHeader@@SAPAV1@ABVTDesC8@@@Z @ 45 NONAME ; class CMSRPMessageIdHeader * CMSRPMessageIdHeader::NewLC(class TDesC8 const &) + ??1CMSRPResponse@@UAE@XZ @ 46 NONAME ; CMSRPResponse::~CMSRPResponse(void) + ?NewL@CMSRPByteRangeHeader@@SAPAV1@HHH@Z @ 47 NONAME ; class CMSRPByteRangeHeader * CMSRPByteRangeHeader::NewL(int, int, int) + ?NewL@CMSRPSuccessReportHeader@@SAPAV1@ABVRStringF@@@Z @ 48 NONAME ; class CMSRPSuccessReportHeader * CMSRPSuccessReportHeader::NewL(class RStringF const &) + ??1CMSRPFailureReportHeader@@UAE@XZ @ 49 NONAME ; CMSRPFailureReportHeader::~CMSRPFailureReportHeader(void) + ?Pool@MSRPStrings@@SA?AVRStringPool@@XZ @ 50 NONAME ; class RStringPool MSRPStrings::Pool(void) + ?SetTotalLength@CMSRPByteRangeHeader@@QAEXH@Z @ 51 NONAME ; void CMSRPByteRangeHeader::SetTotalLength(int) + ??1CMSRPSuccessReportHeader@@UAE@XZ @ 52 NONAME ; CMSRPSuccessReportHeader::~CMSRPSuccessReportHeader(void) + ?NewL@CMSRPContentTypeHeader@@SAPAV1@ABVTDesC8@@@Z @ 53 NONAME ; class CMSRPContentTypeHeader * CMSRPContentTypeHeader::NewL(class TDesC8 const &) + ?NewLC@CMSRPContentTypeHeader@@SAPAV1@ABVTDesC8@@@Z @ 54 NONAME ; class CMSRPContentTypeHeader * CMSRPContentTypeHeader::NewLC(class TDesC8 const &) + ??1CMSRPMessage@@UAE@XZ @ 55 NONAME ; CMSRPMessage::~CMSRPMessage(void) + ?InternalizeL@CMSRPResponse@@SAPAV1@AAVRReadStream@@@Z @ 56 NONAME ; class CMSRPResponse * CMSRPResponse::InternalizeL(class RReadStream &) + ?Content@CMSRPMessage@@QAEABVTDesC8@@XZ @ 57 NONAME ; class TDesC8 const & CMSRPMessage::Content(void) + ??1CMSRPToPathHeader@@UAE@XZ @ 58 NONAME ; CMSRPToPathHeader::~CMSRPToPathHeader(void) + ?SetContent@CMSRPMessage@@QAEXPAVHBufC8@@@Z @ 59 NONAME ; void CMSRPMessage::SetContent(class HBufC8 *) + ?Table@MSRPStrings@@SAABUTStringTable@@XZ @ 60 NONAME ; struct TStringTable const & MSRPStrings::Table(void) + ?StatusCode@CMSRPResponse@@QBEIXZ @ 61 NONAME ; unsigned int CMSRPResponse::StatusCode(void) const + ?ContentTypeHeader@CMSRPMessageBase@@QBEPBVCMSRPContentTypeHeader@@XZ @ 62 NONAME ; class CMSRPContentTypeHeader const * CMSRPMessageBase::ContentTypeHeader(void) const + ?SetContentTypeHeader@CMSRPMessageBase@@QAEXPAVCMSRPContentTypeHeader@@@Z @ 63 NONAME ; void CMSRPMessageBase::SetContentTypeHeader(class CMSRPContentTypeHeader *) + ?ExternalizeValueL@CMSRPSuccessReportHeader@@QBEXAAVRWriteStream@@@Z @ 64 NONAME ; void CMSRPSuccessReportHeader::ExternalizeValueL(class RWriteStream &) const + ?InternalizeValueL@CMSRPByteRangeHeader@@SAPAV1@AAVRReadStream@@@Z @ 65 NONAME ; class CMSRPByteRangeHeader * CMSRPByteRangeHeader::InternalizeValueL(class RReadStream &) + ?IsResponse@CMSRPResponse@@SAHABVTDesC8@@@Z @ 66 NONAME ; int CMSRPResponse::IsResponse(class TDesC8 const &) + ?EndPosition@CMSRPByteRangeHeader@@QBEHXZ @ 67 NONAME ; int CMSRPByteRangeHeader::EndPosition(void) const + ?ToTextL@CMSRPHeaderBase@@QBEPAVHBufC8@@XZ @ 68 NONAME ; class HBufC8 * CMSRPHeaderBase::ToTextL(void) const + ??0CMSRPMessage@@QAE@XZ @ 69 NONAME ; CMSRPMessage::CMSRPMessage(void) + ?StringF@MSRPStrings@@SA?AVRStringF@@H@Z @ 70 NONAME ; class RStringF MSRPStrings::StringF(int) + ?SetFailureReportHeader@CMSRPMessageBase@@QAEXPAVCMSRPFailureReportHeader@@@Z @ 71 NONAME ; void CMSRPMessageBase::SetFailureReportHeader(class CMSRPFailureReportHeader *) + ?NewL@CMSRPMessageIdHeader@@SAPAV1@ABVTDesC8@@@Z @ 72 NONAME ; class CMSRPMessageIdHeader * CMSRPMessageIdHeader::NewL(class TDesC8 const &) + ?IsMessage@CMSRPMessage@@SAHABVTDesC8@@@Z @ 73 NONAME ; int CMSRPMessage::IsMessage(class TDesC8 const &) + ?SetStartPosition@CMSRPByteRangeHeader@@QAEXH@Z @ 74 NONAME ; void CMSRPByteRangeHeader::SetStartPosition(int) + ?SetFromPathHeader@CMSRPMessageBase@@QAEXPAVCMSRPFromPathHeader@@@Z @ 75 NONAME ; void CMSRPMessageBase::SetFromPathHeader(class CMSRPFromPathHeader *) + ?ByteRangeHeader@CMSRPMessageBase@@QBEPBVCMSRPByteRangeHeader@@XZ @ 76 NONAME ; class CMSRPByteRangeHeader const * CMSRPMessageBase::ByteRangeHeader(void) const + ?ExternalizeValueL@CMSRPFromToHeaderBase@@QBEXAAVRWriteStream@@@Z @ 77 NONAME ; void CMSRPFromToHeaderBase::ExternalizeValueL(class RWriteStream &) const + ??1CMSRPByteRangeHeader@@UAE@XZ @ 78 NONAME ; CMSRPByteRangeHeader::~CMSRPByteRangeHeader(void) + ?NewLC@CMSRPFromPathHeader@@SAPAV1@PAVCUri8@@@Z @ 79 NONAME ; class CMSRPFromPathHeader * CMSRPFromPathHeader::NewLC(class CUri8 *) + ?InternalizeValueL@CMSRPContentTypeHeader@@SAPAV1@AAVRReadStream@@@Z @ 80 NONAME ; class CMSRPContentTypeHeader * CMSRPContentTypeHeader::InternalizeValueL(class RReadStream &) + ?MessageIdHeader@CMSRPMessageBase@@QBEPBVCMSRPMessageIdHeader@@XZ @ 81 NONAME ; class CMSRPMessageIdHeader const * CMSRPMessageBase::MessageIdHeader(void) const + ?StartPosition@CMSRPByteRangeHeader@@QBEHXZ @ 82 NONAME ; int CMSRPByteRangeHeader::StartPosition(void) const + ?SetByteRangeHeader@CMSRPMessageBase@@QAEXPAVCMSRPByteRangeHeader@@@Z @ 83 NONAME ; void CMSRPMessageBase::SetByteRangeHeader(class CMSRPByteRangeHeader *) + ?SetReasonPhrase@CMSRPResponse@@QAEXVRStringF@@@Z @ 84 NONAME ; void CMSRPResponse::SetReasonPhrase(class RStringF) + ?ExternalizeValueL@CMSRPByteRangeHeader@@QBEXAAVRWriteStream@@@Z @ 85 NONAME ; void CMSRPByteRangeHeader::ExternalizeValueL(class RWriteStream &) const + ?NewLC@CMSRPFailureReportHeader@@SAPAV1@ABVRStringF@@@Z @ 86 NONAME ; class CMSRPFailureReportHeader * CMSRPFailureReportHeader::NewLC(class RStringF const &) + ?ExternalizeL@CMSRPResponse@@UAEXAAVRWriteStream@@@Z @ 87 NONAME ; void CMSRPResponse::ExternalizeL(class RWriteStream &) + ?GetNotifyProgress@CMSRPMessage@@QAEHXZ @ 88 NONAME ; int CMSRPMessage::GetNotifyProgress(void) + ?SetNotifyProgress@CMSRPMessage@@QAEXH@Z @ 89 NONAME ; void CMSRPMessage::SetNotifyProgress(int) + ?SetFileName@CMSRPMessage@@QAEXABV?$TBuf@$0BAA@@@@Z @ 90 NONAME ; void CMSRPMessage::SetFileName(class TBuf<256> const &) + ?GetFileName@CMSRPMessage@@QAEAAV?$TBuf@$0BAA@@@XZ @ 91 NONAME ; class TBuf<256> & CMSRPMessage::GetFileName(void) + ?IsFile@CMSRPMessage@@QAEHXZ @ 92 NONAME ; int CMSRPMessage::IsFile(void) + ?SetFileSize@CMSRPMessage@@QAEXH@Z @ 93 NONAME ; void CMSRPMessage::SetFileSize(int) + ?GetFileSize@CMSRPMessage@@QAEHXZ @ 94 NONAME ; int CMSRPMessage::GetFileSize(void) + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/eabi/msrpheaderu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/eabi/msrpheaderu.def Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,148 @@ +EXPORTS + _ZN11MSRPStrings4PoolEv @ 1 NONAME + _ZN11MSRPStrings5CloseEv @ 2 NONAME + _ZN11MSRPStrings5OpenLER11RStringPool @ 3 NONAME + _ZN11MSRPStrings5OpenLEv @ 4 NONAME + _ZN11MSRPStrings5TableEv @ 5 NONAME + _ZN11MSRPStrings7StringFEi @ 6 NONAME + _ZN12CMSRPMessage10SetContentEP6HBufC8 @ 7 NONAME + _ZN12CMSRPMessage11GetFileNameEv @ 8 NONAME + _ZN12CMSRPMessage11GetFileSizeEv @ 9 NONAME + _ZN12CMSRPMessage11SetFileNameERK4TBufILi256EE @ 10 NONAME + _ZN12CMSRPMessage11SetFileSizeEi @ 11 NONAME + _ZN12CMSRPMessage12ExternalizeLER12RWriteStream @ 12 NONAME + _ZN12CMSRPMessage12InternalizeLER11RReadStream @ 13 NONAME + _ZN12CMSRPMessage17GetNotifyProgressEv @ 14 NONAME + _ZN12CMSRPMessage17SetNotifyProgressEi @ 15 NONAME + _ZN12CMSRPMessage6IsFileEv @ 16 NONAME + _ZN12CMSRPMessage7ContentEv @ 17 NONAME + _ZN12CMSRPMessage9IsMessageERK6TDesC8 @ 18 NONAME + _ZN12CMSRPMessageC1Ev @ 19 NONAME + _ZN12CMSRPMessageC2Ev @ 20 NONAME + _ZN12CMSRPMessageD0Ev @ 21 NONAME + _ZN12CMSRPMessageD1Ev @ 22 NONAME + _ZN12CMSRPMessageD2Ev @ 23 NONAME + _ZN13CMSRPResponse10IsResponseERK6TDesC8 @ 24 NONAME + _ZN13CMSRPResponse12ExternalizeLER12RWriteStream @ 25 NONAME + _ZN13CMSRPResponse12InternalizeLER11RReadStream @ 26 NONAME + _ZN13CMSRPResponse14SetStatusCodeLEj @ 27 NONAME + _ZN13CMSRPResponse15SetReasonPhraseE8RStringF @ 28 NONAME + _ZN13CMSRPResponseC1Ej8RStringF @ 29 NONAME + _ZN13CMSRPResponseC1Ev @ 30 NONAME + _ZN13CMSRPResponseC2Ej8RStringF @ 31 NONAME + _ZN13CMSRPResponseC2Ev @ 32 NONAME + _ZN13CMSRPResponseD0Ev @ 33 NONAME + _ZN13CMSRPResponseD1Ev @ 34 NONAME + _ZN13CMSRPResponseD2Ev @ 35 NONAME + _ZN15CMSRPHeaderBaseD0Ev @ 36 NONAME + _ZN15CMSRPHeaderBaseD1Ev @ 37 NONAME + _ZN15CMSRPHeaderBaseD2Ev @ 38 NONAME + _ZN16CMSRPMessageBase15SetToPathHeaderEP17CMSRPToPathHeader @ 39 NONAME + _ZN16CMSRPMessageBase17SetFromPathHeaderEP19CMSRPFromPathHeader @ 40 NONAME + _ZN16CMSRPMessageBase18SetByteRangeHeaderEP20CMSRPByteRangeHeader @ 41 NONAME + _ZN16CMSRPMessageBase18SetMessageIdHeaderEP20CMSRPMessageIdHeader @ 42 NONAME + _ZN16CMSRPMessageBase20SetContentTypeHeaderEP22CMSRPContentTypeHeader @ 43 NONAME + _ZN16CMSRPMessageBase22SetFailureReportHeaderEP24CMSRPFailureReportHeader @ 44 NONAME + _ZN16CMSRPMessageBase22SetSuccessReportHeaderEP24CMSRPSuccessReportHeader @ 45 NONAME + _ZN16CMSRPMessageBaseD0Ev @ 46 NONAME + _ZN16CMSRPMessageBaseD1Ev @ 47 NONAME + _ZN16CMSRPMessageBaseD2Ev @ 48 NONAME + _ZN17CMSRPToPathHeader17InternalizeValueLER11RReadStream @ 49 NONAME + _ZN17CMSRPToPathHeader4NewLEP5CUri8 @ 50 NONAME + _ZN17CMSRPToPathHeader5NewLCEP5CUri8 @ 51 NONAME + _ZN17CMSRPToPathHeader7DecodeLERK6TDesC8 @ 52 NONAME + _ZN17CMSRPToPathHeaderD0Ev @ 53 NONAME + _ZN17CMSRPToPathHeaderD1Ev @ 54 NONAME + _ZN17CMSRPToPathHeaderD2Ev @ 55 NONAME + _ZN19CMSRPFromPathHeader17InternalizeValueLER11RReadStream @ 56 NONAME + _ZN19CMSRPFromPathHeader4NewLEP5CUri8 @ 57 NONAME + _ZN19CMSRPFromPathHeader5NewLCEP5CUri8 @ 58 NONAME + _ZN19CMSRPFromPathHeader7DecodeLERK6TDesC8 @ 59 NONAME + _ZN19CMSRPFromPathHeaderD0Ev @ 60 NONAME + _ZN19CMSRPFromPathHeaderD1Ev @ 61 NONAME + _ZN19CMSRPFromPathHeaderD2Ev @ 62 NONAME + _ZN20CMSRPByteRangeHeader14SetEndPositionEi @ 63 NONAME + _ZN20CMSRPByteRangeHeader14SetTotalLengthEi @ 64 NONAME + _ZN20CMSRPByteRangeHeader16SetStartPositionEi @ 65 NONAME + _ZN20CMSRPByteRangeHeader17InternalizeValueLER11RReadStream @ 66 NONAME + _ZN20CMSRPByteRangeHeader4NewLEiii @ 67 NONAME + _ZN20CMSRPByteRangeHeader5NewLCEiii @ 68 NONAME + _ZN20CMSRPByteRangeHeaderD0Ev @ 69 NONAME + _ZN20CMSRPByteRangeHeaderD1Ev @ 70 NONAME + _ZN20CMSRPByteRangeHeaderD2Ev @ 71 NONAME + _ZN20CMSRPMessageIdHeader17InternalizeValueLER11RReadStream @ 72 NONAME + _ZN20CMSRPMessageIdHeader4NewLERK6TDesC8 @ 73 NONAME + _ZN20CMSRPMessageIdHeader5NewLCERK6TDesC8 @ 74 NONAME + _ZN20CMSRPMessageIdHeaderD0Ev @ 75 NONAME + _ZN20CMSRPMessageIdHeaderD1Ev @ 76 NONAME + _ZN20CMSRPMessageIdHeaderD2Ev @ 77 NONAME + _ZN21CMSRPFromToHeaderBaseD0Ev @ 78 NONAME + _ZN21CMSRPFromToHeaderBaseD1Ev @ 79 NONAME + _ZN21CMSRPFromToHeaderBaseD2Ev @ 80 NONAME + _ZN22CMSRPContentTypeHeader17InternalizeValueLER11RReadStream @ 81 NONAME + _ZN22CMSRPContentTypeHeader4NewLERK6TDesC8 @ 82 NONAME + _ZN22CMSRPContentTypeHeader5NewLCERK6TDesC8 @ 83 NONAME + _ZN22CMSRPContentTypeHeaderD0Ev @ 84 NONAME + _ZN22CMSRPContentTypeHeaderD1Ev @ 85 NONAME + _ZN22CMSRPContentTypeHeaderD2Ev @ 86 NONAME + _ZN24CMSRPFailureReportHeader17InternalizeValueLER11RReadStream @ 87 NONAME + _ZN24CMSRPFailureReportHeader4NewLERK8RStringF @ 88 NONAME + _ZN24CMSRPFailureReportHeader5NewLCERK8RStringF @ 89 NONAME + _ZN24CMSRPFailureReportHeaderD0Ev @ 90 NONAME + _ZN24CMSRPFailureReportHeaderD1Ev @ 91 NONAME + _ZN24CMSRPFailureReportHeaderD2Ev @ 92 NONAME + _ZN24CMSRPSuccessReportHeader17InternalizeValueLER11RReadStream @ 93 NONAME + _ZN24CMSRPSuccessReportHeader4NewLERK8RStringF @ 94 NONAME + _ZN24CMSRPSuccessReportHeader5NewLCERK8RStringF @ 95 NONAME + _ZN24CMSRPSuccessReportHeaderD0Ev @ 96 NONAME + _ZN24CMSRPSuccessReportHeaderD1Ev @ 97 NONAME + _ZN24CMSRPSuccessReportHeaderD2Ev @ 98 NONAME + _ZNK12CMSRPMessage9IsContentEv @ 99 NONAME + _ZNK13CMSRPResponse10StatusCodeEv @ 100 NONAME + _ZNK13CMSRPResponse12ReasonPhraseEv @ 101 NONAME + _ZNK15CMSRPHeaderBase13ToTextValueLCEv @ 102 NONAME + _ZNK15CMSRPHeaderBase7ToTextLEv @ 103 NONAME + _ZNK15CMSRPHeaderBase8ToTextLCEv @ 104 NONAME + _ZNK16CMSRPMessageBase12ToPathHeaderEv @ 105 NONAME + _ZNK16CMSRPMessageBase14FromPathHeaderEv @ 106 NONAME + _ZNK16CMSRPMessageBase15ByteRangeHeaderEv @ 107 NONAME + _ZNK16CMSRPMessageBase15MessageIdHeaderEv @ 108 NONAME + _ZNK16CMSRPMessageBase17ContentTypeHeaderEv @ 109 NONAME + _ZNK16CMSRPMessageBase19FailureReportHeaderEv @ 110 NONAME + _ZNK16CMSRPMessageBase19SuccessReportHeaderEv @ 111 NONAME + _ZNK20CMSRPByteRangeHeader11EndPositionEv @ 112 NONAME + _ZNK20CMSRPByteRangeHeader11TotalLengthEv @ 113 NONAME + _ZNK20CMSRPByteRangeHeader13StartPositionEv @ 114 NONAME + _ZNK20CMSRPByteRangeHeader17ExternalizeValueLER12RWriteStream @ 115 NONAME + _ZNK20CMSRPMessageIdHeader17ExternalizeValueLER12RWriteStream @ 116 NONAME + _ZNK21CMSRPFromToHeaderBase17ExternalizeValueLER12RWriteStream @ 117 NONAME + _ZNK21CMSRPFromToHeaderBaseeqERKS_ @ 118 NONAME + _ZTI12CMSRPMessage @ 119 NONAME + _ZTI12CMSRPStrings @ 120 NONAME + _ZTI12CMSRPTlsPtrs @ 121 NONAME + _ZTI13CMSRPResponse @ 122 NONAME + _ZTI15CMSRPHeaderBase @ 123 NONAME + _ZTI16CMSRPMessageBase @ 124 NONAME + _ZTI17CMSRPToPathHeader @ 125 NONAME + _ZTI19CMSRPFromPathHeader @ 126 NONAME + _ZTI20CMSRPByteRangeHeader @ 127 NONAME + _ZTI20CMSRPMessageIdHeader @ 128 NONAME + _ZTI21CMSRPFromToHeaderBase @ 129 NONAME + _ZTI22CMSRPContentTypeHeader @ 130 NONAME + _ZTI24CMSRPFailureReportHeader @ 131 NONAME + _ZTI24CMSRPSuccessReportHeader @ 132 NONAME + _ZTV12CMSRPMessage @ 133 NONAME + _ZTV12CMSRPStrings @ 134 NONAME + _ZTV12CMSRPTlsPtrs @ 135 NONAME + _ZTV13CMSRPResponse @ 136 NONAME + _ZTV15CMSRPHeaderBase @ 137 NONAME + _ZTV16CMSRPMessageBase @ 138 NONAME + _ZTV17CMSRPToPathHeader @ 139 NONAME + _ZTV19CMSRPFromPathHeader @ 140 NONAME + _ZTV20CMSRPByteRangeHeader @ 141 NONAME + _ZTV20CMSRPMessageIdHeader @ 142 NONAME + _ZTV21CMSRPFromToHeaderBase @ 143 NONAME + _ZTV22CMSRPContentTypeHeader @ 144 NONAME + _ZTV24CMSRPFailureReportHeader @ 145 NONAME + _ZTV24CMSRPSuccessReportHeader @ 146 NONAME + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/group/bld.inf Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +PRJ_PLATFORMS +DEFAULT + +PRJ_MMPFILES +msrpheader.mmp + +// END OF FILE diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/group/msrpheader.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/group/msrpheader.mmp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +TARGET msrpheader.dll +TARGETTYPE dll +UID 0x1000008d 0x2002B59D + +VENDORID 0x101FB657 + +CAPABILITY All -Tcb + +SOURCEPATH ../src +SOURCE CMSRPContentTypeHeader.cpp +SOURCE CMSRPFailureReportHeader.cpp +SOURCE CMSRPFromPathHeader.cpp +SOURCE CMSRPFromToHeaderBase.cpp +SOURCE CMSRPHeaderBase.cpp +SOURCE CMSRPMessage.cpp +SOURCE CMSRPResponse.cpp +SOURCE CMSRPSuccessReportHeader.cpp +SOURCE CMSRPToPathHeader.cpp +SOURCE CMSRPStrings.cpp +SOURCE CMSRPMessageIdHeader.cpp +SOURCE CMSRPByteRangeHeader.cpp +SOURCE MSRPStrings.cpp +SOURCE CMSRPTlsPtrs.cpp +SOURCE TMSRPHeaderUtil.cpp +SOURCE CMSRPMessageBase.cpp + + +START STRINGTABLE ../strings/MSRPStrConsts.st +EXPORTPATH MW_LAYER_PLATFORM_EXPORT_PATH(.) +END + +USERINCLUDE ../inc +USERINCLUDE ../../inc + +OS_LAYER_SYSTEMINCLUDE +MW_LAYER_SYSTEMINCLUDE + +LIBRARY inetprotutil.lib +LIBRARY apmime.lib +LIBRARY estor.lib +LIBRARY bafl.lib +LIBRARY euser.lib +LIBRARY efsrv.lib +DEBUGLIBRARY flogger.lib + +EXPORTUNFROZEN + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/inc/CMSRPMessageBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/inc/CMSRPMessageBase.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,184 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPMESSAGEBASE_H +#define CMSRPMESSAGEBASE_H + +// INCLUDES +#include +#include + +// FORWARD DECLARATIONS +class CMSRPFromPathHeader; +class CMSRPToPathHeader; +class CMSRPMessageIdHeader; +class CMSRPByteRangeHeader; +class CMSRPContentTypeHeader; +class CMSRPFailureReportHeader; +class CMSRPSuccessReportHeader; + +// CONSTANTS +const TInt KMaxLengthOfShortMessage = 4096; +const TInt KLengthOfMSRPSmallBuffer = 2048; + +// CLASS DECLARATION + +/** +* @publishedAll +* +* Class provides functions for creation and manipulation of MSRP headers +* +* @lib msrpclient.lib +*/ +class CMSRPMessageBase : public CBase + { + + public: // Constructors and destructor + + /** + * Destructor. + */ + IMPORT_C virtual ~CMSRPMessageBase(); + + public: // New functions + + /** + * Sets/resets the recipient's To-Path header + * @param aTo a To-Path header to be set, the ownership is transferred + */ + IMPORT_C void SetToPathHeader( CMSRPToPathHeader* aToPath ); + + /** + * Gets the recipient's To-Path header + * @return NULL if not present. Ownership is not + * transferred. + */ + IMPORT_C const CMSRPToPathHeader* ToPathHeader() const; + + /** + * Sets/resets the From-Path header + * @param aFromPath From-Path header to be set, the ownership is transferred + */ + IMPORT_C void SetFromPathHeader( CMSRPFromPathHeader* aFromPath ); + + /** + * Returns From-Path header + * @return NULL if not present. Ownership is not + * transferred. + */ + IMPORT_C const CMSRPFromPathHeader* FromPathHeader() const; + + /** + * Sets/resets the Content-Type header + * @param aContentType ContentType header to be set, the ownership is transferred + */ + IMPORT_C void SetContentTypeHeader( CMSRPContentTypeHeader* aContentType ); + + /** + * Returns Content-Type header + * @return NULL if not present. Ownership is not + * transferred. + */ + IMPORT_C const CMSRPContentTypeHeader* ContentTypeHeader() const; + + /** + * Sets/resets the Failure-Report header + * @param aFailureReport FailureReport header to be set, the ownership is transferred + */ + IMPORT_C void SetFailureReportHeader( CMSRPFailureReportHeader* aFailureReport ); + + /** + * Returns Failure-Report header + * @return NULL if not present. Ownership is not + * transferred. + */ + IMPORT_C const CMSRPFailureReportHeader* FailureReportHeader() const; + + /** + * Sets/resets the Success-Report header + * @param aSuccessReport SuccessReport header to be set, the ownership is transferred + */ + IMPORT_C void SetSuccessReportHeader( CMSRPSuccessReportHeader* aSuccessReport ); + + /** + * Returns Success-Report header + * @return NULL if not present. Ownership is not + * transferred. + */ + IMPORT_C const CMSRPSuccessReportHeader* SuccessReportHeader() const; + + /** + * Sets/resets the Message-ID header + * @param aMessageId MessageId header to be set, the ownership is transferred + */ + IMPORT_C void SetMessageIdHeader( CMSRPMessageIdHeader* aMessageId ); + + /** + * Returns Message-ID header + * @return NULL if not present. Ownership is not + * transferred. + */ + IMPORT_C const CMSRPMessageIdHeader* MessageIdHeader() const; + + /** + * Sets/resets the Byte-Range header + * @param aByteRange ByteRange header to be set, the ownership is transferred + */ + IMPORT_C void SetByteRangeHeader( CMSRPByteRangeHeader* aByteRange ); + + /** + * Returns Byte-Range header + * @return NULL if not present. Ownership is not + * transferred. + */ + IMPORT_C const CMSRPByteRangeHeader* ByteRangeHeader() const; + + /** + * Writes the object to a RWriteStream + * @param aWriteStream a stream where the object is to be externalized + */ + virtual void ExternalizeL( RWriteStream& aWriteStream ) = 0; + + protected: + + /** + * Constructor. + */ + CMSRPMessageBase(); + + protected: // Data + + // Headers + // For setting and getting MSRP "From-Path" header field + CMSRPFromPathHeader* iFromPath; + // For setting and getting MSRP "To-Path" header field + CMSRPToPathHeader* iToPath; + // For setting and getting MSRP "Message-ID" header field + CMSRPMessageIdHeader* iMessageId; + // For setting and getting MSRP "Byte-Range" header field + CMSRPByteRangeHeader* iByteRange; + // For setting and getting MSRP "Content-Type" header field + CMSRPContentTypeHeader* iContentType; + // For setting and getting MSRP "Failure-Report" header field + CMSRPFailureReportHeader* iFailureReport; + // For setting and getting MSRP "Success-Report" header field + CMSRPSuccessReportHeader* iSuccessReport; + + }; + +#endif // CMSRPMESSAGEBASE_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/inc/CMSRPTlsPtrs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/inc/CMSRPTlsPtrs.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPTLSPTRS_H +#define CMSRPTLSPTRS_H + +// EXTERNAL INCLUDES +#include + +// FORWARD DECLARATIONS +class CMSRPStrings; + +/* +* CLASS DEFINITION +*/ +class CMSRPTlsPtrs : public CBase + { + public: + + /** + * Constructor. + * @param aStrings new CMSRPStrings object + */ + CMSRPTlsPtrs( CMSRPStrings* aStrings ); + /** + * Destructor. + */ + ~CMSRPTlsPtrs(); + + /** + * Constructor. + */ + void DestroyStrings(); + + public: + + /** + * Gives MsrpStrings object + */ + CMSRPStrings* GetMsrpString(); + + private: + + /** + * Constructor. + */ + CMSRPTlsPtrs(); + + private: // data + + // CMSRPStrings object + CMSRPStrings* iStrings; + + }; + +#endif // CMSRPTLSPTRS_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/inc/CMsrpByteRangeHeader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/inc/CMsrpByteRangeHeader.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,164 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + + +#ifndef CMSRPBYTERANGEHEADER_H +#define CMSRPBYTERANGEHEADER_H + +// INTERNAL INCLUDES +#include "CMsrpHeaderBase.h" + +// CONSTANTS + +const TInt KMaxLengthOfNumbers = 50; +_LIT8( KByteRangeSeparator, "-" ); +_LIT8( KByteRangeTotalSeparator, "/" ); + +// CLASS DECLARATION +/** +* @publishedAll +* +* Class provides functions for setting and getting MSRP "Byte-Range" header field +* +* @lib msrpclient.lib +*/ +class CMSRPByteRangeHeader : public CMSRPHeaderBase + { + public: // Constructors and destructor + + /** + * Creates a new instance of CMSRMessageIdHeader + * @param aStart start position of the bytes in data + * @param aEnd end position of bytes in the data + * @param aTotal Total length of the data + * @return a new instance of CMSRPByteRangeHeader + */ + IMPORT_C static CMSRPByteRangeHeader* NewL( + TInt aStart, TInt aEnd, TInt aTotal ); + + /** + * Creates a new instance of CMSRPByteRangeHeader and puts it to CleanupStack + * @param aStart start position of the bytes in data + * @param aEnd end position of bytes in the data + * @param aTotal Total length of the data + * @return a new instance of CMSRPByteRangeHeader + */ + IMPORT_C static CMSRPByteRangeHeader* NewLC( + TInt aStart, TInt aEnd, TInt aTotal ); + + /** + * Creates a new instance of CMSRMessageIdHeader + * @return a new instance of CMSRPByteRangeHeader + */ + static CMSRPByteRangeHeader* NewL( ); + + /** + * Destructor, deletes the resources of CMSRPByteRangeHeader. + */ + IMPORT_C ~CMSRPByteRangeHeader(); + + public: // New functions + + /** + * Constructs an instance of a CMSRPByteRangeHeader from a RReadStream + * @param aReadStream a stream containing the value of the + * externalized object (header name not included). + * @return an instance of a CMSRPByteRangeHeader + */ + IMPORT_C static CMSRPByteRangeHeader* + InternalizeValueL( RReadStream& aReadStream ); + + /** + * Sets the start position of the bytes in data + * @param aStartPos start position of bytes + */ + IMPORT_C void SetStartPosition( TInt aStartPos ); + + /** + * Gets the start position of the bytes in data + */ + IMPORT_C TInt StartPosition( ) const; + + /** + * Sets the end position of the bytes in data + * @param aEndPos start position of bytes + */ + IMPORT_C void SetEndPosition( TInt aEndPos ); + + /** + * Gets the end position of the bytes in data + */ + IMPORT_C TInt EndPosition( ) const; + + /** + * Sets the total length of bytes in data + * @param aTotal total number of bytes + */ + IMPORT_C void SetTotalLength( TInt aTotal ); + + /** + * Gets the total number of the bytes in data + */ + IMPORT_C TInt TotalLength( ) const; + + public: // From CMSRPHeaderBase + + IMPORT_C void ExternalizeValueL( RWriteStream& aWriteStream ) const; + + protected: // From CMSRPHeaderBase + + RStringF Name() const; + HBufC8* ToTextValueL() const; + + private: // Constructors + + /** + * Contructor. + */ + CMSRPByteRangeHeader( ); + /** + * Contructor. + * @param aStart start position of the bytes in data + * @param aEnd end position of bytes in the data + * @param aTotal Total length of the data + */ + CMSRPByteRangeHeader( + TInt aStart, TInt aEnd, TInt aTotal ); + /** + * two-phased contructor. + */ + void ConstructL( ) const; + + private: // new functions + /** + * Internalize external object data + * @param aReadStream a stream containing the value of the + * externalized object (header name not included). + */ + void DoInternalizeValueL( RReadStream& aReadStream ); + + private: // variables + + // byte range values + TInt iStartPosition; + TInt iEndPosition; + TInt iTotalBytes; + + }; + +#endif // CMSRPBYTERANGEHEADER_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/inc/CMsrpContentTypeHeader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/inc/CMsrpContentTypeHeader.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,120 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + + +#ifndef CMSRPCONTENTTYPEHEADER_H +#define CMSRPCONTENTTYPEHEADER_H + +// EXTERNAL INCLUDES +#include +#include + +// INTERNAL INCLUDES +#include "CMsrpHeaderBase.h" + +// CLASS DECLARATION +/** +* @publishedAll +* +* Class provides functions for setting and getting MSRP "Content-Type" header field +* +* @lib msrpclient.lib +*/ +class CMSRPContentTypeHeader : public CMSRPHeaderBase + { + public: // Constructors and destructor + + /** + * Creates a new instance of CMSRContentTypeHeader + * @param aMediaType Media type, including subtype in the form + type/subtype + * @return a new instance of CMSRPContentTypeHeader + */ + IMPORT_C static CMSRPContentTypeHeader* NewL( const TDesC8& aMediaType ); + + /** + * Creates a new instance of CMSRPContentTypeHeader and puts it to CleanupStack + * @param aMediaType Media type, including subtype in the form + type/subtype + * @return a new instance of CMSRPContentTypeHeader + */ + IMPORT_C static CMSRPContentTypeHeader* NewLC( const TDesC8& aMediaType ); + + /** + * Creates a new instance of CMSRContentTypeHeader + * @return a new instance of CMSRPContentTypeHeader + */ + static CMSRPContentTypeHeader* NewL( ); + + /** + * Destructor, deletes the resources of CMSRPContentTypeHeader. + */ + IMPORT_C ~CMSRPContentTypeHeader(); + + + public: // New functions + + /** + * Constructs an instance of a CMSRPContentTypeHeader from a RReadStream + * @param aReadStream a stream containing the value of the + * externalized object (header name not included). + * @return an instance of a CMSRPContentTypeHeader + */ + IMPORT_C static CMSRPContentTypeHeader* + InternalizeValueL( RReadStream& aReadStream ); + + + public: // From CMSRPHeaderBase + + IMPORT_C void ExternalizeValueL( RWriteStream& aWriteStream ) const; + + protected: // From CMSRPHeaderBase + + RStringF Name() const; + HBufC8* ToTextValueL() const; + + private: // Constructors + + /** + * Contstructor + */ + CMSRPContentTypeHeader( ); + + /** + * Second-phase contstructor + * @param aMediaType Media type, including subtype in the form + type/subtype + */ + void ConstructL( const TDesC8& aMediaType ); + + /** + * Second-phase constructor + */ + void ConstructL( ); + + private: // new functions + void DoInternalizeValueL( RReadStream& aReadStream ); + + private: // variables + + // Data type + TDataType iDataType; + + }; + +#endif // CMSRPCONTENTTYPEHEADER_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/inc/CMsrpFailureReportHeader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/inc/CMsrpFailureReportHeader.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,113 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + + +#ifndef CMSRPFAILUREREPORTHEADER_H +#define CMSRPFAILUREREPORTHEADER_H + +// INTERNAL INCLUDES +#include "CMsrpHeaderBase.h" + +// CLASS DECLARATION +/** +* @publishedAll +* +* Class provides functions for setting and getting MSRP "Failure-Report" header field +* +* @lib msrpclient.lib +*/ +class CMSRPFailureReportHeader : public CMSRPHeaderBase + { + public: // Constructors and destructor + + /** + * Creates a new instance of CMSRFailureReportHeader + * @param aType type of the content + * @return a new instance of CMSRPFailureReportHeader + */ + IMPORT_C static CMSRPFailureReportHeader* NewL( const RStringF& aType ); + + /** + * Creates a new instance of CMSRPFailureReportHeader and puts it to CleanupStack + * @param aType type of the content + * @return a new instance of CMSRPFailureReportHeader + */ + IMPORT_C static CMSRPFailureReportHeader* NewLC( const RStringF& aType ); + + /** + * Creates a new instance of CMSRPFailureReportHeader and puts it to CleanupStack + * @return a new instance of CMSRPFailureReportHeader + */ + static CMSRPFailureReportHeader* NewL( ); + + /** + * Destructor, deletes the resources of CMSRPFailureReportHeader. + */ + IMPORT_C ~CMSRPFailureReportHeader(); + + + public: // New functions + + /** + * Constructs an instance of a CMSRPFailureReportHeader from a RReadStream + * @param aReadStream a stream containing the value of the + * externalized object (header name not included). + * @return an instance of a CMSRPFailureReportHeader + */ + IMPORT_C static CMSRPFailureReportHeader* + InternalizeValueL( RReadStream& aReadStream ); + + + public: // From CMSRPHeaderBase + + IMPORT_C void ExternalizeValueL( RWriteStream& aWriteStream ) const; + + protected: // From CMSRPHeaderBase + + RStringF Name() const; + HBufC8* ToTextValueL() const; + + private: // Constructors + + /** + * Contstructor + */ + CMSRPFailureReportHeader(); + + /** + * Second-phase Contstructor + * @param aType type of the content + */ + void ConstructL( RStringF aType ); + + /** + * Second-phase Contstructor + */ + void ConstructL( ); + + private: // new functions + void DoInternalizeValueL( RReadStream& aReadStream ); + + private: // variables + + // value as a string + RStringF iReportType; + + }; + +#endif // CMSRPFAILUREREPORTHEADER_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/inc/CMsrpFromPathHeader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/inc/CMsrpFromPathHeader.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,112 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + + +#ifndef CMSRPFROMPATHHEADER_H +#define CMSRPFROMPATHHEADER_H + +// INTERNAL INCLUDES +#include "CMsrpFromToHeaderBase.h" + +/* +* @publishedAll +* +* Class provides functions for setting and getting MSRP "From-Path" header field +* +* @lib msrpclient.lib +*/ +class CMSRPFromPathHeader : public CMSRPFromToHeaderBase + { + public: // Constructors and destructor + + /** + * Constructs a CMSRPFromPathHeader from textual representation + * of the header's value part. + * @param aUri a value part of a "From-Path"-header + * @return a new instance of CMSRPFromPathHeader + */ + IMPORT_C static CMSRPFromPathHeader* DecodeL( const TDesC8& aUri ); + + /** + * Creates a new instance of CMSRFromPathHeader + * @param aUri a value part of a "From-Path"-header + * @return a new instance of CMSRPFromPathHeader + */ + IMPORT_C static CMSRPFromPathHeader* NewL( CUri8* aUri ); + + /** + * Creates a new instance of CMSRPFromPathHeader and puts it to CleanupStack + * @param aUri a value part of a "From-Path"-header + * @return a new instance of CMSRPFromPathHeader + */ + IMPORT_C static CMSRPFromPathHeader* NewLC( CUri8* aUri ); + + /** + * Creates a new instance of CMSRFromPathHeader + * @return a new instance of CMSRPFromPathHeader + */ + static CMSRPFromPathHeader* NewL( ); + + /** + * Destructor, deletes the resources of CMSRPFromPathHeader. + */ + IMPORT_C ~CMSRPFromPathHeader(); + + + public: // New functions + + /** + * Constructs an instance of a CMSRPFromPathHeader from a RReadStream + * @param aReadStream a stream containing the value of the + * externalized object (header name not included). + * @return an instance of a CMSRPFromPathHeader + */ + IMPORT_C static CMSRPFromPathHeader* + InternalizeValueL( RReadStream& aReadStream ); + + + protected: // From CMSRPHeaderBase + + /** + * From CMSRPHeaderBase Name + */ + RStringF Name() const; + + protected: // constructors + + /** + * Constructor + * @param aUri a value part of a "From-Path"-header + */ + void ConstructL( CUri8* aUri ); + + /** + * Constructor + */ + void ConstructL( ); + + private: // Constructors + + /** + * Constructor + */ + CMSRPFromPathHeader(); + + }; + +#endif // CMSRPFROMPATHHEADER_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/inc/CMsrpFromToHeaderBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/inc/CMsrpFromToHeaderBase.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + + +#ifndef CMSRPFROMTOHEADERBASE_H +#define CMSRPFROMTOHEADERBASE_H + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include "CMsrpHeaderBase.h" + +// CLASS DECLARATION +/** +* @publishedAll +* +* Class provides functions for setting and getting parameters in MSRP "From-Path" +* and "To-Path" header. +* +* @lib msrpclient.lib +*/ +class CMSRPFromToHeaderBase : public CMSRPHeaderBase + { + public: // Constructors and destructor + + /** + * Destructor, deletes the resources of CMSRPFromToHeaderBase. + */ + IMPORT_C virtual ~CMSRPFromToHeaderBase(); + + + public: // New functions + + /** + * Compares this instance to another "From-Path" or "To-Path" header object + * @param aHeader a header to compare to + * @return ETrue, if the objects are equal otherwise EFalse + */ + IMPORT_C TBool operator==( const CMSRPFromToHeaderBase& aHeader ) const; + + public: // From CMSRPHeaderBase + + IMPORT_C void ExternalizeValueL( RWriteStream& aWriteStream ) const; + + protected: // From CMSRPHeaderBase + + HBufC8* ToTextValueL() const; + + protected: + + /** + * Constructor + */ + CMSRPFromToHeaderBase(); + + protected: // New functions + + /** + * Parce URI string + * @param aReadStream URI string in one piece + */ + void DoInternalizeValueL( RReadStream& aReadStream ); + + protected: // data + + // MSRP url (from or to header field) + CUri8* iUri; + }; + + +#endif // CMSRPFROMTOHEADERBASE_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/inc/CMsrpHeaderBase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/inc/CMsrpHeaderBase.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + + +#ifndef CMSRPHEADERBASE_H +#define CMSRPHEADERBASE_H + +// EXTERNAL INCLUDES +#include +#include +#include + +// CONSTANTS +_LIT8( KColonAndSpace, ": " ); + +// CLASS DECLARATION +/** +* @publishedAll +* +* Class provides a generic interface for all the MSRP headers. +* +* @lib msrpclient.lib +*/ +class CMSRPHeaderBase : public CBase + { + public: // Constructors and destructors + + /** + * Destructor, deletes the resources of CMSRPHeaderBase. + */ + IMPORT_C virtual ~CMSRPHeaderBase(); + + public: // New functions + + + /** + * Encodes the header (name and value) into its textual representation. + * @return a textual representation of the complete header, + * the ownership is transferred + */ + IMPORT_C HBufC8* ToTextL() const; + + /** + * Encodes the header (name and value) into its textual representation + * and pushes it to the CleanupStack. + * @return a textual representation of the complete header, + * the ownership is transferred + */ + IMPORT_C HBufC8* ToTextLC() const; + + /** + * Encodes the header's value into its textual representation + * and pushes it to the CleanupStack. + * @return a textual representation of the header's value, + * the ownership is transferred + */ + IMPORT_C HBufC8* ToTextValueLC() const; + + protected: // pure virtuals + + /** + * Gets the full name of the header + * The function is implemented in each of the sub-classes. + * @return the full name of the header for example "From-Path" + */ + virtual RStringF Name() const = 0; + + /** + * Encodes the header's value into its textual representation. + * @return a textual representation of the header's value, + * the ownership is transferred + */ + virtual HBufC8* ToTextValueL() const = 0; + + protected: // Constructors + + CMSRPHeaderBase(); + }; + +#endif // CMSRPHEADERBASE_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/inc/CMsrpMessage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/inc/CMsrpMessage.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,144 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPMESSAGE_H +#define CMSRPMESSAGE_H + +// INCLUDES +#include +#include +#include + +#include "CMSRPMessageBase.h" + +/** +* @publishedAll +* +* Class provides functions for creation and manipulation of MSRP headers +*/ +class CMSRPMessage : public CMSRPMessageBase + { + public: // Constructors and destructor + + /** + * Constructor. + */ + IMPORT_C CMSRPMessage(); + + /** + * Destructor. + */ + IMPORT_C ~CMSRPMessage(); + + public: // New functions + + /** + * Sets the content of the message to be sent + * Message maximum length is 2048 bytes, longer message will + * have to be sent in chunks by the client + * @param aContent message to be sent + */ + IMPORT_C void SetContent( HBufC8* aContent ); + + /** + * Gets the content buffer, if set + * @return pointer to content buffer, ownership is not transferred + */ + IMPORT_C const TDesC8& Content( ); + + /** + * Check if the contents of the message have been set + * @return true if set + */ + IMPORT_C TBool IsContent( ) const; + + /** + * Check if the given externalised buffer contains MSRP Message + * @param aBuffer a Buffer containing the value of the + * externalized object + * @return true if Buffer contains MSRP message + */ + IMPORT_C static TBool IsMessage( const TDesC8& aBuffer ); + + /** + * Checks if File + */ + + IMPORT_C TBool IsFile( ); + + /** + * Sets the FileName for a FileSession + */ + IMPORT_C void SetFileName( const TFileName& aFileName ); + + /** + * Gets the FileName for a FileSession + */ + IMPORT_C TFileName& GetFileName( ); + + /* Set File Size */ + IMPORT_C void SetFileSize( const TInt aFileSize ); + + /* Get File Size */ + IMPORT_C TInt GetFileSize(); + + /* Set Granularity for file transfer */ + + IMPORT_C void SetNotifyProgress(TBool aNotify); + + /* Get Granularity for file transfer */ + IMPORT_C TBool GetNotifyProgress(); + + /** + * Internalizes the class from given stream + * @param aReadStream a stream containing the value of the + * externalized object + * @return Internalized CMSRPMessage object, ownership is transferred + */ + IMPORT_C static CMSRPMessage* InternalizeL( RReadStream& aReadStream ); + + public: // from base classes + + // from CMSRPMessageBase + IMPORT_C void ExternalizeL( RWriteStream& aWriteStream ); + + private: + + /** + * Internalizes this message + * @param aReadStream a stream containing the value of the + * externalized object (header name not included). + */ + void DoInternalizeL( RReadStream& aReadStream ); + + private: // Data + + // content buffer + HBufC8* iContentBuffer; + + // filename + TFileName iFileName; + + //filesize + TInt iFileSize; + + //Granularity of the file + TBool iNotifyProgress; + }; + +#endif // CMSRPMESSAGE_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/inc/CMsrpMessageIdHeader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/inc/CMsrpMessageIdHeader.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,116 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPMESSAGEIDHEADER_H +#define CMSRPMESSAGEIDHEADER_H + +// INCLUDES +#include "CMsrpHeaderBase.h" + +// CLASS DECLARATION +/** +* @publishedAll +* +* Class provides functions for setting and getting MSRP "Message-ID" header field +* +* @lib msrpclient.lib +*/ +class CMSRPMessageIdHeader : public CMSRPHeaderBase + { + public: // Constructors and destructor + + /** + * Creates a new instance of CMSRMessageIdHeader + * @param aMessageId unique message identifier + * @return a new instance of CMSRPMessageIdHeader + */ + IMPORT_C static CMSRPMessageIdHeader* NewL( const TDesC8& aMessageId ); + + /** + * Creates a new instance of CMSRPMessageIdHeader and puts it to CleanupStack + * @param aMessageId unique message identifier + * @return a new instance of CMSRPMessageIdHeader + */ + IMPORT_C static CMSRPMessageIdHeader* NewLC( const TDesC8& aMessageId ); + + /** + * Creates a new instance of CMSRMessageIdHeader + * @return a new instance of CMSRPMessageIdHeader + */ + static CMSRPMessageIdHeader* NewL( ); + + /** + * Destructor, deletes the resources of CMSRPMessageIdHeader. + */ + IMPORT_C ~CMSRPMessageIdHeader(); + + public: // New functions + + /** + * Constructs an instance of a CMSRPMessageIdHeader from a RReadStream + * @param aReadStream a stream containing the value of the + * externalized object (header name not included). + * @return an instance of a CMSRPMessageIdHeader + */ + IMPORT_C static CMSRPMessageIdHeader* + InternalizeValueL( RReadStream& aReadStream ); + + public: // From CMSRPHeaderBase + + IMPORT_C void ExternalizeValueL( RWriteStream& aWriteStream ) const; + + protected: // From CMSRPHeaderBase + + RStringF Name() const; + HBufC8* ToTextValueL() const; + + private: // Constructors + + /** + * Constructor. + */ + CMSRPMessageIdHeader(); + + /** + * Two-phased constructor. + * @param aMessageId unique message identifier + */ + void ConstructL( const TDesC8& aMessageId ); + + /** + * Two-phased constructor. + */ + void ConstructL( ); + + private: // new functions + + /** + * Internalize external object data + * @param aReadStream a stream containing the value of the + * externalized object (header name not included). + */ + void DoInternalizeValueL( RReadStream& aReadStream ); + + private: // variables + + // value as a string + HBufC8* iIdValue; + + }; + +#endif // CMSRPMESSAGEIDHEADER_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/inc/CMsrpResponse.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/inc/CMsrpResponse.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,142 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPRESPONSE_H +#define CMSRPRESPONSE_H + +// INCLUDES +#include +#include +#include + +#include "CMSRPMessageBase.h" + +// CLASS DECLARATION + + +/** +* @publishedAll +* +* Class provides services for creating and manipulating MSRP response +*/ +class CMSRPResponse : public CMSRPMessageBase + { + public: + + /** Error codes */ + enum TMSRPErrorCodes + { + EUnknownCode = 0, + EAllOk = 200, + EUnintelligibleRequest = 400, + EActionNotAllowed = 403, + ETimeout = 408, + EStopSending = 413, + EMimeNotUnderstood = 415, + EParameterOutOfBounds = 423, + ESessionDoesNotExist = 481, + EUnknownRequestMethod = 501, + ESessionAlreadyBound = 506 + }; + + public: // Constructors and destructor + + /** + * Constructor. + * @param aStatusCode a known MSRP response status code. + * Cannot be 100. + */ + IMPORT_C CMSRPResponse( TUint aStatusCode, RStringF aReasonPhrase ); + + /** + * Constructor + */ + IMPORT_C CMSRPResponse( ); + + /** + * Destructor. + */ + IMPORT_C virtual ~CMSRPResponse(); + + public: // New functions + + /** + * Returns the MSRP Response status code + * @return MSRP Response status code + */ + IMPORT_C TUint StatusCode() const; + + /** + * Gets a MSRP Response Reason Phrase + * @return a MSRP response reason phrase or an empty string if + * the reason phrase is not defined. + */ + IMPORT_C RStringF ReasonPhrase() const; + + /** + * Sets a MSRP Response extension status code. It is not possible to set + * value 100. + * @param aStatusCode extension status code + * @leave KErrArgument if aStatusCode < 100 or aStatusCode >= 700 + */ + IMPORT_C void SetStatusCodeL( TUint aStatusCode ); + + /** + * Sets a MSRP Response Reason Phrase + * @param aReasonPhrase a MSRP response reason phrase. + */ + IMPORT_C void SetReasonPhrase( RStringF aReasonPhrase ); + + /** + * Internalizes object from a given stream + * @param aReadStream stream to read from + * @return CMSRPResponse if internalization successfull + */ + IMPORT_C static CMSRPResponse* InternalizeL( RReadStream& aReadStream ); + + /** + * Check if the given externalised buffer contains MSRP Response + * @param aBuffer a Buffer containing the value of the + * externalized object + * @return true if Buffer contains MSRP response + */ + IMPORT_C static TBool IsResponse( const TDesC8& aBuffer ); + + public: // from base classes + + // from CMSRPMessageBase + IMPORT_C void ExternalizeL( RWriteStream& aWriteStream ); + + private: + + /** + * Internalizes the class from a given stream + * @param aReadStream stream to read from + */ + void DoInternalizeL( RReadStream& aReadStream ); + + private: // Data + + // status code + TUint iStatusCode; + + // reason phrase text + RStringF iReasonPhrase; + }; + +#endif // CMSRPRESPONSE_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/inc/CMsrpStrings.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/inc/CMsrpStrings.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPSTRINGS_H +#define CMSRPSTRINGS_H + +// EXTERNAL HEADERS +#include +#include + +/* +* CLASS DEFINION +*/ +class CMSRPStrings : public CBase + { + public: + + /** + * Constructor + */ + static CMSRPStrings* NewL(); + /** + * Constructor + */ + static CMSRPStrings* NewLC(); + /** + * Destructor + */ + ~CMSRPStrings(); + + /** + * Increment couter by one + */ + void IncrementUsageCount(); + /** + * Decrement couter by one + */ + void DecrementUsageCount(); + /** + * Get counter value + */ + TUint UsageCount() const; + + /** + * Get MSRPStrConsts constant + */ + const RStringPool& Pool() const; + /** + * Get MSRPStrConsts constants + */ + static const TStringTable& Table(); + + private: + + /** + * Constructor + */ + CMSRPStrings(); + /** + * Constructor + */ + void ConstructL(); + + private: // Data + + // The string pool handle object + RStringPool iPool; + // Counter + TUint iUsageCount; + }; + +#endif // CMSRPSTRINGS_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/inc/CMsrpSuccessReportHeader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/inc/CMsrpSuccessReportHeader.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,113 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + + +#ifndef CMSRPSUCCESSREPORTHEADER_H +#define CMSRPSUCCESSREPORTHEADER_H + +// INCLUDES +#include "CMsrpHeaderBase.h" + +// CLASS DECLARATION +/** +* @publishedAll +* +* Class provides functions for setting and getting MSRP "Success-Report" header field +* +* @lib msrpcodec.lib +*/ +class CMSRPSuccessReportHeader : public CMSRPHeaderBase + { + public: // Constructors and destructor + + /** + * Creates a new instance of CMSRSuccessReportHeader + * @param aType type of the content + * @return a new instance of CMSRPSuccessReportHeader + */ + IMPORT_C static CMSRPSuccessReportHeader* NewL( const RStringF& aType ); + + /** + * Creates a new instance of CMSRPSuccessReportHeader and puts it to CleanupStack + * @param aType type of the content + * @return a new instance of CMSRPSuccessReportHeader + */ + IMPORT_C static CMSRPSuccessReportHeader* NewLC( const RStringF& aType ); + + /** + * Creates a new instance of CMSRSuccessReportHeader + * @return a new instance of CMSRPSuccessReportHeader + */ + static CMSRPSuccessReportHeader* NewL( ); + + /** + * Destructor, deletes the resources of CMSRPSuccessReportHeader. + */ + IMPORT_C ~CMSRPSuccessReportHeader(); + + + public: // New functions + + /** + * Constructs an instance of a CMSRPSuccessReportHeader from a RReadStream + * @param aReadStream a stream containing the value of the + * externalized object (header name not included). + * @return an instance of a CMSRPSuccessReportHeader + */ + IMPORT_C static CMSRPSuccessReportHeader* + InternalizeValueL( RReadStream& aReadStream ); + + + public: // From CMSRPHeaderBase + + IMPORT_C void ExternalizeValueL( RWriteStream& aWriteStream ) const; + + public: // From CMSRPHeaderBase + + RStringF Name() const; + HBufC8* ToTextValueL() const; + + private: // Constructors + + /** + * Creates a new instance of CMSRSuccessReportHeader + * @param aType type of the content + */ + void ConstructL( RStringF aType ); + + /** + * Creates a new instance of CMSRSuccessReportHeader + */ + void ConstructL( ); + + /** + * Constructor + */ + CMSRPSuccessReportHeader(); + + private: // new functions + void DoInternalizeValueL( RReadStream& aReadStream ); + + private: // variables + + // value as a string + RStringF iReportType; + + }; + +#endif // CMSRPSUCCESSREPORTHEADER_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/inc/CMsrpToPathHeader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/inc/CMsrpToPathHeader.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,111 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPTOPATHHEADER_H +#define CMSRPTOPATHHEADER_H + +// INTERNAL INCLUDES +#include "CMsrpFromToHeaderBase.h" + +// CLASS DECLARATION +/** +* @publishedAll +* +* Class provides functions for setting and getting MSRP "To-Path" header field +* +* @lib msrpclient.lib +*/ +class CMSRPToPathHeader : public CMSRPFromToHeaderBase + { + public: // Constructors and destructor + + /** + * Constructs a CMSRPToPathHeader from textual representation + * of the header's value part. + * @param aValue a value part of a "To-Path"-header + * @return a new instance of CMSRPToPathHeader + */ + IMPORT_C static CMSRPToPathHeader* DecodeL( const TDesC8& aValue ); + + /** + * Creates a new instance of CMSRToPathHeader + * @param aUri URI of MSRP message receiver + * @return a new instance of CMSRPToPathHeader + */ + IMPORT_C static CMSRPToPathHeader* NewL( CUri8* aUri ); + + /** + * Creates a new instance of CMSRPToPathHeader and puts it to CleanupStack + * @param aUri URI of MSRP message receiver + * @return a new instance of CMSRPTopathHeader + */ + IMPORT_C static CMSRPToPathHeader* NewLC( CUri8* aUri ); + + /** + * Creates a new instance of CMSRToPathHeader + * @return a new instance of CMSRPToPathHeader + */ + static CMSRPToPathHeader* NewL( ); + + /** + * Destructor, deletes the resources of CMSRPToPathHeader. + */ + IMPORT_C ~CMSRPToPathHeader(); + + + public: // New functions + + /** + * Constructs an instance of a CMSRPTopathHeader from a RReadStream + * @param aReadStream a stream containing the value of the + * externalized object (header name not included). + * @return an instance of a CMSRPTopathHeader + */ + IMPORT_C static CMSRPToPathHeader* + InternalizeValueL( RReadStream& aReadStream ); + + + protected: // From CMSRPHeaderBase + + /** + * From CMSRPHeaderBase Name + */ + RStringF Name() const; + + protected: // constructors + + /** + * Constructor + */ + void ConstructL( CUri8* aUri ); + + /** + * Constructor + */ + void ConstructL( ); + + private: // Constructors + + /** + * Constructor + */ + CMSRPToPathHeader(); + + }; + +#endif // CMSRPTOPATHHEADER_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/inc/MSRPStrings.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/inc/MSRPStrings.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef MSRPSTRINGS_H +#define MSRPSTRINGS_H + +// EXTERNAL INCLUDES +#include +#include + +// FORWARD DECLARATIONS +class CMSRPStrings; + +// CLASS DECLARATION +class MSRPStrings + { + public: // Constructors and destructor + + /** + * Opens MSRP string pool, and also provides a 3rd party string pool + * to open MSRP string pool (when MSRP strings are needed elsewhere) + * @param aStringpool another string pool where MSRP string pool is added + * Implemented with a reference count. + */ + IMPORT_C static void OpenL( RStringPool& aStringPool ); + + /** + * Opens MSRP string pool. + * Implemented with a reference count. + */ + IMPORT_C static void OpenL(); + + /** + * Closes MSRP string pool. + * In other words decrements reference count and if it reaches + * zero, closes the string pool. + * The user must not call Close() if it has not called OpenL(). + */ + IMPORT_C static void Close(); + + + public: // New functions + + /** + * Gets a case-insensitive string specified + * in the original string table. + * + * @param aIndex The string table enumeration value + * @return Initialized RStringF object + */ + IMPORT_C static RStringF StringF( TInt aIndex ); + + /** + * Gets the string pool used by MSRP Client + * + * @return RStringPool: A handle to a string pool + */ + IMPORT_C static RStringPool Pool(); + + /** + * Gets the string table used by MSRP client + * + * @return TStringTable&: The string pool table + */ + IMPORT_C static const TStringTable& Table(); + + private: + + /** + * Creates new CMSRPStrings object + */ + static CMSRPStrings* Strings(); + }; + +#endif // MSRPSTRINGS_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/inc/TMSRPHeaderUtil.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/inc/TMSRPHeaderUtil.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef __TMSRPHEADERUTIL_H__ +#define __TMSRPHEADERUTIL_H__ + +// INCLUDES +#include + +// CLASS DEFINITION +/** + * Static utility class, used by MSRP Client + */ +class TMSRPHeaderUtil + { + +public: + + /** + * Convert given string to a number, leaves if string cannot be converted + * @param aString string to be converted + * @return string converted to number + */ + static TInt ConvertToNumber( const TDesC8& aString ); + + /** + * Append a string from a destination to source descriptor + * @param aSource string to be added + * @param aDest destination descriptor + */ + static void AppendStringL( const TDesC8& aString, TDes8& aDest ); + + /** + * Checks that given string consists of only the allowed characters + * @param aString string to check + * @return True if string valid, false if contained illegal characters + */ + static TBool CheckStringValidity( const TDesC8& aString ); + }; + +#endif // __TMSRPHEADERUTIL_H__ + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/src/CMSRPMessageBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/src/CMSRPMessageBase.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,248 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMSRPMessageBase.h" + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include "MsrpCommon.h" +#include "CMsrpToPathHeader.h" +#include "CMsrpFromPathHeader.h" +#include "CMsrpContentTypeHeader.h" +#include "CMSRPMessageIdHeader.h" +#include "CMsrpByteRangeHeader.h" +#include "CMsrpFailureReportHeader.h" +#include "CMsrpSuccessReportHeader.h" + +// ----------------------------------------------------------------------------- +// CMSRPMessageBase::CMSRPMessageBase +// ----------------------------------------------------------------------------- +// +CMSRPMessageBase::CMSRPMessageBase() + { + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageBase::~CMSRPMessageBase +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPMessageBase::~CMSRPMessageBase() + { + delete iToPath; + delete iFromPath; + delete iContentType; + delete iMessageId; + delete iByteRange; + delete iFailureReport; + delete iSuccessReport; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageBase::SetToPathHeaderL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPMessageBase::SetToPathHeader( CMSRPToPathHeader* aToPath ) + { + if(iToPath) + { + delete iToPath; + iToPath = NULL; + } + iToPath = aToPath; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageBase::ToPathHeader +// ----------------------------------------------------------------------------- +// +EXPORT_C const CMSRPToPathHeader* CMSRPMessageBase::ToPathHeader() const + { + if( iToPath ) + { + return iToPath; + } + return NULL; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageBase::SetFromPathHeaderL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPMessageBase::SetFromPathHeader( CMSRPFromPathHeader* aFromPath ) + { + if(iFromPath) + { + delete iFromPath; + iFromPath = NULL; + } + iFromPath = aFromPath; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageBase::FromPathHeader +// ----------------------------------------------------------------------------- +// +EXPORT_C const CMSRPFromPathHeader* CMSRPMessageBase::FromPathHeader() const + { + if( iFromPath ) + { + return iFromPath; + } + return NULL; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageBase::SetContentTypeHeaderL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPMessageBase::SetContentTypeHeader( + CMSRPContentTypeHeader* aContentType ) + { + if(iContentType) + { + delete iContentType; + iContentType = NULL; + } + iContentType = aContentType; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageBase::ContentTypeHeader +// ----------------------------------------------------------------------------- +// +EXPORT_C const CMSRPContentTypeHeader* CMSRPMessageBase::ContentTypeHeader() const + { + if( iContentType ) + { + return iContentType; + } + return NULL; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageBase::SetFailureReportHeaderL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPMessageBase::SetFailureReportHeader( + CMSRPFailureReportHeader* aFailureReport ) + { + if(iFailureReport) + { + delete iFailureReport; + iFailureReport = NULL; + } + iFailureReport = aFailureReport; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageBase::FailureReportHeader +// ----------------------------------------------------------------------------- +// +EXPORT_C const CMSRPFailureReportHeader* CMSRPMessageBase::FailureReportHeader() const + { + if( iFailureReport ) + { + return iFailureReport; + } + return NULL; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageBase::SetSuccessReportHeaderL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPMessageBase::SetSuccessReportHeader( + CMSRPSuccessReportHeader* aSuccessReport ) + { + if(iSuccessReport) + { + delete iSuccessReport; + iSuccessReport = NULL; + } + iSuccessReport = aSuccessReport; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageBase::SuccessReportHeader +// ----------------------------------------------------------------------------- +// +EXPORT_C const CMSRPSuccessReportHeader* CMSRPMessageBase::SuccessReportHeader() const + { + if( iSuccessReport ) + { + return iSuccessReport; + } + return NULL; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageBase::SetMessageIdHeaderL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPMessageBase::SetMessageIdHeader( CMSRPMessageIdHeader* aMessageId ) + { + if(iMessageId) + { + delete iMessageId; + iMessageId = NULL; + } + iMessageId = aMessageId; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageBase::MessageIdHeader +// ----------------------------------------------------------------------------- +// +EXPORT_C const CMSRPMessageIdHeader* CMSRPMessageBase::MessageIdHeader() const + { + if( iMessageId ) + { + return iMessageId; + } + return NULL; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageBase::SetByteRangeHeaderL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPMessageBase::SetByteRangeHeader( CMSRPByteRangeHeader* aByteRange ) + { + if(iByteRange) + { + delete iByteRange; + iByteRange = NULL; + } + iByteRange = aByteRange; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageBase::ByteRangeHeader +// ----------------------------------------------------------------------------- +// +EXPORT_C const CMSRPByteRangeHeader* CMSRPMessageBase::ByteRangeHeader() const + { + if( iByteRange ) + { + return iByteRange; + } + return NULL; + } + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/src/CMSRPTlsPtrs.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/src/CMSRPTlsPtrs.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMSRPTlsPtrs.h" + +// INTERNAL INCLUDES +#include "CMSRPStrings.h" + +// ---------------------------------------------------------------------------- +// CMSRPTlsPtrs::CMSRPTlsPtrs +// ---------------------------------------------------------------------------- +// +CMSRPTlsPtrs::CMSRPTlsPtrs( CMSRPStrings* aStrings ) + : iStrings(aStrings) + { + } + +// ---------------------------------------------------------------------------- +// CMSRPTlsPtrs::~CMSRPTlsPtrs +// ---------------------------------------------------------------------------- +// +CMSRPTlsPtrs::~CMSRPTlsPtrs() + { + delete iStrings; + } + +// ---------------------------------------------------------------------------- +// CMSRPTlsPtrs::DestroyStrings +// ---------------------------------------------------------------------------- +// +void CMSRPTlsPtrs::DestroyStrings() + { + delete iStrings; + iStrings = NULL; + } + +// ---------------------------------------------------------------------------- +// CMSRPTlsPtrs::GetMsrpString +// ---------------------------------------------------------------------------- +// +CMSRPStrings* CMSRPTlsPtrs::GetMsrpString() + { + return iStrings; + } + + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/src/CMsrpByteRangeHeader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/src/CMsrpByteRangeHeader.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,292 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMsrpByteRangeHeader.h" + +// EXTERNAL INCLUDES + +// INTERNAL INCLUDES +#include "MsrpCommon.h" +#include "TMSRPHeaderUtil.h" +#include "msrpstrings.h" +#include "msrpstrconsts.h" + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::NewLC +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPByteRangeHeader* CMSRPByteRangeHeader::NewLC( + TInt aStart, TInt aEnd, TInt aTotal ) + { + CMSRPByteRangeHeader* self = new (ELeave) CMSRPByteRangeHeader( + aStart, aEnd, aTotal ); + CleanupStack::PushL( self ); + self->ConstructL( ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::NewL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPByteRangeHeader* CMSRPByteRangeHeader::NewL( + TInt aStart, TInt aEnd, TInt aTotal ) + { + CMSRPByteRangeHeader* self = CMSRPByteRangeHeader::NewLC( + aStart, aEnd, aTotal ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::NewL +// ----------------------------------------------------------------------------- +// +CMSRPByteRangeHeader* CMSRPByteRangeHeader::NewL( ) + { + CMSRPByteRangeHeader* self = new (ELeave) CMSRPByteRangeHeader( ); + CleanupStack::PushL( self ); + self->ConstructL( ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::CMSRPByteRangeHeader +// ----------------------------------------------------------------------------- +// +CMSRPByteRangeHeader::CMSRPByteRangeHeader( + TInt aStart, TInt aEnd, TInt aTotal ) + : iStartPosition( aStart ), + iEndPosition( aEnd ), + iTotalBytes( aTotal ) + { + } + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::CMSRPByteRangeHeader +// ----------------------------------------------------------------------------- +// +CMSRPByteRangeHeader::CMSRPByteRangeHeader( ) + { + } + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::ConstructL +// ----------------------------------------------------------------------------- +// +void CMSRPByteRangeHeader::ConstructL( ) const + { + MSRPStrings::OpenL(); + } + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::~CMSRPByteRangeHeader +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPByteRangeHeader::~CMSRPByteRangeHeader() + { + MSRPStrings::Close(); + } + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::InternalizeValueL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPByteRangeHeader* CMSRPByteRangeHeader::InternalizeValueL( + RReadStream& aReadStream ) + { + CMSRPByteRangeHeader* self = CMSRPByteRangeHeader::NewL(); + CleanupStack::PushL( self ); + self->DoInternalizeValueL( aReadStream ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::SetStartPosition +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPByteRangeHeader::SetStartPosition( TInt aStartPos ) + { + iStartPosition = aStartPos; + } + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::StartPosition +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CMSRPByteRangeHeader::StartPosition( ) const + { + return iStartPosition; + } + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::SetEndPosition +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPByteRangeHeader::SetEndPosition( TInt aEndPos ) + { + iEndPosition = aEndPos; + } + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::EndPosition +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CMSRPByteRangeHeader::EndPosition( ) const + { + return iEndPosition; + } + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::SetTotalLength +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPByteRangeHeader::SetTotalLength( TInt aTotal ) + { + iTotalBytes = aTotal; + } + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::TotalLength +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CMSRPByteRangeHeader::TotalLength( ) const + { + return iTotalBytes; + } + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::DoInternalizeValueL +// ----------------------------------------------------------------------------- +// +void CMSRPByteRangeHeader::DoInternalizeValueL( RReadStream& aReadStream ) + { + TUint32 valueLength = aReadStream.ReadUint32L(); + if( valueLength > 0 ) + { + HBufC8* tempString = HBufC8::NewLC( valueLength ); + TPtr8 tempValue( tempString->Des() ); + aReadStream.ReadL( tempValue, valueLength ); + iStartPosition = TMSRPHeaderUtil::ConvertToNumber( tempString->Des() ); + CleanupStack::PopAndDestroy( tempString ); + + TUint32 valLength = aReadStream.ReadUint32L(); + if( valLength > 0 ) + { + HBufC8* tempStr = HBufC8::NewLC( valLength ); + TPtr8 tempVal( tempStr->Des() ); + aReadStream.ReadL( tempVal, valLength ); + iEndPosition = TMSRPHeaderUtil::ConvertToNumber( tempStr->Des() ); + CleanupStack::PopAndDestroy( tempString ); + + TUint32 valLgth = aReadStream.ReadUint32L(); + if( valLgth > 0 ) + { + HBufC8* tmpStr = HBufC8::NewLC( valLgth ); + TPtr8 tmpVal( tmpStr->Des() ); + aReadStream.ReadL( tmpVal, valLgth ); + iTotalBytes = TMSRPHeaderUtil::ConvertToNumber( tmpStr->Des() ); + CleanupStack::PopAndDestroy( tmpStr ); + } + else + { + User::Leave( KErrArgument ); + } + } + else + { + User::Leave( KErrArgument ); + } + } + else + { + User::Leave( KErrArgument ); + } + } + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::ExternalizeValueL +// From CSIPHeaderBase: +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPByteRangeHeader::ExternalizeValueL( RWriteStream& aWriteStream ) const + { + TBuf8< KMaxLengthOfNumbers > value; + // start pos + value.AppendNum( iStartPosition ); + aWriteStream.WriteInt32L( value.Length() ); + aWriteStream.WriteL( value ); + + // end pos + value.Zero(); + value.AppendNum( iEndPosition ); + aWriteStream.WriteInt32L( value.Length() ); + aWriteStream.WriteL( value ); + + // total Length + value.Zero(); + value.AppendNum( iTotalBytes ); + aWriteStream.WriteInt32L( value.Length() ); + aWriteStream.WriteL( value ); + } + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::Name +// ----------------------------------------------------------------------------- +// +RStringF CMSRPByteRangeHeader::Name() const + { + return MSRPStrings::StringF( MSRPStrConsts::EByteRange ); + } + +// ----------------------------------------------------------------------------- +// CMSRPByteRangeHeader::ToTextValueL +// ----------------------------------------------------------------------------- +// +HBufC8* CMSRPByteRangeHeader::ToTextValueL() const + { + TBuf8< KMaxLengthOfNumbers > value; + value.AppendNum( iStartPosition, EDecimal ); + TMSRPHeaderUtil::AppendStringL( KByteRangeSeparator, value ); + if ( iEndPosition == KUnknownRange ) + { + value.Append( KAsterisk ); + } + else + { + value.AppendNum( iEndPosition, EDecimal ); + } + TMSRPHeaderUtil::AppendStringL( KByteRangeTotalSeparator, value ); + + if ( iTotalBytes == KUnknownRange ) + { + value.Append( KAsterisk ); + } + else + { + value.AppendNum( iTotalBytes, EDecimal ); + } + HBufC8* tempString = HBufC8::NewLC( value.Length() ); + *tempString = value; + CleanupStack::Pop( tempString ); + + return tempString; + } + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/src/CMsrpContentTypeHeader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/src/CMsrpContentTypeHeader.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,172 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMsrpContentTypeHeader.h" + +// EXTERNAL INCLUDES + +// INTERNAL INCLUDES +#include "TMSRPHeaderUtil.h" +#include "msrpstrings.h" +#include "msrpstrconsts.h" + +// ----------------------------------------------------------------------------- +// CMSRPContentTypeHeader::NewLC +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPContentTypeHeader* CMSRPContentTypeHeader::NewLC( + const TDesC8& aMediaType ) + { + CMSRPContentTypeHeader* self = new (ELeave) CMSRPContentTypeHeader( ); + CleanupStack::PushL( self ); + self->ConstructL( aMediaType ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPContentTypeHeader::NewL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPContentTypeHeader* CMSRPContentTypeHeader::NewL( + const TDesC8& aMediaType ) + { + CMSRPContentTypeHeader* self = CMSRPContentTypeHeader::NewLC( aMediaType ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPContentTypeHeader::NewL +// ----------------------------------------------------------------------------- +// +CMSRPContentTypeHeader* CMSRPContentTypeHeader::NewL( ) + { + CMSRPContentTypeHeader* self = new (ELeave) CMSRPContentTypeHeader( ); + CleanupStack::PushL( self ); + self->ConstructL( ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPContentTypeHeader::CMSRPContentTypeHeader +// ----------------------------------------------------------------------------- +// +CMSRPContentTypeHeader::CMSRPContentTypeHeader( ) + { + } + +// ----------------------------------------------------------------------------- +// CMSRPContentTypeHeader::ConstructL +// ----------------------------------------------------------------------------- +// +void CMSRPContentTypeHeader::ConstructL( const TDesC8& aMediaType ) + { + MSRPStrings::OpenL(); + if ( !TMSRPHeaderUtil::CheckStringValidity( aMediaType ) ) + { + User::Leave( KErrCorrupt ); + } + iDataType = aMediaType; + // let's check string is valid + } + +// ----------------------------------------------------------------------------- +// CMSRPContentTypeHeader::ConstructL +// ----------------------------------------------------------------------------- +// +void CMSRPContentTypeHeader::ConstructL( ) + { + MSRPStrings::OpenL(); + } + +// ----------------------------------------------------------------------------- +// CMSRPContentTypeHeader::~CMSRPContentTypeHeader +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPContentTypeHeader::~CMSRPContentTypeHeader() + { + MSRPStrings::Close(); + } + +// ----------------------------------------------------------------------------- +// CMSRPContentTypeHeader::InternalizeValueL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPContentTypeHeader* CMSRPContentTypeHeader::InternalizeValueL( + RReadStream& aReadStream ) + { + CMSRPContentTypeHeader* self = CMSRPContentTypeHeader::NewL( ); + CleanupStack::PushL( self ); + self->DoInternalizeValueL( aReadStream ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPContentTypeHeader::DoInternalizeValueL +// ----------------------------------------------------------------------------- +// +void CMSRPContentTypeHeader::DoInternalizeValueL( RReadStream& aReadStream ) + { + TUint32 valueLength = aReadStream.ReadUint32L(); + if( valueLength > 0) + { + HBufC8* tempBuffer = HBufC8::NewLC( valueLength ); + TPtr8 tempValue( tempBuffer->Des() ); + aReadStream.ReadL( tempValue, valueLength ); + iDataType = tempValue; + CleanupStack::PopAndDestroy( tempBuffer ); + } + } + +// ----------------------------------------------------------------------------- +// CMSRPContentTypeHeader::ExternalizeValueL +// From CSIPHeaderBase: +// ----------------------------------------------------------------------------- +// +void CMSRPContentTypeHeader::ExternalizeValueL( RWriteStream& aWriteStream ) const + { + aWriteStream.WriteInt32L( iDataType.Des8().Length() ); + aWriteStream.WriteL( iDataType.Des8() ); + } + +// ----------------------------------------------------------------------------- +// CMSRPContentTypeHeader::Name +// ----------------------------------------------------------------------------- +// +RStringF CMSRPContentTypeHeader::Name() const + { + return MSRPStrings::StringF( MSRPStrConsts::EContentType ); + } + +// ----------------------------------------------------------------------------- +// CMSRPContentTypeHeader::ToTextValueL +// ----------------------------------------------------------------------------- +// +HBufC8* CMSRPContentTypeHeader::ToTextValueL() const + { + if( iDataType.Des8().Length()) + { + HBufC8* tempBuffer = HBufC8::NewL( iDataType.Des8().Length() ); + TPtr8 tempValue( tempBuffer->Des() ); + tempValue = iDataType.Des8(); + return tempBuffer; + } + return NULL; + } + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/src/CMsrpFailureReportHeader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/src/CMsrpFailureReportHeader.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,197 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMsrpFailureReportHeader.h" + +// EXTERNAL INCLUDES + +// INTERNAL INCLUDES +#include "msrpstrings.h" +#include "msrpstrconsts.h" + +// ----------------------------------------------------------------------------- +// CMSRPFailureReportHeader::NewLC +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPFailureReportHeader* CMSRPFailureReportHeader::NewLC( + const RStringF& aType ) + { + CMSRPFailureReportHeader* self = new (ELeave) CMSRPFailureReportHeader(); + CleanupStack::PushL( self ); + self->ConstructL( aType ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPFailureReportHeader::NewL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPFailureReportHeader* CMSRPFailureReportHeader::NewL( + const RStringF& aType ) + { + CMSRPFailureReportHeader* self = CMSRPFailureReportHeader::NewLC( aType ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPFailureReportHeader::NewL +// ----------------------------------------------------------------------------- +// +CMSRPFailureReportHeader* CMSRPFailureReportHeader::NewL( ) + { + CMSRPFailureReportHeader* self = new (ELeave) CMSRPFailureReportHeader(); + CleanupStack::PushL( self ); + self->ConstructL( ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPFailureReportHeader::CMSRPFailureReportHeader +// ----------------------------------------------------------------------------- +// +CMSRPFailureReportHeader::CMSRPFailureReportHeader() + { + } + +// ----------------------------------------------------------------------------- +// CMSRPFailureReportHeader::ConstructL +// ----------------------------------------------------------------------------- +// +void CMSRPFailureReportHeader::ConstructL( + RStringF aType ) + { + MSRPStrings::OpenL(); + iReportType = aType.Copy(); + } + +// ----------------------------------------------------------------------------- +// CMSRPFailureReportHeader::ConstructL +// ----------------------------------------------------------------------------- +// +void CMSRPFailureReportHeader::ConstructL( ) + { + MSRPStrings::OpenL(); + } + +// ----------------------------------------------------------------------------- +// CMSRPFailureReportHeader::~CMSRPFailureReportHeader +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPFailureReportHeader::~CMSRPFailureReportHeader() + { + MSRPStrings::Close(); + } + +// ----------------------------------------------------------------------------- +// CMSRPFailureReportHeader::InternalizeValueL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPFailureReportHeader* CMSRPFailureReportHeader::InternalizeValueL( + RReadStream& aReadStream ) + { + CMSRPFailureReportHeader* self = CMSRPFailureReportHeader::NewL( ); + CleanupStack::PushL( self ); + self->DoInternalizeValueL( aReadStream ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPFailureReportHeader::DoInternalizeValueL +// ----------------------------------------------------------------------------- +// +void CMSRPFailureReportHeader::DoInternalizeValueL( RReadStream& aReadStream ) + { + // value must be in stringpool + TUint32 valueLength = aReadStream.ReadUint32L(); + if( valueLength > 0 ) + { + HBufC8* tempBuffer = HBufC8::NewLC( valueLength ); + TPtr8 tempValue( tempBuffer->Des() ); + aReadStream.ReadL( tempValue, valueLength ); + + // let's check if the value matches the supported content-types + RStringF tempString = MSRPStrings::StringF( MSRPStrConsts::EYes ); + if( tempString.DesC() == tempValue ) + { + // OK + iReportType = tempString.Copy(); + } + else + { + RStringF tempStr = MSRPStrings::StringF( MSRPStrConsts::ENo ); + if( tempStr.DesC() == tempValue ) + { + // OK + iReportType = tempStr.Copy(); + } + else + { + RStringF tmpStr = MSRPStrings::StringF( MSRPStrConsts::EPartial ); + if( tmpStr.DesC() == tempValue ) + { + // OK + iReportType = tmpStr.Copy(); + } + else + { + // not supported + CleanupStack::PopAndDestroy( tempBuffer ); + User::Leave( KErrNotSupported ); + } + } + } + CleanupStack::PopAndDestroy( tempBuffer ); + } + } + +// ----------------------------------------------------------------------------- +// CMSRPFailureReportHeader::ExternalizeValueL +// From CSIPHeaderBase: +// ----------------------------------------------------------------------------- +// +void CMSRPFailureReportHeader::ExternalizeValueL( RWriteStream& aWriteStream ) const + { + aWriteStream.WriteInt32L( iReportType.DesC().Length() ); + aWriteStream.WriteL( iReportType.DesC() ); + } + +// ----------------------------------------------------------------------------- +// CMSRPFailureReportHeader::Name +// ----------------------------------------------------------------------------- +// +RStringF CMSRPFailureReportHeader::Name() const + { + return MSRPStrings::StringF( MSRPStrConsts::EFailureReport ); + } + +// ----------------------------------------------------------------------------- +// CMSRPFailureReportHeader::ToTextValueL +// ----------------------------------------------------------------------------- +// +HBufC8* CMSRPFailureReportHeader::ToTextValueL() const + { + if( iReportType.DesC().Length() ) + { + return iReportType.DesC().AllocL(); + } + return NULL; + } + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/src/CMsrpFromPathHeader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/src/CMsrpFromPathHeader.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,180 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMsrpFromPathHeader.h" + +// EXTERNAL INCLUDES + +// INTERNAL INCLUDES +#include "MsrpCommon.h" +#include "msrpstrings.h" +#include "msrpstrconsts.h" + +// ----------------------------------------------------------------------------- +// CMSRPFromPathHeader::DecodeL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPFromPathHeader* CMSRPFromPathHeader::DecodeL( + const TDesC8& aUri ) + { + CMSRPFromPathHeader* self = new (ELeave) CMSRPFromPathHeader(); + CleanupStack::PushL( self ); + + // parsing the descriptor URL + CUri8* uri = CUri8::NewLC( ); + // first is the scheme + TChar charToFind( KColonCharacter ); + TInt matchLoc = aUri.Locate( charToFind ); + if ( matchLoc != KErrNotFound ) + { + TPtrC8 scheme = aUri.Left( matchLoc ); + uri->SetComponentL( scheme, EUriScheme ); + // after that comes the ipaddress which must have // in front + TPtrC8 host = aUri.Mid( matchLoc + 3 ); // codescanner::magicnumbers + matchLoc = host.Locate( charToFind ); + if ( matchLoc != KErrNotFound ) + { + uri->SetComponentL( host.Left( matchLoc ), EUriHost ); + // next is the port + TPtrC8 port = host.Mid( matchLoc + 1 ); + TChar charToFind2( KDividedCharacter ); + matchLoc = port.Locate( charToFind2 ); + if ( matchLoc != KErrNotFound ) + { + uri->SetComponentL( port.Left( matchLoc ), EUriPort ); + TPtrC8 path = port.Mid( matchLoc ); + uri->SetComponentL( path, EUriPath ); + } + else + { + // there is not path set + User::Leave( KErrArgument ); + } + } + else + { + User::Leave( KErrArgument ); + } + } + else + { + User::Leave( KErrArgument ); + } + + self->ConstructL( uri ); + CleanupStack::Pop( uri ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPFromPathHeader::NewLC +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPFromPathHeader* CMSRPFromPathHeader::NewLC( + CUri8* aUri ) + { + CMSRPFromPathHeader* self = new (ELeave) CMSRPFromPathHeader(); + CleanupStack::PushL( self ); + self->ConstructL( aUri ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPFromPathHeader::NewL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPFromPathHeader* CMSRPFromPathHeader::NewL( + CUri8* aUri ) + { + CMSRPFromPathHeader* self = CMSRPFromPathHeader::NewLC( aUri ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPFromPathHeader::NewL +// ----------------------------------------------------------------------------- +// +CMSRPFromPathHeader* CMSRPFromPathHeader::NewL( ) + { + CMSRPFromPathHeader* self = new (ELeave) CMSRPFromPathHeader(); + CleanupStack::PushL( self ); + self->ConstructL( ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPFromPathHeader::CMSRPFromPathHeader +// ----------------------------------------------------------------------------- +// +CMSRPFromPathHeader::CMSRPFromPathHeader() + { + } + +// ----------------------------------------------------------------------------- +// CMSRPFromPathHeader::~CMSRPFromPathHeader +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPFromPathHeader::~CMSRPFromPathHeader() + { + MSRPStrings::Close(); + } + +// ----------------------------------------------------------------------------- +// CMSRPFromPathHeader::ConstructL +// ----------------------------------------------------------------------------- +// +void CMSRPFromPathHeader::ConstructL( CUri8* aUri ) + { + MSRPStrings::OpenL(); + iUri = aUri; + } + +// ----------------------------------------------------------------------------- +// CMSRPFromPathHeader::ConstructL +// ----------------------------------------------------------------------------- +// +void CMSRPFromPathHeader::ConstructL( ) + { + MSRPStrings::OpenL(); + } + +// ----------------------------------------------------------------------------- +// CMSRPFromPathHeader::InternalizeValueL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPFromPathHeader* CMSRPFromPathHeader::InternalizeValueL( + RReadStream& aReadStream ) + { + CMSRPFromPathHeader* self = CMSRPFromPathHeader::NewL( ); + CleanupStack::PushL( self ); + self->DoInternalizeValueL( aReadStream ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPFromPathHeader::Name +// ----------------------------------------------------------------------------- +// +RStringF CMSRPFromPathHeader::Name() const + { + return MSRPStrings::StringF( MSRPStrConsts::EFromPath ); + } + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/src/CMsrpFromToHeaderBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/src/CMsrpFromToHeaderBase.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMsrpFromToHeaderBase.h" + +// ----------------------------------------------------------------------------- +// CMSRPFromToHeaderBase::CMSRPFromToHeaderBase +// ----------------------------------------------------------------------------- +// +CMSRPFromToHeaderBase::CMSRPFromToHeaderBase() + { + } + +// ----------------------------------------------------------------------------- +// CMSRPFromToHeaderBase::~CMSRPFromToHeaderBase +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPFromToHeaderBase::~CMSRPFromToHeaderBase() + { + delete iUri; + iUri = NULL; + } + +// ----------------------------------------------------------------------------- +// CMSRPFromToHeaderBase::operator== +// ----------------------------------------------------------------------------- +// +EXPORT_C TBool CMSRPFromToHeaderBase::operator==( + const CMSRPFromToHeaderBase& aHeader ) const + { + if ( iUri->Uri().UriDes() == aHeader.iUri->Uri().UriDes() ) + { + return ETrue; + } + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CMSRPFromToHeaderBase::DoInternalizeValueL +// ----------------------------------------------------------------------------- +// +void CMSRPFromToHeaderBase::DoInternalizeValueL( RReadStream& aReadStream ) + { + delete iUri; + iUri = NULL; + // URI comes in one string which will be parsed + TUint32 valueLength = aReadStream.ReadUint32L(); + HBufC8* tempBuffer = HBufC8::NewLC( valueLength ); + TPtr8 tempValue( tempBuffer->Des() ); + aReadStream.ReadL( tempValue, valueLength ); + TUriParser8 parser; + User::LeaveIfError( parser.Parse( tempValue ) ); + iUri = CUri8::NewL( parser ); + CleanupStack::PopAndDestroy( tempBuffer ); + } + +// ----------------------------------------------------------------------------- +// CMSRPFromToHeaderBase::ExternalizeValueL +// From CSIPHeaderBase: +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPFromToHeaderBase::ExternalizeValueL( RWriteStream& aWriteStream ) const + { + aWriteStream.WriteInt32L( iUri->Uri().UriDes().Length() ); + aWriteStream.WriteL( iUri->Uri().UriDes() ); + } + +// ----------------------------------------------------------------------------- +// CMSRPFromToHeaderBase::ToTextValueL +// From CSIPHeaderBase +// ----------------------------------------------------------------------------- +// +HBufC8* CMSRPFromToHeaderBase::ToTextValueL() const + { + if( iUri ) + { + return iUri->Uri().UriDes().AllocL(); + } + return NULL; + } diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/src/CMsrpHeaderBase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/src/CMsrpHeaderBase.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +//CLASS HEADER +#include "CMsrpHeaderBase.h" + +// INTERNAL INCLUDES +#include "TMSRPHeaderUtil.h" + +// ----------------------------------------------------------------------------- +// CMSRPHeaderBase::CMSRPHeaderBase +// ----------------------------------------------------------------------------- +// +CMSRPHeaderBase::CMSRPHeaderBase() + { + } + +// ----------------------------------------------------------------------------- +// CMSRPHeaderBase::~CMSRPHeaderBase +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPHeaderBase::~CMSRPHeaderBase() + { + } + +// ----------------------------------------------------------------------------- +// CMSRPHeaderBase::ToTextL +// ----------------------------------------------------------------------------- +// +EXPORT_C HBufC8* CMSRPHeaderBase::ToTextL () const + { + TPtrC8 fullName( Name().DesC() ); + TUint headerLength = fullName.Length(); + headerLength += KColonAndSpace().Length(); + HBufC8* encodedHeaderValue = ToTextValueL(); + headerLength += encodedHeaderValue->Length(); + + CleanupStack::PushL( encodedHeaderValue ); + + HBufC8* encodedHeader = HBufC8::NewL( headerLength ); + CleanupStack::PushL( encodedHeader ); + + TPtr8 encodedHeaderPtr = encodedHeader->Des(); + TMSRPHeaderUtil::AppendStringL( fullName, encodedHeaderPtr ); + TMSRPHeaderUtil::AppendStringL( KColonAndSpace, encodedHeaderPtr ); + TMSRPHeaderUtil::AppendStringL( *encodedHeaderValue, encodedHeaderPtr ); + + CleanupStack::Pop( encodedHeader ); // encodedHeader + CleanupStack::PopAndDestroy( encodedHeaderValue ); + + return encodedHeader; + } + +// ----------------------------------------------------------------------------- +// CMSRPHeaderBase::ToTextLC +// ----------------------------------------------------------------------------- +// +EXPORT_C HBufC8* CMSRPHeaderBase::ToTextLC () const + { + HBufC8* encodedHeader = ToTextL(); + CleanupStack::PushL (encodedHeader); + return encodedHeader; + } + +// ----------------------------------------------------------------------------- +// CMSRPHeaderBase::ToTextValueLC +// ----------------------------------------------------------------------------- +// +EXPORT_C HBufC8* CMSRPHeaderBase::ToTextValueLC () const + { + HBufC8* encodedHeaderValue = ToTextValueL(); + CleanupStack::PushL (encodedHeaderValue); + return encodedHeaderValue; + } + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/src/CMsrpMessage.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/src/CMsrpMessage.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,357 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMsrpMessage.h" + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include "MsrpCommon.h" +#include "CMSRPFromPathHeader.h" +#include "CMSRPToPathHeader.h" +#include "CMSRPMessageIdHeader.h" +#include "CMSRPByteRangeHeader.h" +#include "CMSRPContentTypeHeader.h" +#include "CMSRPFailureReportHeader.h" +#include "CMSRPSuccessReportHeader.h" +#include "TMSRPHeaderUtil.h" +// ----------------------------------------------------------------------------- +// CMSRPMessage::CMSRPMessage +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPMessage::CMSRPMessage() + { + } + +// ----------------------------------------------------------------------------- +// CMSRPMessage::~CMSRPMessage +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPMessage::~CMSRPMessage() + { + delete iContentBuffer; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessage::SetContentL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPMessage::SetContent( HBufC8* aContent ) + { + if( iContentBuffer ) + { + delete iContentBuffer; + iContentBuffer = NULL; + } + iContentBuffer = aContent; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessage::Content +// ----------------------------------------------------------------------------- +// +EXPORT_C const TDesC8& CMSRPMessage::Content( ) + { + if( iContentBuffer ) + { + return *iContentBuffer; + } + return KNullDesC8(); + } + +// ----------------------------------------------------------------------------- +// CMSRPMessage::IsContent +// ----------------------------------------------------------------------------- +// +EXPORT_C TBool CMSRPMessage::IsContent( ) const + { + if ( iContentBuffer ) + { + return ETrue; + } + + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessage::SetFileName +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPMessage::SetFileName( const TFileName& aFileName ) + { + iFileName = aFileName; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessage::GetFileName +// ----------------------------------------------------------------------------- +// +EXPORT_C TFileName& CMSRPMessage::GetFileName( ) + { + return iFileName; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessage::SetFileSize +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPMessage::SetFileSize( const TInt aFileSize ) + { + iFileSize = aFileSize; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessage::GetFileSize +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CMSRPMessage::GetFileSize( ) + { + return iFileSize; + } +// ----------------------------------------------------------------------------- +// CMSRPMessage::InternalizeL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPMessage* CMSRPMessage::InternalizeL( RReadStream& aReadStream ) + { + CMSRPMessage* self = new (ELeave) CMSRPMessage(); + CleanupStack::PushL( self ); + self->DoInternalizeL( aReadStream ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessage::DoInternalizeL +// ----------------------------------------------------------------------------- +// +void CMSRPMessage::DoInternalizeL( RReadStream& aReadStream ) + { + TUint8 dataType( 0 ); + + // read the identifier + if ( aReadStream.ReadUint8L() != 100 ) + { + User::Leave( KErrArgument ); + } + + do + { + dataType = aReadStream.ReadUint8L(); + + switch( dataType ) + { + case 1: // from path + { + iFromPath = CMSRPFromPathHeader::InternalizeValueL( aReadStream ); + break; + } + case 2: // to path + { + iToPath = CMSRPToPathHeader::InternalizeValueL( aReadStream ); + break; + } + case 3: // message id + { + iMessageId = CMSRPMessageIdHeader::InternalizeValueL( aReadStream ); + break; + } + case 4: // byte range + { + iByteRange = CMSRPByteRangeHeader::InternalizeValueL( aReadStream ); + break; + } + case 5: // content type + { + iContentType = CMSRPContentTypeHeader::InternalizeValueL( aReadStream ); + break; + } + case 6: // failure report + { + iFailureReport = CMSRPFailureReportHeader::InternalizeValueL( aReadStream ); + break; + } + case 7: // success report + { + iSuccessReport = CMSRPSuccessReportHeader::InternalizeValueL( aReadStream ); + break; + } + case 10: // content buffer + { + TUint32 contentLength = aReadStream.ReadUint32L(); + iContentBuffer = HBufC8::NewL( contentLength ); + TPtr8 bufferPtr = iContentBuffer->Des(); + aReadStream.ReadL( bufferPtr, contentLength ); + break; + } + case 11: //filename + { + TUint32 nameLength = aReadStream.ReadUint32L(); + aReadStream.ReadL( iFileName, nameLength ); + break; + } + case 12: //filesize + { + TUint32 val = aReadStream.ReadUint32L(); + if( val > 0 ) + { + HBufC8* tempString = HBufC8::NewLC( val ); + TPtr8 tempValue( tempString->Des() ); + aReadStream.ReadL( tempValue, val ); + iFileSize = TMSRPHeaderUtil::ConvertToNumber( tempString->Des() ); + CleanupStack::PopAndDestroy( tempString ); + } + break; + } + case 13: //granularity + { + TUint32 val = aReadStream.ReadUint32L(); + if( val > 0 ) + { + HBufC8* tempString = HBufC8::NewLC( val ); + TPtr8 tempValue( tempString->Des() ); + aReadStream.ReadL( tempValue, val ); + iNotifyProgress = TMSRPHeaderUtil::ConvertToNumber( tempString->Des() ); + CleanupStack::PopAndDestroy( tempString ); + } + break; + } + default: + { + // nothing to do + break; + } + } + + } while( dataType ); + } +// ----------------------------------------------------------------------------- +// CMSRPMessage::ExternalizeL +// ----------------------------------------------------------------------------- +// + +EXPORT_C void CMSRPMessage::ExternalizeL( RWriteStream& aWriteStream ) + { + // first add the MSRP Message identifier + aWriteStream.WriteUint8L( 100 ); // MSRP Message identifier + + if( iFromPath ) + { + aWriteStream.WriteUint8L(1); // more headers in the stream flag + iFromPath->ExternalizeValueL( aWriteStream ); + } + if( iToPath ) + { + aWriteStream.WriteUint8L(2); // more headers in the stream flag + iToPath->ExternalizeValueL( aWriteStream ); + } + if ( iMessageId ) + { + aWriteStream.WriteUint8L(3); // more headers in the stream flag + iMessageId->ExternalizeValueL( aWriteStream ); + } + if( iByteRange ) + { + aWriteStream.WriteUint8L(4); // more headers in the stream flag + iByteRange->ExternalizeValueL( aWriteStream ); + } + if( iContentType ) + { + aWriteStream.WriteUint8L(5); // more headers in the stream flag + iContentType->ExternalizeValueL( aWriteStream ); + } + if( iFailureReport ) + { + aWriteStream.WriteUint8L(6); // more headers in the stream flag + iFailureReport->ExternalizeValueL( aWriteStream ); + } + if( iSuccessReport ) + { + aWriteStream.WriteUint8L(7); // more headers in the stream flag + iSuccessReport->ExternalizeValueL( aWriteStream ); + } + if ( IsContent() ) + { + aWriteStream.WriteUint8L( 10 ); + aWriteStream.WriteInt32L( iContentBuffer->Length() ); + aWriteStream.WriteL( *iContentBuffer, iContentBuffer->Length() ); + } + if ( IsFile() ) + { + aWriteStream.WriteUint8L( 11 ); // 2 = file ID + aWriteStream.WriteInt32L( iFileName.Length() ); + aWriteStream.WriteL( iFileName ); + } + + if( iFileSize > 0 ) + { + aWriteStream.WriteUint8L( 12 ); + TBuf8< 50 > val; + val.AppendNum( iFileSize ); + aWriteStream.WriteInt32L( val.Length() ); + aWriteStream.WriteL( val ); + } + if( iNotifyProgress > 0 ) + { + aWriteStream.WriteUint8L( 13 ); + TBuf8< 50 > val; + val.AppendNum( iNotifyProgress ); + aWriteStream.WriteInt32L( val.Length() ); + aWriteStream.WriteL( val ); + } + aWriteStream.WriteUint8L(0); // no more headers in the stream flag + } + +// ----------------------------------------------------------------------------- +// CMSRPMessage::IsMessage +// ----------------------------------------------------------------------------- +// +EXPORT_C TBool CMSRPMessage::IsMessage( const TDesC8& aBuffer ) + { + if ( aBuffer.Length() ) + { + if ( aBuffer[ 0 ] == 100 ) + { + return ETrue; + } + } + + return EFalse; + } + +EXPORT_C TBool CMSRPMessage::IsFile() + { + if ( iFileName.Length() ) + { + return ETrue; + } + return EFalse; + +} + + +EXPORT_C void CMSRPMessage::SetNotifyProgress(TBool aNotify) + { + iNotifyProgress = aNotify; + } + +EXPORT_C TBool CMSRPMessage::GetNotifyProgress() + { + return iNotifyProgress; + } +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/src/CMsrpMessageIdHeader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/src/CMsrpMessageIdHeader.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,167 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMsrpMessageIdHeader.h" + +// INTERNAL INCLUDES +#include "msrpstrings.h" +#include "msrpstrconsts.h" + +// ----------------------------------------------------------------------------- +// CMSRPMessageIdHeader::NewLC +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPMessageIdHeader* CMSRPMessageIdHeader::NewLC( + const TDesC8& aMessageId ) + { + CMSRPMessageIdHeader* self = new (ELeave) CMSRPMessageIdHeader(); + CleanupStack::PushL( self ); + self->ConstructL( aMessageId ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageIdHeader::NewL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPMessageIdHeader* CMSRPMessageIdHeader::NewL( + const TDesC8& aMessageId ) + { + CMSRPMessageIdHeader* self = CMSRPMessageIdHeader::NewLC( aMessageId ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageIdHeader::NewL +// ----------------------------------------------------------------------------- +// +CMSRPMessageIdHeader* CMSRPMessageIdHeader::NewL( ) + { + CMSRPMessageIdHeader* self = new (ELeave) CMSRPMessageIdHeader(); + CleanupStack::PushL( self ); + self->ConstructL( ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageIdHeader::CMSRPMessageIdHeader +// ----------------------------------------------------------------------------- +// +CMSRPMessageIdHeader::CMSRPMessageIdHeader() + { + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageIdHeader::ConstructL +// ----------------------------------------------------------------------------- +// +void CMSRPMessageIdHeader::ConstructL( + const TDesC8& aMessageId ) + { + MSRPStrings::OpenL(); + // set the ID + iIdValue = HBufC8::NewL( aMessageId.Length() ); + *iIdValue = aMessageId; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageIdHeader::ConstructL +// ----------------------------------------------------------------------------- +// +void CMSRPMessageIdHeader::ConstructL( ) + { + MSRPStrings::OpenL(); + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageIdHeader::~CMSRPMessageIdHeader +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPMessageIdHeader::~CMSRPMessageIdHeader() + { + MSRPStrings::Close(); + delete iIdValue; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageIdHeader::InternalizeValueL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPMessageIdHeader* CMSRPMessageIdHeader::InternalizeValueL( + RReadStream& aReadStream ) + { + CMSRPMessageIdHeader* self = CMSRPMessageIdHeader::NewL( ); + CleanupStack::PushL( self ); + self->DoInternalizeValueL( aReadStream ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageIdHeader::DoInternalizeValueL +// ----------------------------------------------------------------------------- +// +void CMSRPMessageIdHeader::DoInternalizeValueL( RReadStream& aReadStream ) + { + // value must be in stringpool + TUint32 valueLength = aReadStream.ReadUint32L(); + if( valueLength > 0 ) + { + delete iIdValue; + iIdValue = NULL; + iIdValue = HBufC8::NewL( valueLength ); + TPtr8 tempValue( iIdValue->Des() ); + aReadStream.ReadL( tempValue, valueLength ); + } + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageIdHeader::ExternalizeValueL +// From CSIPHeaderBase: +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPMessageIdHeader::ExternalizeValueL( RWriteStream& aWriteStream ) const + { + aWriteStream.WriteInt32L( iIdValue->Length() ); + aWriteStream.WriteL( *iIdValue ); + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageIdHeader::Name +// ----------------------------------------------------------------------------- +// +RStringF CMSRPMessageIdHeader::Name() const + { + return MSRPStrings::StringF( MSRPStrConsts::EMessageId ); + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageIdHeader::ToTextValueL +// ----------------------------------------------------------------------------- +// +HBufC8* CMSRPMessageIdHeader::ToTextValueL() const + { + if( iIdValue ) + { + return iIdValue->Des().AllocL(); + } + return NULL; + } + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/src/CMsrpResponse.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/src/CMsrpResponse.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,229 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMsrpResponse.h" + +// EXTERNAL HEADER +#include + +// INTERNAL HEADER +#include "MsrpCommon.h" +#include "TMSRPHeaderUtil.h" +#include "CMSRPFromPathHeader.h" +#include "CMSRPToPathHeader.h" +#include "CMSRPMessageIdHeader.h" +#include "CMSRPByteRangeHeader.h" +#include "CMSRPContentTypeHeader.h" +#include "CMSRPFailureReportHeader.h" +#include "CMSRPSuccessReportHeader.h" + +// ----------------------------------------------------------------------------- +// CMSRPResponse::CMSRPResponse +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPResponse::CMSRPResponse( TUint aStatusCode, RStringF aReasonPhrase ) + : iStatusCode( aStatusCode ) + { + iReasonPhrase = aReasonPhrase.Copy(); + } + +// ----------------------------------------------------------------------------- +// CMSRPResponse::CMSRPResponse +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPResponse::CMSRPResponse( ) + { + } + +// ----------------------------------------------------------------------------- +// CMSRPResponse::~CMSRPResponse +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPResponse::~CMSRPResponse() + { + } + +// ----------------------------------------------------------------------------- +// CMSRPResponse::SetStatusCodeL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPResponse::SetStatusCodeL( TUint aStatusCode ) + { + // make sure the status code is valid + // sip status codes must be between 200 - 600 + __ASSERT_ALWAYS( aStatusCode < 600, User::Leave( KErrArgument ) ); // codescanner::magicnumbers + __ASSERT_ALWAYS( aStatusCode >= 200, User::Leave( KErrArgument ) ); // codescanner::magicnumbers + + iStatusCode = aStatusCode; + } + +// ----------------------------------------------------------------------------- +// CMSRPResponse::StatusCode +// ----------------------------------------------------------------------------- +// +EXPORT_C TUint CMSRPResponse::StatusCode() const + { + return iStatusCode; + } + +// ----------------------------------------------------------------------------- +// CMSRPResponse::SetReasonPhraseL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPResponse::SetReasonPhrase( RStringF aReasonPhrase ) + { + iReasonPhrase = aReasonPhrase.Copy(); + } + +// ----------------------------------------------------------------------------- +// CMSRPResponse::ReasonPhrase +// ----------------------------------------------------------------------------- +// +EXPORT_C RStringF CMSRPResponse::ReasonPhrase() const + { + return iReasonPhrase; + } + +// ----------------------------------------------------------------------------- +// CMSRPResponse::InternalizeL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPResponse* CMSRPResponse::InternalizeL( RReadStream& aReadStream ) + { + CMSRPResponse* self = new (ELeave ) CMSRPResponse(); + CleanupStack::PushL( self ); + self->DoInternalizeL( aReadStream ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPResponse::ExternalizeL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CMSRPResponse::ExternalizeL( RWriteStream& aWriteStream ) + { + // first add the MSRP Message identifier + aWriteStream.WriteUint8L( 101 ); // MSRP Response identifier + + // Reason code + TBuf8< KMaxLengthOfStatusCode > value; + + // status code + value.AppendNum( iStatusCode, EDecimal ); + aWriteStream.WriteInt32L( value.Length() ); + aWriteStream.WriteL( value ); + + // then reason phrase + aWriteStream.WriteInt32L( iReasonPhrase.DesC().Length() ); + aWriteStream.WriteL( iReasonPhrase.DesC() ); + + if( iFromPath ) + { + aWriteStream.WriteUint8L(1); // more headers in the stream flag + iFromPath->ExternalizeValueL( aWriteStream ); + } + if( iToPath ) + { + aWriteStream.WriteUint8L(2); // more headers in the stream flag + iToPath->ExternalizeValueL( aWriteStream ); + } + + aWriteStream.WriteUint8L(0); // no more headers in the stream flag + } + +// ----------------------------------------------------------------------------- +// CMSRPResponse::DoInternalizeL +// ----------------------------------------------------------------------------- +// +void CMSRPResponse::DoInternalizeL( RReadStream& aReadStream ) + { + TUint8 dataType( 0 ); + + RStringPool strings; + CleanupClosePushL( strings ); + strings.OpenL( MSRPStrConsts::Table ); + + // read the identifier + if ( aReadStream.ReadUint8L() != 101 ) + { + User::Leave( KErrArgument ); + } + + // The reason code + TUint32 codeLength = aReadStream.ReadUint32L(); + HBufC8* codeInString = HBufC8::NewLC( codeLength ); + TPtr8 codePtr( codeInString->Des() ); + aReadStream.ReadL( codePtr, codeLength ); + iStatusCode = TMSRPHeaderUtil::ConvertToNumber( codeInString->Des() ); + CleanupStack::PopAndDestroy( codeInString ); + + // then reason phrase + TUint32 phraseLength = aReadStream.ReadUint32L(); + HBufC8* phraseInString = HBufC8::NewLC( codeLength ); + TPtr8 phrasePtr( phraseInString->Des() ); + aReadStream.ReadL( phrasePtr, phraseLength ); + iReasonPhrase = strings.OpenFStringL( phrasePtr ); + CleanupStack::PopAndDestroy( phraseInString ); + + // and headers + do + { + dataType = aReadStream.ReadUint8L(); + + switch( dataType ) + { + case 1: // from path + { + iFromPath = CMSRPFromPathHeader::InternalizeValueL( aReadStream ); + break; + } + case 2: // to path + { + iToPath = CMSRPToPathHeader::InternalizeValueL( aReadStream ); + break; + } + default: + { + // nothing to do + break; + } + } + + } while( dataType ); + + CleanupStack::PopAndDestroy( ); // strings, codescanner::cleanup + } + +// ----------------------------------------------------------------------------- +// CMSRPResponse::IsResponse +// ----------------------------------------------------------------------------- +// +EXPORT_C TBool CMSRPResponse::IsResponse( const TDesC8& aBuffer ) + { + if ( aBuffer.Length() ) + { + if ( aBuffer[ 0 ] == 101 ) + { + return ETrue; + } + } + + return EFalse; + } + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/src/CMsrpStrings.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/src/CMsrpStrings.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMSRPStrings.h" + +// EXTERNAL INCLUDES +#include + +// ---------------------------------------------------------------------------- +// CMSRPStrings::NewLC +// ---------------------------------------------------------------------------- +// +CMSRPStrings* CMSRPStrings::NewL() + { + CMSRPStrings* self = NewLC(); + CleanupStack::Pop(self); + return self; + } + +// ---------------------------------------------------------------------------- +// CMSRPStrings::NewLC +// ---------------------------------------------------------------------------- +// +CMSRPStrings* CMSRPStrings::NewLC() + { + CMSRPStrings* self = new(ELeave)CMSRPStrings; + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// ---------------------------------------------------------------------------- +// CMSRPStrings::CMSRPStrings +// ---------------------------------------------------------------------------- +// +CMSRPStrings::CMSRPStrings() + : iUsageCount(1) + { + } + +// ---------------------------------------------------------------------------- +// CMSRPStrings::ConstructL +// ---------------------------------------------------------------------------- +// +void CMSRPStrings::ConstructL() + { + iPool.OpenL( MSRPStrConsts::Table ); + } + +// ---------------------------------------------------------------------------- +// CMSRPStrings::~CMSRPStrings +// ---------------------------------------------------------------------------- +// +CMSRPStrings::~CMSRPStrings() + { + iPool.Close(); + } + +// ----------------------------------------------------------------------------- +// CMSRPStrings::IncrementUsageCount +// ----------------------------------------------------------------------------- +// +void CMSRPStrings::IncrementUsageCount() + { + iUsageCount++; + } + +// ----------------------------------------------------------------------------- +// CMSRPStrings::DecrementUsageCount +// ----------------------------------------------------------------------------- +// +void CMSRPStrings::DecrementUsageCount() + { + iUsageCount--; + } + +// ----------------------------------------------------------------------------- +// CMSRPStrings::UsageCount +// ----------------------------------------------------------------------------- +// +TUint CMSRPStrings::UsageCount() const + { + return iUsageCount; + } + +// ---------------------------------------------------------------------------- +// CMSRPStrings::StringPool +// ---------------------------------------------------------------------------- +// +const RStringPool& CMSRPStrings::Pool() const + { + return iPool; + } + +// ---------------------------------------------------------------------------- +// CMSRPStrings::StringTable +// ---------------------------------------------------------------------------- +// +const TStringTable& CMSRPStrings::Table() + { + return MSRPStrConsts::Table; + } + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/src/CMsrpSuccessReportHeader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/src/CMsrpSuccessReportHeader.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,186 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMsrpSuccessReportHeader.h" + +// INTERNAL INCLUDES +#include "msrpstrings.h" +#include "msrpstrconsts.h" + +// ----------------------------------------------------------------------------- +// CMSRPSuccessReportHeader::NewLC +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPSuccessReportHeader* CMSRPSuccessReportHeader::NewLC( + const RStringF& aType ) + { + CMSRPSuccessReportHeader* self = new (ELeave) CMSRPSuccessReportHeader(); + CleanupStack::PushL( self ); + self->ConstructL( aType ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPSuccessReportHeader::NewL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPSuccessReportHeader* CMSRPSuccessReportHeader::NewL( + const RStringF& aType ) + { + CMSRPSuccessReportHeader* self = CMSRPSuccessReportHeader::NewLC( aType ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPSuccessReportHeader::NewL +// ----------------------------------------------------------------------------- +// +CMSRPSuccessReportHeader* CMSRPSuccessReportHeader::NewL( ) + { + CMSRPSuccessReportHeader* self = new (ELeave) CMSRPSuccessReportHeader(); + CleanupStack::PushL( self ); + self->ConstructL( ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPSuccessReportHeader::CMSRPSuccessReportHeader +// ----------------------------------------------------------------------------- +// +CMSRPSuccessReportHeader::CMSRPSuccessReportHeader() + { + } + +// ----------------------------------------------------------------------------- +// CMSRPSuccessReportHeader::ConstructL +// ----------------------------------------------------------------------------- +// +void CMSRPSuccessReportHeader::ConstructL( + RStringF aType ) + { + MSRPStrings::OpenL(); + iReportType = aType.Copy(); + } + +// ----------------------------------------------------------------------------- +// CMSRPSuccessReportHeader::ConstructL +// ----------------------------------------------------------------------------- +// +void CMSRPSuccessReportHeader::ConstructL( ) + { + MSRPStrings::OpenL(); + } + +// ----------------------------------------------------------------------------- +// CMSRPSuccessReportHeader::~CMSRPSuccessReportHeader +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPSuccessReportHeader::~CMSRPSuccessReportHeader() + { + MSRPStrings::Close(); + } + +// ----------------------------------------------------------------------------- +// CMSRPSuccessReportHeader::InternalizeValueL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPSuccessReportHeader* CMSRPSuccessReportHeader::InternalizeValueL( + RReadStream& aReadStream ) + { + CMSRPSuccessReportHeader* self = CMSRPSuccessReportHeader::NewL( ); + CleanupStack::PushL( self ); + self->DoInternalizeValueL( aReadStream ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPSuccessReportHeader::DoInternalizeValueL +// ----------------------------------------------------------------------------- +// +void CMSRPSuccessReportHeader::DoInternalizeValueL( RReadStream& aReadStream ) + { + // value must be in stringpool + TUint32 valueLength = aReadStream.ReadUint32L(); + if( valueLength > 0 ) + { + HBufC8* tempBuffer = HBufC8::NewLC( valueLength ); + TPtr8 tempValue( tempBuffer->Des() ); + aReadStream.ReadL( tempValue, valueLength ); + + // let's check if the value matches the supported content-types + RStringF tempString = MSRPStrings::StringF( MSRPStrConsts::EYes ); + if( tempString.DesC() == tempValue ) + { + // OK + iReportType = tempString.Copy(); + } + else + { + RStringF tempStr = MSRPStrings::StringF( MSRPStrConsts::ENo ); + if( tempStr.DesC() == tempValue ) + { + // OK + iReportType = tempStr.Copy(); + } + else + { + // not supported + CleanupStack::PopAndDestroy( tempBuffer ); + User::Leave( KErrNotSupported ); + } + } + CleanupStack::PopAndDestroy( tempBuffer ); + } + } + +// ----------------------------------------------------------------------------- +// CMSRPSuccessReportHeader::ExternalizeValueL +// From CSIPHeaderBase: +// ----------------------------------------------------------------------------- +// +void CMSRPSuccessReportHeader::ExternalizeValueL( RWriteStream& aWriteStream ) const + { + aWriteStream.WriteInt32L( iReportType.DesC().Length() ); + aWriteStream.WriteL( iReportType.DesC() ); + } + +// ----------------------------------------------------------------------------- +// CMSRPFailureReportHeader::Name +// ----------------------------------------------------------------------------- +// +RStringF CMSRPSuccessReportHeader::Name() const + { + return MSRPStrings::StringF( MSRPStrConsts::ESuccessReport ); + } + +// ----------------------------------------------------------------------------- +// CMSRPFailureReportHeader::ToTextValueL +// ----------------------------------------------------------------------------- +// +HBufC8* CMSRPSuccessReportHeader::ToTextValueL() const + { + if( iReportType.DesC().Length() ) + { + return iReportType.DesC().AllocL(); + } + return NULL; + } + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/src/CMsrpToPathHeader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/src/CMsrpToPathHeader.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,181 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMsrpToPathHeader.h" + +// EXTERNAL INCLUDES + +// INTERNAL INCLUDES +#include "MsrpCommon.h" +#include "msrpstrings.h" +#include "msrpstrconsts.h" + +// ----------------------------------------------------------------------------- +// CMSRPToPathHeader::DecodeL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPToPathHeader* CMSRPToPathHeader::DecodeL( + const TDesC8& aUri ) + { + CMSRPToPathHeader* self = new (ELeave) CMSRPToPathHeader(); + CleanupStack::PushL( self ); + + // parsing the descriptor URL + CUri8* uri = CUri8::NewLC( ); + // first is the scheme + TChar charToFind( KColonCharacter ); + TInt matchLoc = aUri.Locate( charToFind ); + if ( matchLoc != KErrNotFound ) + { + TPtrC8 scheme = aUri.Left( matchLoc ); + uri->SetComponentL( scheme, EUriScheme ); + // after that comes the ipaddress which must have // in front + TPtrC8 host = aUri.Mid( matchLoc + 3 ); // codescanner::magicnumbers + matchLoc = host.Locate( charToFind ); + if ( matchLoc != KErrNotFound ) + { + uri->SetComponentL( host.Left( matchLoc ), EUriHost ); + // next is the port + TPtrC8 port = host.Mid( matchLoc + 1 ); + TChar charToFind2( KDividedCharacter ); + matchLoc = port.Locate( charToFind2 ); + if ( matchLoc != KErrNotFound ) + { + uri->SetComponentL( port.Left( matchLoc ), EUriPort ); + TPtrC8 path = port.Mid( matchLoc ); + uri->SetComponentL( path, EUriPath ); + } + else + { + // there is not path set + User::Leave( KErrArgument ); + } + } + else + { + User::Leave( KErrArgument ); + } + } + else + { + User::Leave( KErrArgument ); + } + + self->ConstructL( uri ); + CleanupStack::Pop( uri ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPToPathHeader::NewLC +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPToPathHeader* CMSRPToPathHeader::NewLC( + CUri8* aUri ) + { + CMSRPToPathHeader* self = new (ELeave) CMSRPToPathHeader(); + CleanupStack::PushL( self ); + self->ConstructL( aUri ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPToPathHeader::NewL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPToPathHeader* CMSRPToPathHeader::NewL( + CUri8* aUri ) + { + CMSRPToPathHeader* self = CMSRPToPathHeader::NewLC( aUri ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPToPathHeader::NewL +// ----------------------------------------------------------------------------- +// +CMSRPToPathHeader* CMSRPToPathHeader::NewL( ) + { + CMSRPToPathHeader* self = new (ELeave) CMSRPToPathHeader(); + CleanupStack::PushL( self ); + self->ConstructL( ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPToPathHeader::CMSRPToPathHeader +// ----------------------------------------------------------------------------- +// +CMSRPToPathHeader::CMSRPToPathHeader() + { + } + +// ----------------------------------------------------------------------------- +// CMSRPToPathHeader::~CMSRPToPathHeader +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPToPathHeader::~CMSRPToPathHeader() + { + MSRPStrings::Close(); + } + +// ----------------------------------------------------------------------------- +// CMSRPFromPathHeader::ConstructL +// ----------------------------------------------------------------------------- +// +void CMSRPToPathHeader::ConstructL( CUri8* aUri ) + { + MSRPStrings::OpenL(); + iUri = aUri; + } + +// ----------------------------------------------------------------------------- +// CMSRPFromPathHeader::ConstructL +// ----------------------------------------------------------------------------- +// +void CMSRPToPathHeader::ConstructL( ) + { + MSRPStrings::OpenL(); + } + +// ----------------------------------------------------------------------------- +// CMSRPToPathHeader::InternalizeValueL +// ----------------------------------------------------------------------------- +// +EXPORT_C CMSRPToPathHeader* CMSRPToPathHeader::InternalizeValueL( + RReadStream& aReadStream ) + { + CMSRPToPathHeader* self = CMSRPToPathHeader::NewL( ); + CleanupStack::PushL( self ); + self->DoInternalizeValueL( aReadStream ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPToPathHeader::Name +// ----------------------------------------------------------------------------- +// +RStringF CMSRPToPathHeader::Name() const + { + return MSRPStrings::StringF( MSRPStrConsts::EToPath ); + } + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/src/MSRPStrings.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/src/MSRPStrings.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,126 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "MSRPStrings.h" + +// INTERNAL INCLUDES +#include "CMSRPTlsPtrs.h" +#include "CMSRPStrings.h" + +// ----------------------------------------------------------------------------- +// MSRPStrings::OpenL +// ----------------------------------------------------------------------------- +// +EXPORT_C void MSRPStrings::OpenL( RStringPool& aStringPool ) + { + OpenL(); + aStringPool.OpenL( Table() ); + } + +// ----------------------------------------------------------------------------- +// MSRPStrings::OpenL +// ----------------------------------------------------------------------------- +// +EXPORT_C void MSRPStrings::OpenL() + { + CMSRPTlsPtrs* tlsPtrs = static_cast( Dll::Tls() ); + if( !tlsPtrs ) + { + CMSRPStrings* strings = CMSRPStrings::NewL(); + CleanupStack::PushL( strings ); + tlsPtrs = new (ELeave) CMSRPTlsPtrs( strings ); + CleanupStack::Pop( strings ); + CleanupStack::PushL( tlsPtrs ); + User::LeaveIfError( Dll::SetTls( tlsPtrs ) ); + CleanupStack::Pop( tlsPtrs ); + } + else + { + CMSRPStrings* strings = tlsPtrs->GetMsrpString(); + __ASSERT_ALWAYS( strings, + User::Panic( KNullDesC, KErrAlreadyExists )); + strings->IncrementUsageCount(); + } + } + +// ----------------------------------------------------------------------------- +// MSRPStrings::Close +// Closes & deletes string pool +// ----------------------------------------------------------------------------- +// +EXPORT_C void MSRPStrings::Close() + { + CMSRPTlsPtrs* tlsPtrs = static_cast( Dll::Tls() ); + if ( !tlsPtrs ) + { + return; + } + CMSRPStrings* strings = tlsPtrs->GetMsrpString(); + + __ASSERT_ALWAYS( strings, User::Panic( KNullDesC, KErrNotFound )); + strings->DecrementUsageCount(); + if ( strings->UsageCount() == 0 ) + { + delete tlsPtrs; + Dll::FreeTls(); + } + } + +// ----------------------------------------------------------------------------- +// MSRPStrings::StringF +// ----------------------------------------------------------------------------- +// +EXPORT_C RStringF MSRPStrings::StringF( TInt aIndex ) + { + CMSRPStrings* strings = Strings(); + return strings->Pool().StringF( aIndex, strings->Table() ); + } + +// ----------------------------------------------------------------------------- +// MSRPStrings::StringPool +// Returns string pool +// ----------------------------------------------------------------------------- +// +EXPORT_C RStringPool MSRPStrings::Pool() + { + return Strings()->Pool(); + } + +// ----------------------------------------------------------------------------- +// MSRPStrings::StringTableL +// Returns string table +// ----------------------------------------------------------------------------- +// +EXPORT_C const TStringTable& MSRPStrings::Table() + { + return Strings()->Table(); + } + +// ----------------------------------------------------------------------------- +// MSRPStrings::Strings +// ----------------------------------------------------------------------------- +// +CMSRPStrings* MSRPStrings::Strings() + { + CMSRPTlsPtrs* tlsPtrs = static_cast( Dll::Tls() ); + __ASSERT_ALWAYS( tlsPtrs, User::Panic( KNullDesC, KErrNotReady ) ); + + CMSRPStrings* strings = tlsPtrs->GetMsrpString(); + __ASSERT_ALWAYS( strings, User::Panic( KNullDesC, KErrNotReady ) ); + + return strings; + } diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/src/TMSRPHeaderUtil.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/src/TMSRPHeaderUtil.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,111 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "TMSRPHeaderUtil.h" + +// INTERNAL INCLUDES +#include "MsrpCommon.h" +#include "CMSRPByteRangeHeader.h" + + +// ----------------------------------------------------------------------------- +// TMSRPHeaderUtil::ConvertToNumberL +// ----------------------------------------------------------------------------- +// +TInt TMSRPHeaderUtil::ConvertToNumber( const TDesC8& aString ) + { + // checking for special characters: + // Unknown byte range end + if ( aString == KAsterisk ) + { + // Range unknown + return KUnknownRange; + } + TLex8 numberToConvert( aString ); + TInt convertedNumber( 0 ); + numberToConvert.Val( convertedNumber ); + + return convertedNumber; + } + +// ----------------------------------------------------------------------------- +// TMSRPHeaderUtil::AppendStringL +// ----------------------------------------------------------------------------- +// +void TMSRPHeaderUtil::AppendStringL( const TDesC8& aString, TDes8& aDest ) + { + TInt newLength = aString.Length() + aDest.Length(); + if ( newLength > aDest.MaxLength() ) + { + // not enough room + User::Leave( KErrArgument ); + } + aDest.Append( aString ); + } + +// ----------------------------------------------------------------------------- +// TMSRPHeaderUtil::CheckStringValidity +// ----------------------------------------------------------------------------- +// +TBool TMSRPHeaderUtil::CheckStringValidity( const TDesC8& aString ) + { + if ( !aString.Length() ) + { + return EFalse; + } + + // Checks the syntax for the Content-Type string only. May need to extend to other headers as well + + TChar charToFind( KDividedCharacter ); + TInt matchLoc = aString.Locate( charToFind ); + if( matchLoc == KErrNotFound || matchLoc == (aString.Length() -1) ) + { + return EFalse; + } + + TPtrC8 typePtr = aString.Left(matchLoc); + TLex8 lex( typePtr ); + TChar chr = lex.Get(); + while ( chr ) + { + if ( !chr.IsAlphaDigit() && chr != '!' && chr != '#' && chr != '$' && chr != '%' && chr != '&' && + chr != '\'' && chr != '*' && chr != '+' && chr != '-' && chr != '.' && chr != '^' && + chr != '_' && chr != '`' && chr != '{' && chr != '|' && chr != '}' && chr != '~' ) + { + return EFalse; + } + chr = lex.Get(); + } + + TPtrC8 subtypePtr = aString.Mid( matchLoc+1 ); + lex.Assign( subtypePtr ); + chr = lex.Get(); + while ( chr ) + { + if ( !chr.IsAlphaDigit() && chr != '!' && chr != '#' && chr != '$' && chr != '%' && chr != '&' && + chr != '\'' && chr != '*' && chr != '+' && chr != '-' && chr != '.' && chr != '^' && + chr != '_' && chr != '`' && chr != '{' && chr != '|' && chr != '}' && chr != '~' ) + { + return EFalse; + } + chr = lex.Get(); + } + + return ETrue; + } + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpHeader/strings/MSRPStrConsts.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpHeader/strings/MSRPStrConsts.st Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,84 @@ +# MSRP String table +fstringtable MSRPStrConsts +# Strings are case-sensitive +# +# +!// General constants +EEmpty +EMSRP MSRP +EUDP UDP +EUdp udp +ETCP TCP +ETcp tcp +!// MSRP methods +ESend SEND +EReport REPORT +# +!// MSRP reason phrases: +EAllOk OK +EUnintelligibleRequest Unintelligible Request +EActionNotAllowed Action Not Allowed +ETimeout Timeout +EStopSending Stop Sending +EMimeNotUnderstood Mime Not Understood +EParameterOutOfBounds Parameter Out of Bounds +ESessionDoesNotExist Session Does Not Exist +EUnknownRequestMethod Unknown Request +ESessionAlreadyBound Session Already in Use +# +!// MSRP URL scheme +EMSRPUrlScheme msrp +EMSRPUrlSchemeSecure msrps +# +!// MSRP transport protocol +ETcpMsrp TCP/MSRP +ETcpMsrpTls TCP/TLS/MSRP +# +!// MSRP SDP media type +EMessageMediaType message +# +!// MSRP SDP attributes +EAcceptTypes accept-types +EWrappedTypes accept-wrapped-types +EMaxSize max-size +EPath path +EFileName filename +EFileType filetype +EDisposition disposition +EFileSize filesize +EFileSelector file-selector +EFileDisposition file-disposition +EFileTransferId file-transfer-id +EFileTransfer file-transfer +EIcon icon +EHash hash +# +!// RFC 4145 additional attributes, used with MSRP +EMTSetup setup +EMTConnection connection +# +!// MSRP header names: +EToPath To-Path +EFromPath From-Path +ESuccessReport Success-Report +EFailureReport Failure-Report +EByteRange Byte-Range +EStatus Status +EContentType Content-Type +EMessageId Message-ID +EContentDisposition Content-Disposition +# +!// MSRP Report variable +EYes yes +ENo no +EPartial partial +!// MSRP status code field namespace +EStatusNameSpace 000 +# +!// Feature tags as defined in GSMA Image Share Definition 1.0 +EFeatureTagCsVoice +g.3gpp.cs-voice +EFeatureTagMmTel +g.ims.icsi.mmtel +EFeatureTagMessaging +g.oma.sip-im +EFeatureTagImageShare +g.3gpp.iari-ref%3Aurn%3Aurn-xxx%3A3gpp-application.ims.iari.gsma-is +EFeatureTagImageShareName +g.3gpp.app_ref +EFeatureTagImageShareValue \"urn%3Aurn-xxx%3A3gpp-application.ims.iari.gsma-is\" diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/group/bld.inf Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +PRJ_PLATFORMS +DEFAULT + +PRJ_MMPFILES +msrpserver.mmp + +// END OF FILE diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/group/msrpserver.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/group/msrpserver.mmp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// Capability assignment. +CAPABILITY ProtServ NetworkControl NetworkServices Location \ +ReadDeviceData WriteDeviceData + +// Nokia's Vendor ID. +VENDORID 0x101FB657 + +TARGET msrpserver.exe + +TARGETTYPE exe + +TARGETPATH /sys/bin + +UID 0x1000008d 0x2002B59E + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../../msrpheader/inc + +OS_LAYER_SYSTEMINCLUDE +MW_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src +SOURCE MSRPMain.cpp +SOURCE CMSRPServer.cpp +SOURCE CMSRPScheduler.cpp +SOURCE CMSRPTimeOutTimer.cpp +SOURCE CMSRPConnectionManager.cpp +SOURCE CMSRPConnection.cpp +SOURCE TMSRPUtil.cpp +SOURCE CMSRPServerSession.cpp +SOURCE CMSRPServerSubSession.cpp +SOURCE CMSRPConnListener.cpp +SOURCE CMSRPConnector.cpp +SOURCE CMSRPReader.cpp +SOURCE CMSRPParser.cpp +SOURCE CMSRPWriter.cpp +SOURCE CMSRPMessageHandler.cpp +SOURCE CMSRPMsgParser.cpp +SOURCE TStateFactory.cpp +SOURCE TStates.cpp +SOURCE CMSRPMessageChunkState.cpp + + + +LIBRARY euser.lib +LIBRARY sysutil.lib +LIBRARY esock.lib // RSocketServ +LIBRARY insock.lib // TInetAddr +LIBRARY commdb.lib +LIBRARY bafl.lib +LIBRARY random.lib +DEBUGLIBRARY flogger.lib +#if defined(__SERIES60_) +LIBRARY extendedconnpref.lib +LIBRARY netmeta.lib +#endif + +// end of file +LIBRARY msrpheader.lib estor.lib efsrv.lib inetprotutil.lib + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/CMSRPConnListener.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/CMSRPConnListener.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPCONNLISTENER_H_ +#define CMSRPCONNLISTENER_H_ + + +#include "MMSRPListener.h" +#include "CMSRPConnectionManager.h" +#include "MMSRPTimeOutObserver.h" +#include "CMSRPTimeOutTimer.h" +#include "MMSRPConnection.h" + +const TInt KListenQueueSize = 4; + +class CMSRPConnListener: public CActive, public MMSRPListener, public MMSRPTimeOutObserver + { + +public: + + //constructors and destructors + static MMSRPListener* NewL(CMSRPConnectionManager& aConnectionMngr); + + virtual ~CMSRPConnListener(); + + //MMsrpListener fns + + virtual void ListenL(); + + virtual void ListenCancel(); + + virtual void ListenCompletedL(TBool aValid); + + //MMsrpTimeoutObserver fn + virtual void TimerExpiredL(); + +protected: // from CActive + + void DoCancel(); + void RunL(); + TInt RunError(TInt aError); + + +private: + CMSRPConnListener(CMSRPConnectionManager& aConnectionMngr); + void ConstructL(); + void NotifyL(TListenerState aNewState); + virtual void ActivateL();//start listening + + +private: + TUint iListenCount; + RSocket* iDataSocket; + RSocket iListenSocket; + TListenerState iState; + CMSRPTimeOutTimer* iTimer; + CMSRPConnectionManager& iConnMngr; + }; + + + +#endif /* CMSRPCONNLISTENER_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/CMSRPConnection.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/CMSRPConnection.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,134 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPCONNECTION_H +#define CMSRPCONNECTION_H + +// INCLUDES + +#include "MMSRPConnector.h" +#include "MMSRPConnection.h" +#include "MMSRPReader.h" +#include "MMSRPReaderObserver.h" +#include "MMSRPParser.h" +#include "MMSRPWriter.h" +#include "MMSRPConnectionObserver.h" +#include "MMSRPTimeOutObserver.h" +#include "CMSRPTimeOutTimer.h" + +// FORWARD DECLARATIONS +class CMSRPMessageHandler; +class MMSRPConnection; +class MMSRPConnectionObserver; +class MMSRPReaderObserver; +class MMSRPWriterObserver; +class MMSRPReader; +class MMSRPConnectionManager; + +// CLASS DECLARATION + +/** +* MSRP Connection Manager +*/ +class CMSRPConnection : public CBase, public MMSRPConnection, public MMSRPConnectorObserver, + public MMSRPReaderObserver, public MMSRPParserObserver, + public MMSRPWriterErrorObserver, public MMSRPTimeOutObserver + { + public: + + // Constructors and destructor + + static MMSRPConnection* NewL( TInetAddr& aRemoteAddr, MMSRPConnectionManager& aConnMngr); + + virtual ~CMSRPConnection(); + + public: // Functions from base classes + + // From MMSRPConnection + virtual TBool CheckConnection(TInetAddr& aRemoteAddr, TBool aOnlyListen); + + virtual TInt ConnectL(MMSRPConnectionObserver& aSubsession); + + virtual TInt ListenL(MMSRPConnectionObserver& aSubsession); + + virtual void ReleaseConnection(MMSRPConnectionObserver& aSubsession); + + virtual void SendL( MMSRPWriterObserver& aMsg /*, MMSRPConnectionObserver& aSubsession*/ ); + + virtual void ConnectionEstablishedL( TInt aNewState, RSocket* aSocket, TInt aStatus ); + + virtual TInt getConnectionState(); + + //from MMSRPConnectorObserver + + //virtual void ConnectionEstablishedL( TInt aNewState, RSocket* aDataSocket, TInt aStatus ); + + //from MMSRPReaderObserver + + virtual void ReadStatusL(RMsrpBuf& aBuf, TInt aStatus); + + //from MMSRPParserObserver + virtual void ParseStatusL (CMSRPMessageHandler* aMsg, TInt aStatus); + + //from MMSRPWriterErrorObserver + virtual void WriteSocketError(TInt aError); + + //from timeout + void TimerExpiredL(); + + + private: // constructor + + CMSRPConnection(TInetAddr& aRemoteAddr, MMSRPConnectionManager& aConnMngr ); + + void ConstructL( ); + + void Remove(MMSRPConnectionObserver* aSubsession); + + void NotifyAllL(TInt aNewState, TInt aStatus ); + + void CloseConnection( ); + + + private: // data + + TInetAddr iHostAddress; + + MMSRPConnectionManager& iConnMngr; + + TInt iConnectionState; + + RPointerArray iSubsessions; + + MMSRPConnector* iConnector; + + MMSRPReader* iReader; + + MMSRPParser* iParser; + + MMSRPWriter* iWriter; + + CMSRPBufPool iBufPool; + + RSocket* iSocket; + + CMSRPTimeOutTimer* iListenTimer; + + }; + +#endif // CMSRPCONNECTION_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/CMSRPConnectionManager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/CMSRPConnectionManager.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPCONNECTIONMANAGER_H +#define CMSRPCONNECTIONMANAGER_H + +// INCLUDES +#include "MMSRPConnectionManager.h" +#include "MMSRPConnectionManagerObserver.h" +#include "MMSRPListenerObserver.h" +#include "MMSRPListener.h" +#include "MMSRPConnection.h" + + +// FORWARD DECLARATIONS +class MMSRPConnectionManagerObserver; +class MMSRPConnection; + +// CLASS DECLARATION + +/** +* MSRP Connection Manager +*/ +class CMSRPConnectionManager : public CBase, public MMSRPConnectionManager + , public MMSRPListenerObserver + { + + public: + + /* Constructors and destructor*/ + + static CMSRPConnectionManager* NewL( const TUint32 aIapID, MMSRPConnectionManagerObserver& aServer ); + + virtual ~CMSRPConnectionManager(); + + + /*Functions from base classes*/ + /* from MMSRPConnectionManager*/ + + virtual void ResolveLocalIPAddressL( TInetAddr& aLocalAddr ); + + virtual MMSRPConnection& getConnectionL( TDesC8& aHost, TUint aPort ); + + + //called by conn + virtual void ListenL(MMSRPConnection* aConnection); + + virtual void ListenCancel(MMSRPConnection* aConnection); + + virtual void Remove(MMSRPConnection* aConnection); + + virtual RSocketServ& SocketServer(); + + virtual RConnection& SocketServerConn() ; + + //virtual TBool MatchIapId(TUint32 aIapID); + + + /* from MMSRPListenerObserver */ + virtual void ListenerStateL( TInt aNewState, RSocket* aDataSocket, TInt aStatus ); + + + + private: + + // internal functions + /** + * remote address resolution + */ + void ResolveIPAddressL( const TDesC8& aHost, TInetAddr& aAddress ); + + /** + * check if we have a connection to the same host and port + */ + MMSRPConnection* CheckConnection( TInetAddr& aHostAddress ,TBool aListenOnly); + + /** + * start up the connection on iap + */ + TInt StartInterface(); + + + // constructors + + CMSRPConnectionManager( const TUint32 aIapID, MMSRPConnectionManagerObserver& aServer ); + + void ConstructL(); + + private: // data + + RPointerArray iConnectionArray; + MMSRPListener* iConnListener; + + RSocketServ iSocketServer; + RConnection iConnection; + RHostResolver iHostResolver; + TUint32 iIapID; + TInetAddr iLocalAddr; + + MMSRPConnectionManagerObserver& iObserver; + }; + +#endif // CMSRPCONNECTIONMANAGER_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/CMSRPConnector.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/CMSRPConnector.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPCONNECTOR_H +#define CMSRPCONNECTOR_H + +// INTERNAL INCLUDES +#include "MMSRPConnector.h" +#include "MMSRPTimeOutObserver.h" +#include "CMSRPTimeOutTimer.h" +#include "MMSRPConnectionManager.h" +#include "MMSRPConnection.h" + + +// CLASS DECLARATION + +/** +* MSRP Connection Manager +*/ +class CMSRPConnector : public CActive, public MMSRPConnector, public MMSRPTimeOutObserver + { + public: + + // Constructors and destructor + static MMSRPConnector* NewL(MMSRPConnectionManager& aConnMngr, MMSRPConnectorObserver& aConnection); + virtual ~CMSRPConnector(); + + //from MMSRPConnector + void Connect(TInetAddr& aRemoteAddr); + void ConnectComplete(); + + //from MMSRPTimeOutObserver + void TimerExpiredL(); + + + protected: // from CActive + void DoCancel(); + void RunL(); + TInt RunError(TInt aError); + + private: + CMSRPConnector(MMSRPConnectionManager& aConnMngr, MMSRPConnectorObserver& aConnection); + void ConstructL(); + + private: // data + CMSRPTimeOutTimer* iTimer; + MMSRPConnectionManager& iConnMngr; + MMSRPConnectorObserver& iConnection; + RSocket* iSocket; + + + }; + +#endif // CMSRPCONNECTOR_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/CMSRPMessageChunkState.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/CMSRPMessageChunkState.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPMESSAGECHUNKSTATE_H_ +#define CMSRPMESSAGECHUNKSTATE_H_ + +// System Includes +#include +#include + +const TInt KMaxLgthOfTransactionIdString = 100; + + +class CMSRPMessageChunkState : public CBase + { + +public: // Constructors and destructor + IMPORT_C static CMSRPMessageChunkState* NewL( ); + IMPORT_C ~CMSRPMessageChunkState(); + + + IMPORT_C TBool GetResponseReceived( ); + IMPORT_C void SetResponseReceived(TBool aResponseReceived); + IMPORT_C TDesC8& GetTransactionId( ); + IMPORT_C void SetTransactionId(TDesC8& aTransactionId ); + IMPORT_C void SetStartPos(TInt aStartPos); + IMPORT_C void SetEndPos(TInt aEndPos); + IMPORT_C TInt GetStartPos( ); + IMPORT_C TInt GetEndPos( ); + IMPORT_C void SetResponseSent(TBool aResponseSent); + IMPORT_C TBool GetResponseSent( ); + +private: + + CMSRPMessageChunkState(); + // void ConstructL(); + + + + +private: + TInt iStartPos; + TInt iEndPos; + TBuf8< KMaxLgthOfTransactionIdString > iTransactionId; + TBool iResponseReceived; + TBool iResponseSent; + }; + + + + + +#endif /* CMSRPMESSAGECHUNKSTATE_H_ */ + + + + + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/CMSRPMessageHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/CMSRPMessageHandler.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,242 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPMESSAGEHANDLER_H_ +#define CMSRPMESSAGEHANDLER_H_ + +// INCLUDES +#include +#include + +#include "MSRPCommon.h" +#include "MMSRPMessageHandler.h" +#include "MMSRPIncomingMessage.h" +#include "MMSRPOutgoingMessage.h" +#include "MMSRPWriterObserver.h" +#include "CMSRPMessageChunkState.h" + +// Forward declarations +class MMSRPMessageHandler; +class MMSRPIncomingMessage; +class MMSRPOutgoingMessage; +class MMSRPWriterObserver; +class MMSRPMessageObserver; +class CMSRPMessage; +class CMSRPResponse; +class CMSRPReport; +class CMSRPMessageBase; +class RStringF; + +// Constants +const TInt KMaxBufferSize = 2500; +const TInt KSmallBuffer = 1024; +const TInt KMaxChunkReadSize = 65000; +// Class declaration + +/* MSRP Message handler + * + */ + +class CMSRPMessageHandler : public CBase, public MMSRPMessageHandler, + public MMSRPIncomingMessage, public MMSRPOutgoingMessage, + public MMSRPWriterObserver + { +public: + + enum TMSRPMessageState + { + EIdle, + EInProgress, + EChunkSent, + EMessageSent, + EWaitingForResponse, + EWaitingForReport, + EMessageDone + }; + + /* Two-Phased constructor + * + */ + static CMSRPMessageHandler* NewL( MMSRPMessageObserver* aMessageObserver, + const TDesC8& aMessage ); + + static CMSRPMessageHandler* NewLC( MMSRPMessageObserver* aMessageObserver, + const TDesC8& aMessage ); + + static CMSRPMessageHandler* NewL( TMSRPMessageType aMessageType ); + + static CMSRPMessageHandler* NewLC( TMSRPMessageType aMessageType ); + + /** + * Destructor. + */ + ~CMSRPMessageHandler(); + + static TInt LinkOffset(); + TSglQueLink iLink; + +public: // From base classes + + // From MMSRPWriterObserver + TWriteStatus GetSendBufferL( TPtrC8& aData, TBool aInterrupt ); + + MMSRPWriterObserver::TMsgStatus WriteDoneL( TInt aStatus ); + + // From MMSRPMessageHandler + void AddHeaderL( TMsrpHeaderType aHeaderType, TPtrC8& aHeaderValue, + TPtrC8& aHeaderTypeAndValue ); + + void AddContentL( TPtrC8& aContent ); + + void SetTransactionId( TPtrC8& aTransactionId ); + + void SetStatusOfResponseL( TPtrC8& aStatusCode, TPtrC8& aStatusMessage ); + + void EndOfMessageL( TMsrpMsgEndStatus aStatus ); + + // From MMSRPIncomingMessage + TMSRPMessageType MessageType( ); + + CMSRPMessage* GetIncomingMessage( ); + + TBool SendResponseL( MMSRPMessageObserver* aMessageObserver, + MMSRPConnection& aConnection, TUint aResponseCode ); + + TDesC8& TransactionId( ); + + CMSRPResponse* GetIncomingResponse( ); + + // From MMSRPOutgoingMessage + void SendMessageL( MMSRPConnection& aConnection ); + + TBool IsOwnerOfResponse( MMSRPIncomingMessage& aIncomingMessage ); + + TBool ConsumeResponseL( MMSRPIncomingMessage& aIncomingMessage ); + + TBool IsMessageComplete(); + + TBool GetSendResultL( TUint &aErrorCode, HBufC8* &aMessageId ); + + void SendFileL( MMSRPConnection& aConnection ); + + void ConsumeFileResponseL( MMSRPIncomingMessage& aIncomingMessage ); + + + + TBool IsInFile(); + + void ReceiveFileL( ); + + TBool FileTransferComplete( ); + + void WritetoFileL(CMSRPMessageHandler *aIncomingMsgHandler ); + + void UpdateResponseStateL(CMSRPMessageHandler *incomingMsgHandler); + + TBool IfResponseReqL(); +private: + // Constructor + CMSRPMessageHandler( MMSRPMessageObserver* aMessageObserver ); + + CMSRPMessageHandler( ); + + void ConstructL( const TDesC8& aMessage ); + + void ConstructL( TMSRPMessageType aMessageType ); + + // Member Functions + void CreateByteRangeHeaderL(); + + void CreateTransactionId(); + + void WriteInitialLineToBufferL(); + + void WriteHeadersToBufferL(); + + void WriteContentToBuffer(); + + void WriteFileContentToBufferL(); + + void WriteEndLineToBuffer(TMsrpMsgEndStatus = EMessageEnd ); + + TInt ExtractByteRangeParams( TDesC8& aHeaderValue, TInt& aStartPos, + TInt& aEndPos, TInt& aTotal ); + + RStringF GetStatusStringL( TUint aStatusCode ); + + TUint CheckValidityOfMessage( TMSRPMessageType aMessageType, + CMSRPMessageBase* aMessage ); + + TInt FillFileBufferL(); + + void SendFileChunkL( MMSRPConnection& aConnection ); + + + + void SendFileStateL( TInt aBytes ); + + void ReceiveFileStateL( TInt aBytes ); + + void WriteChunkToFileL(const TDesC8& aFileChunk ,TDesC8& aTransactionId); +private: + + // Server interface + MMSRPMessageObserver* iMSRPMessageObserver; + + // Transaction Id + TBuf8< KMaxLengthOfTransactionIdString > iTransactionId; + + // MSRP Message + CMSRPMessage* iMessage; + + // MSRP response; + CMSRPResponse* iResponse; + + TBool iResponseNeeded; + + RBuf8 iBuffer; + + TPtrC8 iContentPtr; + + TBool iWriteDone; + + TMSRPMessageType iActiveMsgType; + + TMSRPMessageState iState; + + TMsrpMsgEndStatus iMsgEndStatus; + + /* For File Use Case */ + TBool isFile; + RFile iFile; + RFs iFs; + TInt iFileSize; + + TBool iInterrupt; + HBufC8* iFileBuffer; + TBool iFileTransferComplete; + RPointerArray iChunkList; + TInt iBufPosInFile; //file buffer start pos in file + TInt iEndPosInBuffer; + TInt iStartPosInBuffer; + TInt iFileBytesSent; + + TBool iProgress; + TInt iNotifiedBytes; + TInt iPendingBytes; + }; + +#endif /* CMSRPMESSAGEHANDLER_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/CMSRPMsgParser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/CMSRPMsgParser.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,97 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPMSGPARSER_H_ +#define CMSRPMSGPARSER_H_ + +#ifdef UT_TEST +#include "../../tsrc/conn_parser/inc/CMSRPMessageHandler.h" +#else +#include "CMSRPMessageHandler.h" +#endif + +#include "MMSRPParserObserver.h" +#include "MSRPBuffer.h" + +#define MSRP_COLON ':' +#define MSRP_SPACE ' ' +#define MSRP_CARRIAGE '\r' +#define MSRP_TERMINATE '#' +#define MSRP_CONTINUE '+' +#define MSRP_END '$' + +#define KMSRPIDLenMax 32 +#define KMSRPIDLenMin 4 +#define KMSRPEndTokenMax KMSRPIDLenMax+8+2 //init-crlf + +class CMSRPMsgParser: public CBase + { + friend class CMSRPParser; +public: + enum TParseState + { + EIdle = 0, + ETitleLine, + EToPath, + EFromPath, + //EMandatoryHeader, + EOptionalHeaders, + EBody, + EExtraCRLF, + EEndofEndLine + }; + + enum TMatchType + { + ENoMatch, + EFullMatch, + EPartialMatch + }; + + static CMSRPMsgParser* NewL(MMSRPParserObserver& aConnection); + virtual ~CMSRPMsgParser(); + + TBool ParseL(); + +private: + CMSRPMsgParser(MMSRPParserObserver& aConnection); + void ConstructL(); + + TBool HandleFullMatchL(TPtrC8& aToken, TInt aMatchPos, TBool aCopyToLocal = FALSE); + TBool HandlePartialMatchL(TPtrC8& aToken, TInt aCurBufMatchPos); + TBool HandleNoMatchL(TPtrC8& aToken, TInt aCurBufMatchPos); + + void HandleStateL(const TDesC8& aString, TInt aMatchPos); + void HandleTitleLineL(const TDesC8& aString, TInt aMatchPos); + void HandleHeaderL(const TDesC8& aString, TInt aMatchPos); + void HandleOptionalHeaderL(const TDesC8& aString, TInt aMatchPos); + void HandleBodyL(const TDesC8& aString, TInt aMatchPos); + void HandleXtraCrlfL(const TDesC8& aString, TInt aMatchPos); + void HandleEndofEndLineL(const TDesC8& aString, TInt aMatchPos); + + TMatchType FindToken(const TDesC8& aString, const TDesC8& aToken, TInt& aMatchPos); + + +private: + MMSRPParserObserver& iConnection; + RPointerArray iParseBuffers; + TParseState iState; + RMsrpBuf* iLocalBuf;//keep it above pool + CMSRPMessageHandler* iMessage; + CMSRPBufPool iBufPool; + HBufC8* iEndToken; + }; +#endif /* CMSRPMSGPARSER_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/CMSRPParser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/CMSRPParser.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPPARSER_H +#define CMSRPPARSER_H + +// INCLUDES +#include +#include +#include "MMSRPParser.h" +#include "MMSRPParserObserver.h" +#include "MSRPBuffer.h" +#include "CMSRPMsgParser.h" + +class MMSRPParserObserver; +// CLASS DECLARATIONS +/** + * The socket reader request interface. + */ + +class CMSRPParser : public CActive, public MMSRPParser + { + public: + + // Constructors and destructor + static MMSRPParser* NewL(MMSRPParserObserver& aConnection); + virtual ~CMSRPParser(); + + virtual void ParseL(RMsrpBuf& aBuf); + + protected: // from CActive + void DoCancel(); + void RunL(); + TInt RunError(TInt aError); + + private: + CMSRPParser(MMSRPParserObserver& aConnection); + void ConstructL(MMSRPParserObserver& aConnection); + + private: // data + MMSRPParserObserver& iConnection; + //RPointerArray iParseBuffers; + CMSRPMsgParser* iParser; + }; + + + +#endif // CMSRPPARSER_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/CMSRPReader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/CMSRPReader.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPREADER_H +#define CMSRPREADER_H + +// INCLUDES +#include +#include +#include "MMSRPReader.h" +#include "MMSRPReaderObserver.h" +#include "MSRPBuffer.h" + +class MMSRPReaderObserver; +// CLASS DECLARATIONS +/** + * The socket reader request interface. + */ + +class CMSRPReader : public CActive, public MMSRPReader + { + public: + + // Constructors and destructor + static MMSRPReader* NewL(RSocket& aSocket, MMSRPReaderObserver& aConnection); + virtual ~CMSRPReader(); + + virtual void StartReceivingL(RMsrpBuf aBuf); + + protected: // from CActive + void DoCancel(); + void RunL(); + TInt RunError(TInt aError); + + private: + CMSRPReader(RSocket& aSocket, MMSRPReaderObserver& aConnection); + void ConstructL(); + + private: // data + MMSRPReaderObserver& iConnection; + RSocket& iSocket; + TSockXfrLength iNumberOfBytesRead; + RMsrpBuf* iBuf; + }; + + + +#endif // CMSRPREADER_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/CMSRPScheduler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/CMSRPScheduler.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPSCHEDULER_H +#define CMSRPSCHEDULER_H + +// INCLUDE FILES +#include + +// FORWARD DECLARATIONS +class CMSRPServer; + +// CLASS DECLARATION + +/** +* MSRP Server includes a scheduler of it's own to simplify +* client request handling code. All active object leaves are +* handled in function Error(). The behaviour of Error() +* depends on whether there is an outstanding client request +* or not: it will tell the client the reason for inability +* to handle the client request. It will also panic the +* client if the descriptor passed to the server was malformed. +* Finally, a panic is raised if the error does not originate +* from the server itself. +*/ + +class CMSRPScheduler : public CActiveScheduler + { + public: // Constructors + + /** + * Default constructor + */ + CMSRPScheduler(); + + /** + * Gives a pointer of the current CMSRPServer instance + * to the scheduler. + * @param aServer The current server pointer + */ + void SetServer( CMSRPServer* aServer ); + + public: // from CActiveScheduler + + /** + * Overridden to handle leaves in request functions and + * unexpected situations. + * @param aError Error code, see EPOC system documentation. + */ + void Error( TInt aError ) const; + + private: // data + + // server instance + CMSRPServer* iServer; + }; + +#endif // CMSRPSCHEDULER_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/CMSRPServer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/CMSRPServer.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,152 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + + +#ifndef CMSRPSERVER_H +#define CMSRPSERVER_H + +// INCLUDES +#include + +#include "MsrpCommon.h" + +// FORWARD DECLARATIONS +class MMSRPConnectionManager; +class CMSRPConnectionManager; +class MMSRPConnection; +class CStateFactory; + +#include "MMSRPConnectionManagerObserver.h" + +// CLASS DECLARATION +/** +* Manages sessions +*/ +class CMSRPServer : public CPolicyServer, MMSRPConnectionManagerObserver + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CMSRPServer* NewLC(); + + /** + * Destructor. + */ + virtual ~CMSRPServer(); + + public: // New functions + + /** + * Access an instance of connection manager + */ + MMSRPConnectionManager& ConnectionManager() const; + CStateFactory& StateFactory() const; + + /** + * Session informs server when created + */ + void SessionCreated(); + + void CreatingSubSessionL( const TUint aIapID ); + + /** + * Session informs server when deleted. + */ + void SessionDeleted(); + + // From the MMSRPConnectionManagerObserver + + void HandleError(TInt aError, TInt aStatus, MMSRPConnection& aConnection); + + + private: // Functions from base classes + + /** + * From CServer2, creates a new server session. + * @param aVersion Client interface version. + * @param aMessage 'connect' message from the client. + * @return Pointer to the created server session. + */ + CSession2* NewSessionL( + const TVersion &aVersion, + const RMessage2& aMessage ) const; + + private: + + /** + * C++ default constructor. + */ + CMSRPServer(); + + /** + * private 2nd phase constructor + */ + void ConstructL(); + + private: // variables + + // pointer to connection manager instance, owned + CMSRPConnectionManager* iConnectionManager; + CStateFactory* iStateFactory; + + // Counter for session instance + TInt iSessionCount; + }; + +// ---------------------------------------------------------------------------------------- +// Server policy +// ---------------------------------------------------------------------------------------- + +// Total number of ranges +const TUint KTotalNumberOfRanges = 2; + +// Definition of the ranges of IPC numbers +const TInt MSRPServerRanges[ KTotalNumberOfRanges ] = + { + EMSRPCreateSubSession, + EMSRPReserved, + }; + +// Policy to implement for each of the above ranges +const TUint8 MSRPServerElementsIndex[ KTotalNumberOfRanges ] = + { + CPolicyServer::EAlwaysPass, // 0 + CPolicyServer::ENotSupported, // 1 + }; + +// Specific capability checks +// not used currently +const CPolicyServer::TPolicyElement MSRPServerElements[] = + { + //lint -e{1924} + {_INIT_SECURITY_POLICY_C1( ECapabilityReadDeviceData ), CPolicyServer::EFailClient} + }; + +// Package all the above together into a policy +const CPolicyServer::TPolicy MSRPServerPolicy = + { + CPolicyServer::EAlwaysPass, // all applications can access + KTotalNumberOfRanges, // number of ranges + MSRPServerRanges, // ranges array + MSRPServerElementsIndex, // elements<->ranges index + MSRPServerElements + }; + +#endif // CMSRPSERVER_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/CMSRPServerSession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/CMSRPServerSession.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPSERVERSESSION_H_ +#define CMSRPSERVERSESSION_H_ + +#include "E32base.h" + +// Forward declarations +class CMSRPServer; +class RMessage2; +class CMSRPServerSubSession; +class MMSRPConnectionManager; + + +// Class to handle multiple sub sessions + +class CMsrpHandleObj : public CBase + { +public: + static CMsrpHandleObj* NewL( CMSRPServerSubSession* aSubSession); + CMSRPServerSubSession* Subsession() const; + TUint Handle() const; + inline TBool Compare( TUint aHandle ) const; + virtual ~CMsrpHandleObj(); + +private: + void ConstructL(); + CMsrpHandleObj( CMSRPServerSubSession* aSubSession); + +public: + TSglQueLink iLink; + +private: + CMSRPServerSubSession* iSubSession; + TUint iHandle; + }; + + + +class CMSRPServerSession : public CSession2 + { +public: + static CMSRPServerSession* NewL( CMSRPServer& aServer ); + static CMSRPServerSession* NewLC( CMSRPServer& aServer ); + + ~CMSRPServerSession(); + void ServiceL( const RMessage2& aMessage ); + MMSRPConnectionManager& ConnectionManager(); + +private: + + void ConstructL(); + CMSRPServerSession( CMSRPServer& aServer ); + + void CreateSubSessionL( const RMessage2& aMessage ); + void CloseSubSessionL( const RMessage2& aMessage ); + void DispatchToSubSessionL( const RMessage2& aMessage ); + + // ITC Write functions. Must be moved out to a common location. + void WriteResponseL( const RMessage2& aMessage, + TServerClientResponses aResponseItem, + TInt aValue ); + + CMsrpHandleObj* CMSRPServerSession::FindHandle( TInt aHandle ); + +private: + CMSRPServer& iMSRPServer; + TSglQue iSubSessionList; + }; + +#endif /* CMSRPSERVERSESSION_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/CMSRPServerSubSession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/CMSRPServerSubSession.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,401 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPSERVERSUBSESSION_H_ +#define CMSRPSERVERSUBSESSION_H_ + +#include +#include +#include +#include + + +#include "MMSRPConnectionObserver.h" +#include "MMSRPMessageObserver.h" +#include "MSRPServerCommon.h" +#include "CMSRPMessageHandler.h" + +const TInt KMSRPSessIdLength=12; + +// Forward Declarations +class CMSRPServerSubSession; +class CMSRPServerSession; +class MMSRPConnectionManager; +class CMSRPMessageBase; +class MMSRPConnection; +class MMSRPIncomingMessage; +class CMSRPMessageHandler; +class CMSRPFromToHeaderBase; +class CMSRPToPathHeader; +class CMSRPHeaderBase; + +class TStateBase; +class CStateFactory; + + +class CRMessageContainer: public CBase +{ +public: + + CRMessageContainer(); + ~CRMessageContainer(); + TBool set(const RMessage2& aMessage); + + TInt CRMessageContainer::Write(TInt aParam,const TDesC8& aDes,TInt aOffset=0) const; + void ReadL(TInt aParam,TDes8& aDes,TInt aOffset=0) const; + + void Complete(TInt aReason); + + TBool Check(); + + TBool iStatus; + RMessage2 iMsg; + +}; + + +template +class CQueue : public CBase + { + public: + inline CQueue(); + virtual ~CQueue(){}; + inline TBool Queue(T& element); + inline T* DeQueue(); + inline TBool isEmpty(); + + inline T* getHead(); + + virtual inline T* getMatch(T* aMatch); + + TInt inline Length(){ + #ifdef _DEBUG + if(0 == iQLenght && !iList.IsEmpty()) + { + MSRPLOG("CQueue::Lenght!! Problem!! in the queue lenght calculations"); + } + #endif + return iQLenght; + + }; + + inline void CQueue::Destroy(); + + protected: + TInt iQLenght; + + TSglQue iList; + + }; + + +template +CQueue::CQueue(): iList(T::LinkOffset()),iQLenght(0){} + +template +TBool CQueue::Queue(T& element) + { + iList.AddLast(element); + iQLenght++; + return TRUE; + } + +template +T* CQueue::DeQueue() + { + T* element = NULL; + if(!(iList.IsEmpty())) + { + element = iList.First(); + iList.Remove(*element); + iQLenght--; + } + + return element; + } + +template +TBool CQueue::isEmpty() + { + return iList.IsEmpty(); + } + +template +T* CQueue::getHead() + { + T* element = NULL; + if(!(iList.IsEmpty())) + { + element = iList.First(); + } + return element; + } + +template +T* CQueue::getMatch(T* aMatch) + { + aMatch; + return NULL; + } + +template +inline void CQueue::Destroy() + { + T* element = NULL; + TSglQueIter iter(iList); + element = iter++; + + while(element) + { + iList.Remove(*element); + delete element; + element = iter++; + iQLenght--; + } + + } + +template +class CQueueMsgHandlers : public CQueue + { + public: + CQueueMsgHandlers(); + virtual ~CQueueMsgHandlers(){}; + virtual inline T* getMatch(T*); + + virtual inline TBool explicitRemove(T* aElementToRemove); + + }; + +template +CQueueMsgHandlers::CQueueMsgHandlers() : CQueue::CQueue(){} + +template +T* CQueueMsgHandlers::getMatch(T* aInCommingMsg) + { + // + + TSglQueIter iterator(CQueue::iList); + iterator.SetToFirst(); + T* iMatchingOwner; + + while((iMatchingOwner = iterator++)) + { + if(iMatchingOwner->IsOwnerOfResponse(*aInCommingMsg)) + { + return iMatchingOwner; + } + } + + return NULL; + } + +template +TBool CQueueMsgHandlers::explicitRemove(T* aElementToRemove) + { + CQueue::iList.Remove(*aElementToRemove); + CQueue::iQLenght--; + return TRUE; + + } + +class CMSRPServerSubSession : public CBase, MMSRPConnectionObserver, MMSRPMessageObserver + { +public: + + enum TQueueType + { + TClientQueue, + TInCommingMsgQueue + }; + + static CMSRPServerSubSession* NewL( CMSRPServerSession& aServerSession, CStateFactory& aStateFactory ); + + static CMSRPServerSubSession* NewLC( CMSRPServerSession& aServerSession, CStateFactory& aStateFactory ); + + virtual ~CMSRPServerSubSession( ); + + TBool ServiceL( const RMessage2& aMessage ); + + // From MMSRPConnectionObserver + void ConnectionStateL( TInt aNewState, TInt aStatus ); + + TBool MessageReceivedL( CMSRPMessageHandler* aMsg ); + + void UnclaimedMessageL( CMSRPMessageHandler* aMsg ); + + // From MMSRPMsgObserver + void MessageSendCompleteL(); + + void MessageResponseSendCompleteL(CMSRPMessageHandler& aMsg); + + virtual void MessageSendProgressL(TInt aBytesSent, TInt aTotalBytes); + + virtual void MessageReceiveProgressL(TInt aBytesSent, TInt aTotalBytes); + + void WriterError(); + + CMSRPMessageHandler* ReceiveFileMsgHandler(); + + void NotifyFileReceiveResultToClientL(CMSRPMessageHandler *msgHandler); + + void NotifyFileSendResultToClientL(CMSRPMessageHandler *msgHandler); + +private: + CMSRPServerSession& iServerSession; + CMSRPServerSubSession( CMSRPServerSession& aServerSession, CStateFactory &aStateFactory); + void ConstructL(); + + // ProcessEventL shall only take a event. The data associated with the event can be a + // RMessage(Client to Server events), CSendBuffer(buffer being send out by connection manager), + // CMSRPMessage(received message) or other such data. + // The associated data is stored in the context and retrieved by the relevant state when needed. + + TBool CMSRPServerSubSession::ProcessEventL( TMSRPFSMEvent aEvent); + + HBufC8* CreateSubSessionIDL( ); + + void HandleLocalPathRequestL( const RMessage2& aMessage ); + + void HandleConnectRequestL( const RMessage2& aMessage ); + + void HandleListenConnectionsL( const RMessage2& aMessage ); + void HandleListenMessagesL( const RMessage2& aMessage ); + void HandleListenSendResultL( const RMessage2& aMessage ); + + void HandleSendMessageL( const RMessage2& aMessage ); + + void HandleCancelSendingL( const RMessage2& aMessage ); + void HandleCancelReceivingL( const RMessage2& aMessage ); + void HandleCancelSendRespListening( const RMessage2& aMessage ); + + MMSRPConnectionManager& ConnectionManager( ); + + void CompleteClient(TInt aReason); + TInt Write(TInt aParam,const TDesC8& aDes); + + TBool QueueClientSendRequestsL(); + + TBool QueueSendMessages(CMSRPMessageHandler* aMessageHandlers); + CMSRPMessageHandler* DeQueueSentMessage(); + + TBool QueueReceivedMessages(); + + // Utility functions. + + TBool sendResultToClientL(CMSRPMessageHandler *incommingMsgHandler); + TBool sendMsgToClientL(CMSRPMessageHandler *incommingMsgHandler); + TBool SendProgressToClientL(CMSRPMessageHandler *msgHandler); + TBool ReceiveProgressToClientL(CMSRPMessageHandler *msgHandler); + + void ReadSendDataPckgL(); + + TBool listnerSetupComplete(); + + CMSRPServerSubSession::TQueueType getQToProcess(); + + TBool QueuesEmpty(); + TBool informConnectionReadyToClient(); + + void QueueLog(); + + TBool checkMessageForSelfL(CMSRPMessageHandler *aMsgHandler); + TBool matchSessionIDL(const CMSRPHeaderBase *aPathHeader, TBool local = TRUE); + TPtrC8 extractSessionID(const TDesC8& aPathBuffer); + + CStateFactory& StateFactory(); + +private: + + // Session Data. + HBufC8* iLocalSessionID; + HBufC8* iRemoteSessionID; + + // Connection info bundle. + TBuf8< KMaxLengthOfHost > iRemoteHost; + TUint iRemotePort; + TConnectionDirection iConnDirection; + + // Local Host info + TBuf< KMaxLengthOfHost > iLocalHost; + + MMSRPConnection* iConnection; + + // connect package from the client + TPckgBuf< TLocalPathMSRPData > iLocalPathMSRPDataPckg; + TPckgBuf< TConnectMSRPData > iConnectMSRPdataPckg; + + // listen package from the client + TPckgBuf< TListenMSRPData > iListenMSRPdataPckg; + + // send package to the client + TPckgBuf< TSendMSRPData > iSendMSRPdataPckg; + + // result of sent messages package to the client + TPckgBuf< TListenSendResultMSRPData > iSendResultListenMSRPDataPckg; + + // Temorary Event Data. + const RMessage2* iClientMessage; + CMSRPMessageHandler* iReceivedMsg; + CMSRPMessageHandler* iReceivedResp; + CMSRPMessageHandler* iReceiveFileMsgHdler; + TBool iFileShare; //is previous state file share + TBool iSendCompleteNotify; // + TBool iReceiveCompleteNotify; + TInt iBytesTransferred; + TInt iTotalBytes; + + // Client Listners waiting to be completed. + + // Listner for response of Connect request. + CRMessageContainer iConnectionListner; + // Listner for response of Listen request(iMessage set as false) and also + // listner for incomming messages(iMessage set as TRUE). + CRMessageContainer iIncommingMessageListner; + // Listner for Responses to sent messages. + CRMessageContainer iResponseListner; + + CStateFactory& iStateFactory; // Not owned. + TStateBase* iState; // Not owned. + + // The current message handler that is doing a MSRP Send and + // for which the subsession has still not rerceived a sendmessagecomplete event. + // Once the sendmessage completed is received the message handler is put on the + // OutGoingMessage queue where it waits for a response to arrive. + CMSRPMessageHandler *iCurrentMsgHandler; + + // Queues. + CQueueMsgHandlers iOutMsgQ; + CQueueMsgHandlers iInCommingMsgQ; + CQueueMsgHandlers iPendingSendMsgQ; + CQueueMsgHandlers iPendingForDeletionQ; + + friend class TStateBase; + friend class TStateIdle; + friend class TStateConnecting; + friend class TStateActive; + friend class TStateActiveSend; + friend class TStateWaitForClient; + friend class TStateFileShare; + friend class TStateError; // Not a very good thing !! Need change. + + #ifdef __UT_TSTATEFACTORY_H__ + friend class UT_TStateFactory; + #endif + + }; + +#endif /* CMSRPSERVERSUBSESSION_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/CMSRPTimeOutTimer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/CMSRPTimeOutTimer.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPTIMEOUTIMER_H +#define CMSRPTIMEOUTIMER_H + +// EXTERNAL INCLUDES +#include + +// CONSTANTS + + +// FORWARD DECLARATIONS +class MMSRPTimeOutObserver; + +// CLASS DECLARATIONS +/** +* Implements timeout timer. +*/ +class CMSRPTimeOutTimer: public CTimer + { + public: + + /** + * Static constructor + * @param aTimeOutNotify The reference to the timeout notifier. + * @return A new instance of CMSRPTimeOutTimer + */ + static CMSRPTimeOutTimer* NewL( MMSRPTimeOutObserver& aTimeOutNotify ); + + /** + * Destructor. + */ + ~CMSRPTimeOutTimer(); + + protected: + + /** + * C++ default constructor. + * @param aTimeOutNotify The reference to the timeout notifier. + */ + CMSRPTimeOutTimer( MMSRPTimeOutObserver& aTimeOutNotify ); + + /** + * Symbian 2nd phase constructor that might leave. + */ + void ConstructL( ); + + private: // From base classes + /** + * From CActive + */ + virtual void RunL(); + + private: // Member variables + + // The reference to the notifier + MMSRPTimeOutObserver& iNotifier; + }; + +#endif // CSIPEXTIMEOUTIMER_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/CMSRPWriter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/CMSRPWriter.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef CMSRPWRITER_H +#define CMSRPWRITER_H + +// INCLUDES +#include +#include +#include "MMSRPWriter.h" +#include "MMSRPWriterObserver.h" + + +class MMSRPWriterObserver; +class MMSRPWriterErrorObserver; + +// CLASS DECLARATIONS +/** + * The socket reader request interface. + */ + +class CMSRPWriter : public CActive, public MMSRPWriter + { + public: + + // Constructors and destructor + static MMSRPWriter* NewL(RSocket& aSocket, MMSRPWriterErrorObserver& aConnection ); + virtual ~CMSRPWriter(); + + virtual void RequestSendL(MMSRPWriterObserver& aMsg); + + protected: // from CActive + void DoCancel(); + void RunL(); + TInt RunError(TInt aError); + + private: + CMSRPWriter(RSocket& aSocket, MMSRPWriterErrorObserver& aConnection); + void ConstructL(); + void SendL(); + + private: // data + MMSRPWriterErrorObserver& iConnection; + RSocket& iSocket; + RPointerArray iSendQueue; + TBool iWriteIssued; + }; + +#endif // CMSRPWRITER_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPConnection.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPConnection.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,143 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef MMMSRPCONNECTION_H +#define MMMSRPCONNECTION_H + +// INCLUDES +#include +#include +#include "MMSRPConnectionManager.h" +#include "MMSRPConnectionObserver.h" +#include "MMSRPWriterObserver.h" + +// FORWARD DECLARATIONS +class MMSRPConnectionObserver; +class MMSRPWriterObserver; +class MMSRPConnectionManager; + +// CLASS DECLARATIONS + + + +class MMSRPConnection + { +public: + //move to CMSRPConn + enum TMSRPConnectionState + { + EError = -1, + ENotConnected = 0, + EConnecting, + EListening, + //EListenConnected, + EConnected, + EListenTimedOut, + EConnectTimedOut, + EDisconnecting, //cancel issued on connecting socket + EDisconnected//EConnectCancelling/ed + //EListenConnected (as opposed to connect connected)//validation to be taken care by session + //EListenValidated (received bodiless msg) //per session basis, hence these 2 states not needed + }; +// + inline virtual ~MMSRPConnection(){} + + /** + * Connect to remote address + */ + virtual TInt ConnectL(MMSRPConnectionObserver& aSubsession) = 0; + + /** + * Listen to remote address + * add observer and start listener, if not started + * if new conn object i.e. single observer conn then + * update listen count + */ + virtual TInt ListenL(MMSRPConnectionObserver& aSubsession) = 0; + + + virtual TInt getConnectionState()=0; + + + /** + * Cancel the connect request if pending, else disconnect subsession + */ + //virtual void ConnectCancel(MMSRPConnectionObserver& aSubsession) = 0; //state == not connected means error + //connecting : issue cancel connect on socket if only subsession pending + //if connected: disconnect if only subsession pending + //else listening, panic client + /** + * Cancel the listen request if pending, else disconnect subsession + */ + //virtual void ListenCancel(MMSRPConnectionObserver& aSubsession) = 0; + + /** + * The particular subsession wishes to cease using the connection/ disconnect + */ + virtual void ReleaseConnection(MMSRPConnectionObserver& aSubsession) = 0; + + + /** + * Sends the buffer content + * the observer cud be implemented by msg or subsession + * connection observer deemed unnecessary in send call + */ + virtual void SendL( MMSRPWriterObserver& aMsg ) = 0; + + + /** + * use case unknown : connection failure detected, parse error on the connection + * Send failed , goes directly to subsession. + * In that scenario, subession could ask mngr to close connection itself as part of error recovery + */ + /** + * mngr/server decides to close all subsessions on connection + */ + //virtual void CloseConnection() = 0; + + + /*move to CMSrpConn*/ + virtual TBool CheckConnection(TInetAddr& aRemoteAddr, TBool aOnlyListen) = 0; + + /** + * connection observer is available with every request + * NewL used to get a reference to connection mgr, + * call delete connection entry in conn mngr on disconnect + */ + //virtual MMSRPConnection* NewL( TInetAddr& aRemoteAddr, MMSRPConnectionManager& aConnMngr) = 0; + + /** + * called on listen complete by connection manager + */ + virtual void ConnectionEstablishedL( TInt aNewState, RSocket* aSocket, TInt aStatus ) = 0; + + + /** + * Cancel the send + */ + //Send called on subsession with message + //Send cancel should be called on message (subsession with message id) + //msg state modified to cancel next fetch of message by writer + //but if the writer is sending same msg currently and send abort is issued then socket will need to be + //shutdown with stopoutput and then restarted + //Things cud get complicated , support not really necessary + //virtual void SendCancel( MMSRPConnectionObserver& aSubsession, MsgPTr, TDesC8& aBuf ) = 0; + + }; + +#endif // MMMSRPCONNECTION_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPConnectionManager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPConnectionManager.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef __MMMSRPCONNECTIONMANAGER_H +#define __MMMSRPCONNECTIONMANAGER_H + +#include +#include + +/* + * subsession to ensure no connect call after listen + * or multiple connect/listen calls + * make call to connmngr only if iConn not null + * stop association of multiple connections with single session + * stop association of single session multiple times with varying conns + * stopping assocation of same session id twice or more with the same connection needs to be taken care by connmgr + * done automatically by subsession, 506 (session already in use) response scenario doesnot arise + */ +// FORWARD DECLARATIONS +class MMSRPConnection; + +// CLASS DECLARATIONS +class MMSRPConnectionManager + { + public: + inline virtual ~MMSRPConnectionManager(){} + + /** + * Get local ip address to form msrp path + * @out param aLocalAddress + */ + virtual void ResolveLocalIPAddressL( TInetAddr& aLocalAddr ) = 0; + + /** + * Connection request to a specified address + * @param aHost host address, direct ip address or host name + * @param + */ + + virtual MMSRPConnection& getConnectionL( TDesC8& aHost, TUint aPort ) = 0; + + //take care of case where listen completes before connect + //and connect completes before listen to same host + //virtual MMSRPConnection& ListenL( TDesC8& aHost, TUint aPort, MMSRPConnectionObserver& aSubsession ) = 0; + + /** + * Start listener if not running + * else call listen to increment listen count + */ + virtual void ListenL(MMSRPConnection* /*aConnection*/) = 0; + + /** + * issue listener cancel and remove connection + */ + virtual void ListenCancel(MMSRPConnection* aConnection) = 0; + + /** + * should we move to CMSRPConnectionManager, + * and keep a ref to the actual object in conn rather than access through interface class + */ + virtual void Remove(MMSRPConnection* aConnection) = 0; + + + /*to be moved to C class?*/ + + virtual RSocketServ& SocketServer() = 0; + + virtual RConnection& SocketServerConn() = 0 ; + + //virtual TBool MatchIapId(TUint32 aIapID); + + }; + +#endif // __MMMSRPCONNECTIONMANAGER_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPConnectionManagerObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPConnectionManagerObserver.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef __MMMSRPCONNECTIONMANAGEROBSERVER_H +#define __MMMSRPCONNECTIONMANAGEROBSERVER_H + +#include +#include +#include "MMSRPConnection.h" +#include "MMSRPConnectionObserver.h" + +class MMSRPConnection; +// CLASS DECLARATIONS +class MMSRPConnectionManagerObserver + { + + public: + + enum TMSRPConnManagerErrors + { + ESocketServerStartFailed = -110, + EInterfaceStartFailed, + ELocalAddressResolveFailed, + EAddressResolveError, + EListenerStartError, + EListenPortFailed + }; + + + /** + * Get local ip address to form msrp path + * @out param aLocalAddress + */ + //socket server, connection, listen port failure + virtual void HandleError(TInt aError, TInt aStatus, MMSRPConnection& aConnection) = 0; + + //if listener fails, change listen port and restart listener + + }; + +#endif // __MMMSRPCONNECTIONMANAGER_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPConnectionObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPConnectionObserver.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef MMMSRPCONNECTIONOBSERVER_H +#define MMMSRPCONNECTIONOBSERVER_H + +// INCLUDES +#include + +class CMSRPMessageHandler; + + +// CLASS DECLARATIONS +/** +* Interface for observing the connection +*/ +class MMSRPConnectionObserver + { + public: + + enum TMSRPConnErrors + { + EConnectionStateUnexpected = -150, + }; + + /** + * SocketState + * @param aNewState The new state of the connection + * connected, timed out, disconnected etc.., unknown or undefined + * @param aStatus system-wide error code + *///pass connection also + virtual void ConnectionStateL( TInt aNewState, TInt aStatus ) = 0; + + /** + * Message Received + * @return: if session id match return TRUE + * else return FALSE + */ + virtual TBool MessageReceivedL( CMSRPMessageHandler* aMsg ) = 0; + + virtual void UnclaimedMessageL( CMSRPMessageHandler* aMsg ) = 0; + + }; + +#endif // MMMSRPCONNECTIONOBSERVER_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPConnector.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPConnector.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef MMMSRPCONNECTOR_H +#define MMMSRPCONNECTOR_H + +#include +#include +#include "MMSRPConnectorObserver.h" + +// CLASS DECLARATIONS +/** +* Interface for connector requests +*/ +class MMSRPConnector + { + public: + inline virtual ~MMSRPConnector(){} + + virtual void Connect(TInetAddr& aRemoteAddr) = 0; + + virtual void ConnectComplete() = 0; + + //virtual void CancelConnect() = 0; + + //close connection + // virtual void Disconnect() = 0; + + }; + +#endif // MMMSRPCONNECTOR_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPConnectorObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPConnectorObserver.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef MMMSRPCONNECTOROBSERVER_H +#define MMMSRPCONNECTOROBSERVER_H + +#include +#include + +// CLASS DECLARATIONS +/** +* Interface for notifing connector events +*/ +class MMSRPConnectorObserver + { + public: + + virtual void ConnectionEstablishedL( TInt aNewState, RSocket* aDataSocket, TInt aStatus ) = 0; + + }; + +#endif // MMMSRPCONNECTOROBSERVER_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPIncomingMessage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPIncomingMessage.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef MMSRPINCOMINGMESSAGE_H_ +#define MMSRPINCOMINGMESSAGE_H_ + + +// INCLUDES + +// FORWARD DECLARATIONS +class MMSRPMessageObserver; +class CMSRPMessage; +class CMSRPResponse; +class MMSRPConnection; + + +// CLASS DECLARATIONS + +/* MSRP Incoming message request interface with the subsession + * + */ +class MMSRPIncomingMessage + { +public: + + enum TMSRPMessageType + { + EMSRPNotDefined, + EMSRPMessage, + EMSRPReport, + EMSRPResponse + }; + + virtual TMSRPMessageType MessageType( ) = 0; + + virtual CMSRPMessage* GetIncomingMessage( ) = 0; + + virtual TBool SendResponseL( MMSRPMessageObserver* aMessageObserver, + MMSRPConnection& aConnection, TUint aResponseCode )=0; + + + virtual TDesC8& TransactionId( ) = 0; + + virtual CMSRPResponse* GetIncomingResponse( ) = 0; + + }; + +#endif /* MMSRPINCOMINGMESSAGE_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPListener.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPListener.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef MMSRPLISTENER_H_ +#define MMSRPLISTENER_H_ + +// INCLUDES +#include + +class MMSRPListener + { + public: + + enum TListenerState + { + ENotListening, + EAccepting, + ENotAccepting, + EListenAccepted, + ETimedOut, + EListenPortError, + ETerminate + }; + + + inline virtual ~MMSRPListener(){} + /** + * Listen() call, increment listen count if already listening + */ + virtual void ListenL() = 0; + + /** + * Cancel Listen, do not issue an actual cancel accept, + * decrement listen count and delete listener if count zero + */ + virtual void ListenCancel() = 0; + + + virtual void ListenCompletedL(TBool aValid) = 0; + + /** + * cleanup or reset + */ + //virtual void StopListening() = 0; + + + /** + * as part of destruction, no client interface + */ + //virtual void CancelAccept() = 0; + + }; + + +#endif /* MMSRPLISTENER_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPListenerObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPListenerObserver.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef MMSRPLISTENEROBSERVER_H_ +#define MMSRPLISTENEROBSERVER_H_ + +// INCLUDES +#include +#include + + +class MMSRPListenerObserver + { + public: + + virtual void ListenerStateL( TInt aNewState, RSocket* aDataSocket, TInt aStatus ) = 0; + + }; + + +#endif /* MMSRPLISTENEROBSERVER_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPMessageHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPMessageHandler.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef MMSRPMESSAGEHANDLER_H_ +#define MMSRPMESSAGEHANDLER_H_ + +// INCLUDES + + +// CLASS DECLARATIONS + +/* MSRP Message request interface + * + */ +class MMSRPMessageHandler + { +public: + + enum TMsrpHeaderType + { + EHeaderUnknown = -1, + EToPath, + EFromPath, + EMessageId, + ESuccessReport, + EFailureReport, + EByteRange, + EContentType, + EStatus, + EExtenstion + }; + + enum TMsrpMsgEndStatus + { + EMessageEnd, // $ + EMessageContinues, // + + EMessageTerminated // # + }; + + inline virtual ~MMSRPMessageHandler(){} + + virtual void AddHeaderL( TMsrpHeaderType aHeaderType, TPtrC8& aHeaderValue, TPtrC8& aHeaderTypeAndValue ) = 0; + + virtual void AddContentL( TPtrC8& aContent ) = 0; + + virtual void SetTransactionId( TPtrC8& aTransactionId ) = 0; + + virtual void SetStatusOfResponseL( TPtrC8& aStatusCode, TPtrC8& aStatusMessage ) = 0; + + virtual void EndOfMessageL( TMsrpMsgEndStatus aStatus ) = 0; + + }; + +#endif /* MMSRPMESSAGEHANDLER_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPMessageObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPMessageObserver.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef MMSRPMESSAGEOBSERVER_H_ +#define MMSRPMESSAGEOBSERVER_H_ + +class CMSRPMessageHandler; + +class MMSRPMessageObserver + { +protected: + ~MMSRPMessageObserver(){}; + + // Interface via which the Message informs events to its observer (a server sub session). + +public: + + virtual void MessageSendCompleteL( ) = 0; + + virtual void MessageResponseSendCompleteL( CMSRPMessageHandler& aMsg ) = 0; + + virtual void MessageSendProgressL(TInt aBytesSent, TInt aTotalBytes) = 0; + + virtual void MessageReceiveProgressL(TInt aBytesSent, TInt aTotalBytes) = 0; + + virtual void WriterError( ) = 0; + + }; + +#endif /* MMSRPMSGOBSERVER_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPOutgoingMessage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPOutgoingMessage.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef MMSRPOUTGOINGMESSAGE_H_ +#define MMSRPOUTGOINGMESSAGE_H_ + + +// INCLUDES + +// FORWARD DECLARATIONS + +class MMSRPIncomingMessage; + +// CLASS DECLARATIONS + +/* MSRP Outgoing message request interface with the subsession + * + */ +class MMSRPOutgoingMessage + { +public: + + virtual void SendMessageL( MMSRPConnection& aConnection ) = 0; + + virtual TBool IsOwnerOfResponse( MMSRPIncomingMessage& aIncomingMessage ) = 0; + + virtual TBool ConsumeResponseL( MMSRPIncomingMessage& aIncomingMessage ) = 0; + + virtual TBool IsMessageComplete() = 0; + + virtual TBool GetSendResultL( TUint &aErrorCode, HBufC8* &aMessageId ) = 0; + + }; +#endif /* MMSRPOUTGOINGMESSAGE_H_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPParser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPParser.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef __MMMSRPPARSER_H +#define __MMMSRPPARSER_H + +// INCLUDES +#include +#include "MMSRPParserObserver.h" +#include "MsrpBuffer.h" + +// CLASS DECLARATIONS +/** +* The socket reader request interface. +*/ +class MMSRPParser + { + public: + + inline virtual ~MMSRPParser(){} + + /** + * Set a variable, to stop parser self completing + */ + //virtual void StopParser() = 0; + + /** + * DataReceived triggers start, idles on no msgs + */ + virtual void ParseL(RMsrpBuf& aBuf) = 0; + + }; + +#endif // __MMMSRPPARSER_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPParserObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPParserObserver.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef __MMMSRPPARSEROBSERVER_H +#define __MMMSRPPARSEROBSERVER_H + +// INCLUDES +#include + +/** + * ideally msg received shud directly go to msrp session mngr(subsession mngr) + * msgs unclaimed by any session shud be handled by thesession mngr + * xpected dummy subsession to handle or send responses to unclaimed msgs + */ + +class CMSRPMessageHandler; + + +// CLASS DECLARATIONS +/** +* The parser event interface +*/ +class MMSRPParserObserver + { + public: + + /** + * Message, Report, Response + * MessageReceived + * @return true if consumed + */ + virtual void ParseStatusL (CMSRPMessageHandler* aMsg, TInt aStatus) = 0; + + /** + * Parse error: Handle similar to connection error now + * Try to recover from parse errors, using byte-range etc. later + */ + //virtual void ParseResult (TInt aStatus, CMessage* aMsg) = 0; + //virtual void ParseError () = 0; + + /** + * Part of large chunk + * Same as message received, msg internal state incomplete + * msg co-owned by parser and subsession, parsing continues after transfer to msrp session + * the content ptrs can be completed and closed (Removing them from msg' content_ptrs_list) and thus freeing content buffers for reuse if needed + */ + + }; + +#endif // __MMMSRPPARSEROBSERVER_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPReader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPReader.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef __MMMSRPREADER_H +#define __MMMSRPREADER_H + +// INCLUDES +//#include "MMSRPReaderObserver.h" +#include "MSRPBuffer.h" + +// CLASS DECLARATIONS + +/** + * The socket reader request interface. + */ +class MMSRPReader + { + public: + + inline virtual ~MMSRPReader(){} + + /** + * issue socket recv and set reader active + */ + virtual void StartReceivingL(RMsrpBuf aBuf) = 0; + + /** + * Cancel receive + */ + //virtual void CancelReceiving() = 0; + + }; + +#endif // __MMMSRPREADER_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPReaderObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPReaderObserver.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef __MMMSRPREADEROBSERVER_H +#define __MMMSRPREADEROBSERVER_H + +// INCLUDES +#include "MSRPBuffer.h" + + +// CLASS DECLARATIONS + +/** + * Subsession unknown,has to be identified after parsing + * Hence the observer split as in writer not seen + * Buf passed to parser thru connection rather than directly + * For direct passing to parser, split observers + */ + +/** +* The socket reader notifier interface. +* Notifies about events in reader. +* +*/ + + +class MMSRPReaderObserver + { + public: + + /** + * Called when the message has been read from the socket or on error + * @return processing status + */ + + virtual void ReadStatusL(RMsrpBuf& aBuf, TInt aStatus) = 0; + + }; + +#endif // __MMMSRPREADEROBSERVER_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPTimeOutObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPTimeOutObserver.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef MMMSRPTIMEOUTOBSERVER_H +#define MMMSRPTIMEOUTOBSERVER_H + +// CLASS DECLARATIONS +/** +* Interface for notifing timer's timeout. +*/ +class MMSRPTimeOutObserver + { + public: + virtual void TimerExpiredL() = 0; + }; + +#endif // MMMSRPTimeOutObserver_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPWriter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPWriter.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef __MMMSRPWRITER_H +#define __MMMSRPWRITER_H + +#include +#include +#include "MMSRPWriterObserver.h" + +// CLASS DECLARATIONS +/** +* writer request Interface +*/ +class MMSRPWriter + { + public: + inline virtual ~MMSRPWriter(){} + /** + * register for send service + * also triggers writer start, inactive on nothing to send + */ + virtual void RequestSendL(MMSRPWriterObserver& aMsg) = 0; + + /** + * Cancel current send, socket state to be verified + */ + //virtual void CancelWrite() = 0; //not supported, only cancel message supported, i.e. chunk abort + + /** + * Stops the writer from sending data + */ + //virtual void Stop() = 0; + //virtual void Start() = 0; + + /** + * Stops sending and discards all pending data + */ + //virtual void Flush() = 0; + + }; +#endif // __MMMSRPWRITER_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MMSRPWriterObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MMSRPWriterObserver.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef __MMMSRPWRITEROBSERVER_H +#define __MMMSRPWRITEROBSERVER_H + +// CLASS DECLARATIONS +/** +* Interface for notifying about socket writer events +*/ +class MMSRPWriterObserver + { + public: + + enum TWriteStatus + { + EMsrpSocketWrite = 0,//EComplete, EInterrupted, EPending_bufferfull + EMsrpAvoidSocketWrite, //EPending_buffernotfull + }; + + enum TMsgStatus + { + EUndefined = 0, + EPending, //Sending incomplete. Same observer is called again immediately + EComplete, //No more to send. A new observer is called, this is removed + EInterrupted //There is more to send. Same observer called later + }; + + /** + * Called by writer to fetch the content to send + * @param aData Output param, Points to data to be sent + * @param aInterrupt Signals whether other msgs are queued waiting to be sent + * @return KErrNone or system wide eror codes + */ + virtual TWriteStatus GetSendBufferL( TPtrC8& aData, TBool aInterrupt ) = 0; + + /** + * Called when the message has been written to the socket + * @param aSendstatus status of the write operation, communicates prev send result + * @return Indicates which observer has to be called the next time + */ + virtual TMsgStatus WriteDoneL(TInt aStatus ) = 0; + }; + + +class MMSRPWriterErrorObserver + { + public: + + /** + * socket errors detected on write arent msg specific + * Hence the observer has been separated + * The observer is expected to be implemented in connection and handled as a connection error + */ + + virtual void WriteSocketError(TInt aError) = 0; + }; + + + +#endif // __MMMSRPWRITEROBSERVER_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MSRPBuffer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MSRPBuffer.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,327 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef __MMSRPBUFFER_H +#define __MMSRPBUFFER_H + +// INCLUDES +#include +#include "MsrpCommon.h" + +// CLASS DECLARATIONS +class RMsrpBuf; +class CMSRPBuffer; +class CMSRPBufPool; +/** + * pool of buffers + */ + + +class CMSRPBufPool : public CBase + { + friend class CMSRPBuffer; +public: + inline RMsrpBuf ProvideBufferL(TInt aSize = KBufSize); + //inline RMsrpBuf ProvideBufferL(TInt aSize); + + //InitializePool; //dummy + //void ReleasePool(); //force free all buffers + inline virtual ~CMSRPBufPool(); + +private: + inline void TakeBackBufferL(CMSRPBuffer* aBuffer); //append to pool + +private: + RPointerArray iFreeBufPool; //free buf pool + RPointerArray iUsedBufPool; //free buf pool + }; + + +/** +* The buffer class +*/ +class CMSRPBuffer : public CBase + { + +friend class RMsrpBuf; + + public: + inline static CMSRPBuffer* NewL(TInt aSize, CMSRPBufPool& aPool ); + inline virtual ~CMSRPBuffer(); + + private: + inline void ConstructL(TInt aSize); + inline CMSRPBuffer(CMSRPBufPool& aPool); + TPtr8 MsrpDes(TInt aOffset); + TPtr8 MsrpDes(); + + inline void IncRef(void); + inline void DecRef(void); + + private: + TUint iRef; + HBufC8* iBuf; + CMSRPBufPool& iBufPool; + + }; + +class RMsrpBuf + { + public: + + inline RMsrpBuf(CMSRPBuffer& aBuf); + + inline RMsrpBuf(RMsrpBuf& aClone, TPtr8 aPtr); + + //get a R ref on the C class using the R class //MidTPtr + inline RMsrpBuf(const RMsrpBuf& aCopy); + + //makes the rmsrpbuf point to the remaining buffer after the length + TInt MsrpRightExtract(); + + //if same pool then append to our Rmsrpbuf and return true + //no continuity check, not required as of now + inline TBool Collate(RMsrpBuf& aSuffix); + + inline void MsrpRightTPtr(TInt length); + + inline void MsrpLeftTPtr(TInt length); + + inline void MsrpMidTPtr(TInt offset); + + inline void MsrpMidTPtr(TInt offset, TInt length); + + inline void Zero(); + + inline void Append(TDesC8& aDes); + + + /*implicit TPtr conv, temp only*/ + inline operator TPtr8() const; + + inline operator TPtr8&(); + + /** + * if TPtrs are passed to and stored in some class obj + * then the passer must call close on rbuf after the obj has cleaned up itself or + * released the reference + */ + inline TPtr8 Ptr(); + + inline virtual ~RMsrpBuf(); + + private: + //assignment + RMsrpBuf& operator=(const RMsrpBuf&); + + private: + CMSRPBuffer& iBuf; + TPtr8 iPtr; + }; + + + + inline RMsrpBuf CMSRPBufPool::ProvideBufferL(TInt aSize) //remove head element of pool or allocate and provide + { + CMSRPBuffer* buf = NULL; + if (iFreeBufPool.Count()) + { + buf = iFreeBufPool[0]; + iFreeBufPool.Remove(0); + } + else + { + buf = CMSRPBuffer::NewL(aSize, *this); + } + CleanupStack::PushL(buf); + iUsedBufPool.AppendL(buf); + CleanupStack::Pop(); + RMsrpBuf ptr(*buf); + return ptr; + } + + inline CMSRPBufPool::~CMSRPBufPool() + { + iFreeBufPool.ResetAndDestroy(); + iFreeBufPool.Close(); + iUsedBufPool.ResetAndDestroy(); + iUsedBufPool.Close(); + } + + inline void CMSRPBufPool::TakeBackBufferL(CMSRPBuffer* aBuffer) //append to pool + { + TInt index = iUsedBufPool.Find(aBuffer); + iUsedBufPool.Remove(index); + CleanupStack::PushL(aBuffer); + iFreeBufPool.AppendL(aBuffer); + CleanupStack::Pop(aBuffer); + } + + +/** +* The buffer class +*/ + inline CMSRPBuffer* CMSRPBuffer::NewL(TInt aSize, CMSRPBufPool& aPool ) + { + CMSRPBuffer* self = new (ELeave) CMSRPBuffer(aPool ); + CleanupStack::PushL(self); + self->ConstructL(aSize); + CleanupStack::Pop(self); + return self; + } + + inline CMSRPBuffer::CMSRPBuffer(CMSRPBufPool& aPool ): iBufPool(aPool) + { + + } + + inline void CMSRPBuffer::ConstructL(TInt aSize) + { + iBuf = HBufC8::NewL(aSize); + } + + inline CMSRPBuffer::~CMSRPBuffer() + { + delete iBuf; + } + + inline TPtr8 CMSRPBuffer::MsrpDes(TInt aOffset) //MsrpRef + { + TPtr8 mPtr(iBuf->Des()); + mPtr.Set(mPtr.MidTPtr(aOffset)); + return mPtr; + } + + inline TPtr8 CMSRPBuffer::MsrpDes() //MsrpRef + { + return iBuf->Des(); + } + + inline void CMSRPBuffer::IncRef(void) + { + iRef++; + } + inline void CMSRPBuffer::DecRef(void) + { + iRef--; + if (iRef == 0) + iBufPool.TakeBackBufferL(this); + //delete this; + } + + + inline RMsrpBuf::RMsrpBuf(CMSRPBuffer& aBuf):iBuf(aBuf), iPtr(aBuf.MsrpDes()) + { + iBuf.IncRef(); + } + + inline RMsrpBuf::RMsrpBuf(RMsrpBuf& aClone, TPtr8 aPtr):iBuf(aClone.iBuf), iPtr(aPtr) + { + //check TPtr belongs to buf + //if(iBuf.IsInBuf(aPtr))//DEBUG + iBuf.IncRef(); + //iPtr = aPtr; + } + //get a R ref on the C class using the R class //MidTPtr + inline RMsrpBuf::RMsrpBuf(const RMsrpBuf& aCopy):iBuf(aCopy.iBuf), iPtr(aCopy.iPtr) + { + iBuf.IncRef(); + } + + inline TInt RMsrpBuf::MsrpRightExtract() + { + TInt length = iPtr.Length(); + iPtr.SetMax(); + iPtr.Set(iPtr.MidTPtr(length)); + iPtr.Zero(); + return iPtr.MaxLength(); + } + + inline TBool RMsrpBuf::Collate(RMsrpBuf& aSuffix) + { + if (&aSuffix.iBuf != &iBuf) + return FALSE; + + iPtr.SetLength(iPtr.Length() + aSuffix.iPtr.Length()); + return TRUE; + } + + inline void RMsrpBuf::MsrpRightTPtr(TInt length) + { + iPtr.Set(iPtr.RightTPtr(length)); + } + + inline void RMsrpBuf::MsrpLeftTPtr(TInt length) + { + iPtr.Set(iPtr.LeftTPtr(length)); + } + + inline void RMsrpBuf::MsrpMidTPtr(TInt offset) + { + TInt length = iPtr.Length(); + iPtr.SetMax(); + iPtr.Set(iPtr.MidTPtr(offset)); + iPtr.SetLength(length - offset); + } + + inline void RMsrpBuf::MsrpMidTPtr(TInt offset, TInt length) + { + iPtr.Set(iPtr.MidTPtr(offset, length)); + } + + inline void RMsrpBuf::Zero() + { + iPtr.Zero(); + } + + inline void RMsrpBuf::Append(TDesC8& aDes) + { + iPtr.Append(aDes); + } + + /*implicit TPtr conv, temp only*/ + inline RMsrpBuf::operator TPtr8() const + { + return iPtr; + } + + inline RMsrpBuf::operator TPtr8&() + { + return iPtr; + } + + /** + * if TPtrs are passed to and stored in some class obj + * then the passer must call close on rbuf after the obj has cleaned up itself or + * released the reference + */ + inline TPtr8 RMsrpBuf::Ptr() + { + return iPtr; + } + + inline RMsrpBuf::~RMsrpBuf() + //inline void Close() + { + iBuf.DecRef(); + iPtr.Zero(); + //iBuf = 0; + } + + +#endif // __MMSRPBUFFER_H + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/MSRPServerCommon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/MSRPServerCommon.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,97 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef __MSRPSERVERCOMMON_H +#define __MSRPSERVERCOMMON_H + +#include +#include // For RDebug + +// CONSTANTS + +// ENUMS +enum TMSRPPanicCodes + { + EMSRPServerStartError, + EMSRPServerBadRequestError, + EMSRPServerBadDescriptorError, + EMSRPServerNotSupportedError, + EMSRPServerSchedulerError, + EMSRPServerNullPointer + }; + +// used in CMSRPListeners/CMSRPConnection +enum TMSRPChunkProcessingStatus + { + EMSRPMessageNotConsumed, + EMSRPMessageConsumed, + EMSRPMessageConsumedAndCompleted, + EMSRPFinalMessageProcessed, + EMSRPMessageError + }; + +// FUNCTION PROTOTYPES +void PanicServer( TMSRPPanicCodes aPanicCode ); + +// Terminology for now. +enum TConnectionDirection { + + EDownstream, // downstream is implies "connect" and the othe end listens. + EUpstream // upstream implies "listen" and the other end connects. + + }; + +// Connection state for users of the connection. If the connection usable or not. +enum TConnectionState + { + Usable, + NoUsable + }; + +// Sub Session FSM Events +enum TMSRPFSMEvent +{ + // Events generated from as a result of client requests. + ELocalMSRPPathEvent=0, // 0 + EMSRPConnectEvent, // 1 + EMSRPListenEvent, // 2 Maps to EMSRPListenConnections. + EMSRPListenMessagesEvent, // 3 + EMSRPListenSendResultEvent, // 4 Client Setup event to setup listner for incomming results. + EMSRPDataSendMessageEvent, // 5 Client Event to send data. + EMSRPSendFileEvent, // 6 + EMSRPReceiveFileEvent, // 7 + EMSRPDataSendMessageCancelEvent, // 8 + + // Should be CancelClientSetup1, 2 and 3 respectively. + EMSRPCancelReceivingEvent, // 9 Maps to EMSRPCancelReceiving. What is EMSRPCancelReceiving for? !! + EMSRPCancelSendRespListeningEvent, // 10 Maps to EMSRPCancelSendRespListening. What is EMSRPCancelSendRespListening for? !! + + // Events generated from the Message Layer. + EMSRPDataSendCompleteEvent, // 11 + EMSRPResponseSendCompleteEvent, // 12 + + + // From Connection Layer + EMSRPIncomingMessageReceivedEvent, // 13 + EConnectionStateChangedEvent, // 14 + EUncalimedMessageReceivedEvent, // 15 + + EMSRPSendProgressEvent, + EMSRPReceiveProgressEvent +}; +#endif // __MSRPSERVERCOMMON_H + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/TMSRPUtil.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/TMSRPUtil.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef __TMSRPUTIL_H__ +#define __TMSRPUTIL_H__ + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class CMSRPToPathHeader; + +// CLASS DEFINITION +/** + * Static utility class, used by MSRP Client + */ +class TMSRPUtil + { + +public: + + /** + * Convert given string to a number, leaves if string cannot be converted + * @param aString string to be converted + * @return string converted to number + */ + static TInt ConvertToNumber( const TDesC8& aString ); + + /** + * Extract session-id from To-Path or From-path value field + * @param aValueField from-path or to-path value field + * @return buffer containing the session-id, ownership is transferred + */ + static HBufC8* ExtractSessionIdFromPathLC( TDesC8& aValueField ); + }; + +#endif // __TMSRPUTIL_H__ + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/TStateFactory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/TStateFactory.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef TSTATEFACTORY_H_ +#define TSTATEFACTORY_H_ + +#include "TStates.h" + +class CStateFactory : public CBase + { + public: + static CStateFactory* NewL(); + static CStateFactory* NewLC(); + + ~CStateFactory(); + + TStateBase* getStateL(TStates state); + + private: + CStateFactory(); + void ConstructL(); + + private: + RPointerArray iStateArray; + + #ifdef __UT_TSTATEFACTORY_H__ + friend class UT_TStateFactory; + #endif + }; + + +#endif /* TSTATEFACTORY_HPP_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/inc/TStates.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/inc/TStates.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,159 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef TSTATES_H_ +#define TSTATES_H_ + +#include "MSRPServerCommon.h" + +class TStateBase; +class CMSRPServerSubSession; +class CMSRPMessageHandler; + +enum TStates +{ + EIdle = 0, + EConnecting, + EWaitForClient, + EActive, + EActiveSend, + EFileShare, + EError, + EEndLine +}; + + +class TStateBase +{ +public: + virtual TStateBase* EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext)=0; + virtual TStateBase* HandleStateErrorL(CMSRPServerSubSession *aContext); + virtual TStateBase * processIncommingMessageL(CMSRPServerSubSession *aContext, CMSRPMessageHandler* incommingMsg = NULL); + TStateBase * processPendingMessageQL( CMSRPServerSubSession *aContext ); + virtual TStateBase * handlesResponseL(CMSRPServerSubSession *aContext, + CMSRPMessageHandler *incommingMsgHandler); + + virtual TStateBase* handleRequestsL(CMSRPServerSubSession *aContext, + CMSRPMessageHandler *incommingMsgHandler); + + TStateBase* handleClientListnerCancelL(CMSRPServerSubSession * aContext, + TMSRPFSMEvent aEvent); + TStateBase* handleConnectionStateChangedL(CMSRPServerSubSession *aContext); + TStateBase* handleQueuesL(CMSRPServerSubSession *aContext); + TStateBase* handleConnectionErrorsL(CMSRPServerSubSession *aContext); + virtual TStates identity()=0; + TStateBase* handleInCommingMessagesL(CMSRPServerSubSession *aContext); + TStateBase* handleSendFileL(CMSRPServerSubSession *aContext); + TStateBase* handleReceiveFileL(CMSRPServerSubSession *aContext); +}; + + +class TStateIdle : public TStateBase +{ +public: + TStateBase* EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext); + TStates identity(); + +private: + TStateBase* handleLocalMSRPPathRequestL( CMSRPServerSubSession *aContext); + TStateBase* handleConnectRequestL(CMSRPServerSubSession *aContext); + TStateBase* handleListenRequestL(CMSRPServerSubSession *aContext); + + TBool initializeConnectionL(CMSRPServerSubSession *aContext); + +}; + + +class TStateConnecting : public TStateBase +{ +public: + TStateBase* EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext); + TStates identity(); + +}; + + +class TStateWaitForClient : public TStateBase +{ +public: + TStateBase* EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext); + TStates identity(); + +private: + TStateBase* fileSendCompleteL(CMSRPServerSubSession *aContext); + TStateBase * handleResponseSentL( CMSRPServerSubSession *aContext); + +}; + + +class TStateActive : public TStateBase +{ +public: + TStateBase* EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext); + TStates identity(); + +private: + TStateBase* handleSendDataL(CMSRPServerSubSession *aContext); + +}; + + +class TStateFileShare : public TStateBase +{ +public: + TStateBase* EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext); + TStates identity(); + +private: + TStateBase * processIncommingMessageL(CMSRPServerSubSession *aContext, CMSRPMessageHandler* incommingMsg = NULL); + + TStateBase* fileSendCompleteL(CMSRPServerSubSession *aContext); + TStateBase * handlesResponseL(CMSRPServerSubSession *aContext, + CMSRPMessageHandler *incommingMsgHandler); + + TStateBase* handleRequestsL(CMSRPServerSubSession *aContext, + CMSRPMessageHandler *incommingMsgHandler); + TStateBase * handleResponseSentL( CMSRPServerSubSession *aContext); + + TStateBase * handleSendProgressL( CMSRPServerSubSession *aContext); + + TStateBase * handleReceiveProgressL( CMSRPServerSubSession *aContext); + +}; + + +class TStateActiveSend : public TStateBase +{ +public: + TStateBase* EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext); + TStates identity(); + +private: + TStateBase * MessageSendCompleteL(CMSRPServerSubSession *aContext); + +}; + + +class TStateError : public TStateBase +{ +public: + TStateBase* EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext); + TStates identity(); + +}; + + +#endif /* TSTATES_HPP_ */ diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/CMSRPConnListener.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/CMSRPConnListener.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,276 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#include "CMSRPConnListener.h" +#include "MSRPCommon.h" +// ----------------------------------------------------------------------------- +// CMSRPConnListener::NewL +// Static constructor +// ----------------------------------------------------------------------------- +// + +/*static*/ MMSRPListener* CMSRPConnListener::NewL(CMSRPConnectionManager& aConnMngr) + { + MSRPLOG( "CMSRPConnListener::NewL enter" ) + CMSRPConnListener* self = new (ELeave) CMSRPConnListener( aConnMngr ); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + MSRPLOG( "CMSRPConnListener::NewL exit" ) + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPConnListener::CMSRPConnListener +// Constructor +// ----------------------------------------------------------------------------- +// +CMSRPConnListener::CMSRPConnListener(CMSRPConnectionManager& aConnMngr ) + : CActive(CActive::EPriorityStandard), + iConnMngr( aConnMngr ) + { + CActiveScheduler::Add(this); + } + +// ----------------------------------------------------------------------------- +// CMSRPConnListener::~CMSRPConnListener +// Destructor +// ----------------------------------------------------------------------------- +// +CMSRPConnListener::~CMSRPConnListener() + { + MSRPLOG( "CMSRPConnListener::~CMSRPConnListener enter" ) + delete iTimer; + Cancel(); + iListenSocket.Close(); +/* if(iDataSocket) + { + iDataSocket->Close(); + delete iDataSocket; + iDataSocket = NULL; + }*/ + MSRPLOG( "CMSRPConnListener::~CMSRPConnListener exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPConnListener::ConstructL +// 2nd phase constructor +// ----------------------------------------------------------------------------- +// +void CMSRPConnListener::ConstructL() + { + iState = ENotListening; + iTimer = CMSRPTimeOutTimer::NewL( *this ); + } + +// ----------------------------------------------------------------------------- +// CMSRPConnListener::DoCancel +// Cancels outstanding request. +// ----------------------------------------------------------------------------- +// +void CMSRPConnListener::DoCancel() + { + MSRPLOG( "CMSRPConnListener::DoCancel enter" ) + iListenSocket.CancelAccept(); + //if(iDataSocket) + { + iDataSocket->Close(); + delete iDataSocket; + iDataSocket = NULL; + } + MSRPLOG( "CMSRPConnListener::DoCancel exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPConnListener::ListenL +// ----------------------------------------------------------------------------- +// +void CMSRPConnListener::ListenL() + { + MSRPLOG( "CMSRPConnListener::ListenL enter" ) + iTimer->Cancel(); + iListenCount++; + if(iState == ENotAccepting || iState == ENotListening) + ActivateL(); + MSRPLOG( "CMSRPConnListener::ListenL exit" ) + + } + +// ----------------------------------------------------------------------------- +// CMSRPConnListener::ListenCancel +// ListenCancel will get invoked for connections that time out +// So listener will not keep running waiting for clients that failed to connect +// ----------------------------------------------------------------------------- +// + +void CMSRPConnListener::ListenCancel() + { + MSRPLOG( "CMSRPConnListener::ListenCancel enter" ) + if(iListenCount > 0) + iListenCount--; + + if(iListenCount == 0) + { + Cancel(); + iState = ENotAccepting; + iTimer->After( KListenTimeoutInSeconds * KSecondinMicroseconds ); + } + MSRPLOG( "CMSRPConnListener::ListenCancel exit" ) + } + +// ----------------------------------------------------------------------------- +// called by observer on Notify, reactivates listener and updates count +// ----------------------------------------------------------------------------- +void CMSRPConnListener::ListenCompletedL(TBool aValid) + { + MSRPLOG( "CMSRPConnListener::ListenCompletedL enter" ) + if(!aValid) + { + /*ownership not transferred*/ + iDataSocket->Close(); + delete iDataSocket; + } + else if ( iListenCount > 0) + { + iListenCount--; + } + iDataSocket = NULL; + if(iListenCount > 0) + { + ActivateL(); + } + else + { + iState = ENotAccepting; + iTimer->After( KListenTimeoutInSeconds * KSecondinMicroseconds ); + } + MSRPLOG( "CMSRPConnListener::ListenCompletedL exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPConnListener::StartListeningL +// ----------------------------------------------------------------------------- +// +void CMSRPConnListener::ActivateL() + { + MSRPLOG( "CMSRPConnListener::ActivateL enter" ) + if(iState == ENotListening) + { + TInetAddr localAddr; + iConnMngr.ResolveLocalIPAddressL( localAddr ); + localAddr.SetPort( KMsrpPort ); + User::LeaveIfError( iListenSocket.Open( + iConnMngr.SocketServer(), KAfInet, KSockStream, KProtocolInetTcp, iConnMngr.SocketServerConn() ) ); + User::LeaveIfError( iListenSocket.SetOpt( KSoReuseAddr, KSolInetIp, ETrue ) ); + + User::LeaveIfError( iListenSocket.Bind( localAddr ) ); + + User::LeaveIfError( iListenSocket.Listen( KListenQueueSize ) ); + + } + + iDataSocket = new (ELeave) RSocket; + User::LeaveIfError( iDataSocket->Open( iConnMngr.SocketServer() ) ); + iListenSocket.Accept( *iDataSocket, iStatus ); + iState = EAccepting; + SetActive(); + + MSRPLOG( "CMSRPConnListener::ActivateL exit" ) + } + + +// ----------------------------------------------------------------------------- +// CMSRPConnListener::RunL +// ----------------------------------------------------------------------------- +// +void CMSRPConnListener::RunL() + { + MSRPLOG2( "CMSRPConnListener::RunL status = %d", iStatus.Int() ); + + //switch( iState ) + { + if( iStatus.Int() == KErrNone ) + { + //if(iListenCount) + NotifyL(EListenAccepted); + } + else + { + //if state not stopping NotifyL(EListenPortError); else NotifyL(EStopped); + NotifyL(EListenPortError); + } + } + + MSRPLOG( "CMSRPConnListener::RunL exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPConnListener::RunError +// ----------------------------------------------------------------------------- +// +TInt CMSRPConnListener::RunError(TInt aError) + { + MSRPLOG( "CMSRPConnListener::RunError enter" ); + + //leave on other error, terminate + //TRAPD(err, NotifyL(ETerminate); + aError = KErrNone; + MSRPLOG( "CMSRPConnListener::RunError exit" ); + return aError; + } + + +// ----------------------------------------------------------------------------- +// CMSRPConnListener::ChangeStateAndNotify +// ----------------------------------------------------------------------------- +// +void CMSRPConnListener::NotifyL(TListenerState aNewState) + { + MSRPLOG( "CMSRPConnListener::NotifyL enter" ) + iState = aNewState; + iConnMngr.ListenerStateL( iState, iDataSocket, iStatus.Int()); + MSRPLOG( "CMSRPConnListener::NotifyL exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPConnListener::TimerExpired +// Callback from the timeout notifier. +// ----------------------------------------------------------------------------- +// +void CMSRPConnListener::TimerExpiredL() + { + MSRPLOG( "CMSRPConnListener::TimerExpired enter" ) + //non leaving, no issue here as notifyl does not leave on timeout, + //TRAPD(err, NotifyL(ETimedOut)); + NotifyL(ETimedOut); + MSRPLOG( "CMSRPConnListener::TimerExpired exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPConnListener::Stop +// Cancelling any outstanding read/write request. +// ----------------------------------------------------------------------------- +// +/* +void CMSRPConnListener::StopListeningL() + { + iListenSocket.CancelAccept(); + NotifyL(EStopping); + } +*/ + + +// End of file diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/CMSRPConnection.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/CMSRPConnection.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,443 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMSRPConnection.h" +#include "MSRPCommon.h" +// INTERNAL INCLUDES +#include "CMSRPConnector.h" +#include "CMSRPReader.h" +#include "CMSRPParser.h" +#include "CMSRPWriter.h" + +// ----------------------------------------------------------------------------- +// Constructor +// ----------------------------------------------------------------------------- +// +CMSRPConnection::CMSRPConnection( TInetAddr& aRemoteAddr, MMSRPConnectionManager& aConnMngr ): iHostAddress(aRemoteAddr), iConnMngr(aConnMngr) + { + MSRPLOG( "CMSRPConnection::CMSRPConnection enter" ) + MSRPLOG( "CMSRPConnection::CMSRPConnection exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPConnection::~CMSRPConnection +// ----------------------------------------------------------------------------- +// +CMSRPConnection::~CMSRPConnection() + { + MSRPLOG( "CMSRPConnection::~CMSRPConnection enter" ) + iSubsessions.Reset(); + iSubsessions.Close(); + delete iListenTimer; + delete iConnector; + delete iWriter; + delete iParser; + delete iReader; + //delete iBufPool; + if(iSocket) + { + iSocket->Close(); + delete iSocket; + } + + MSRPLOG( "CMSRPConnection::~CMSRPConnection exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPConnection* CMSRPConnection::NewL +// ----------------------------------------------------------------------------- +// +/*static*/ MMSRPConnection* CMSRPConnection::NewL( TInetAddr& aRemoteAddr, MMSRPConnectionManager& aConnMngr ) + { + MSRPLOG( "CMSRPConnection::NewL enter" ) + + // Perform construction. + CMSRPConnection* self = new ( ELeave ) CMSRPConnection(aRemoteAddr, aConnMngr); + CleanupStack::PushL( self ); + self->ConstructL( ); + CleanupStack::Pop( self ); + + MSRPLOG( "CMSRPConnection::NewL exit" ) + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPConnection::ConstructL +// ----------------------------------------------------------------------------- +// +void CMSRPConnection::ConstructL( ) + { + MSRPLOG( "CMSRPConnection::ConstructL enter" ) + iConnectionState = ENotConnected; + iListenTimer = CMSRPTimeOutTimer::NewL( *this ); + MSRPLOG( "CMSRPConnection::ConstructL exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPConnection::CheckIfConnected +// listening state check for validating listener connections +// ----------------------------------------------------------------------------- +// +TBool CMSRPConnection::CheckConnection(TInetAddr& aRemoteAddr, TBool aOnlyListen) + { + MSRPLOG( "CMSRPConnection::CheckConnection enter" ) + TUint port_stored = iHostAddress.Port(); + TUint port_connect = aRemoteAddr.Port(); + + //if (iHostAddress.CmpAddr(aRemoteAddr))//v4, v6 issue + if (iHostAddress.Match(aRemoteAddr) && port_stored == port_connect) + { + if (aOnlyListen && iConnectionState == EListening) //check if listening + return ETrue; + else if (!aOnlyListen /*&& iConnectionState <= EConnected */) //not connected, connecting, listening, connected + return ETrue; + /*else + return EFalse;*/ //timed out, disconnecting, disconnected, create a new conn object + } + MSRPLOG( "CMSRPConnection::CheckConnection exit" ) + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CMSRPConnection::ConnectL +// ----------------------------------------------------------------------------- +// +TInt CMSRPConnection::ConnectL(MMSRPConnectionObserver& aSubsession) + { + MSRPLOG("CMSRPConnection::ConnectL() enter") + //subsession to ensure it does not reissue + //connection does not check for pre-existent observers + + iSubsessions.AppendL(&aSubsession); + + switch(iConnectionState) + { + case ENotConnected: + //create connector and issue connect + //delete iConnector; + iConnector = CMSRPConnector::NewL( iConnMngr, *this ); + iConnector->Connect(iHostAddress); + iConnectionState = EConnecting; + + break; + + case EConnecting: + break; + + case EListening: //as of now, dont try to issue connect,complete when other party connects + //TBD + //later change state to connecting and issue connect + //if connect completes before listen, then change state to connected + // if at all listen completes on same conn object, then check if state == connected and drop listen conn + // do vice versa if listen completes before connect + break; + + case EConnected: + break; + + case EListenTimedOut: + case EConnectTimedOut: + case EError: + //shudn't reach here, if connect issued immediately after/within getConn + //User::Leave(MMSRPConnectionObserver::EConnectionStateUnexpected); + break; + + } + MSRPLOG("CMSRPConnection::ConnectL() exit") + return iConnectionState; + } + + +// ----------------------------------------------------------------------------- +// CMSRPConnection::ListenL +// ----------------------------------------------------------------------------- +// +TInt CMSRPConnection::ListenL(MMSRPConnectionObserver& aSubsession) + { + MSRPLOG("CMSRPConnection::ListenL() enter") + + iSubsessions.AppendL(&aSubsession); + + + switch(iConnectionState) + { + case ENotConnected: + iConnectionState = EListening; + iConnMngr.ListenL(this); + //iListenTimer->After( KListenTimeoutInSeconds * KSecondinMicroseconds ); + + break; + + case EConnecting: //dont issue listen, drop conn if other party connects, change later + + //added check if listening in check connection to prevent accepting conn, + //simply allowing will corrupt listen count, TBD: introduce another EListeningandConnecting state + break; + + case EListening: + break; + + case EConnected: + break; + + case EListenTimedOut: + case EConnectTimedOut: + case EError: + //shudn't reach here, if connect issued immediately after/within getConn + //User::Leave(MMSRPConnectionObserver::EConnectionStateUnexpected); + break; + + } + MSRPLOG("CMSRPConnection::ListenL() exit") + return iConnectionState; + + } + +// ----------------------------------------------------------------------------- +// CMSRPConnection::ReleaseConnection +// ----------------------------------------------------------------------------- +// +void CMSRPConnection::ReleaseConnection(MMSRPConnectionObserver& aSubsession) + { + MSRPLOG("CMSRPConnection::ReleaseConnection() enter") + + Remove(&aSubsession); + + if(iSubsessions.Count()) + { + MSRPLOG("CMSRPConnection::ReleaseConnection() exit") + return; + } + + //if no subsessions (TBD : start timeout timer and disconnect on timeout) + /*if(iConnectionState == EConnecting) + { + //iConnector->CancelConnect(); + delete iConnector; + iConnector = NULL; + } + else if(iConnectionState == EConnected)*/ + + CloseConnection(); + + + //iConnectionState = ENotConnected; + MSRPLOG("CMSRPConnection::ReleaseConnection() exit") + return; + } + +// ----------------------------------------------------------------------------- +// CMSRPConnection::ConnectionEstablishedL +// ----------------------------------------------------------------------------- +// +void CMSRPConnection::ConnectionEstablishedL( TInt aNewState, RSocket* aSocket, TInt aStatus ) + { + MSRPLOG("CMSRPConnection::ConnectionEstablishedL() enter") + iListenTimer->Cancel(); + //if not error + if(aNewState == EConnected) + { + iConnectionState = aNewState; + iSocket = aSocket; + if(iConnector) + { + iConnector->ConnectComplete(); + /*dont delete now,as in case of leave, connector needs 2 b available*/ + //delete iConnector; + //iConnector = NULL; + } + iWriter = CMSRPWriter::NewL(*iSocket , *this); + iParser = CMSRPParser::NewL(*this); + iReader = CMSRPReader::NewL(*iSocket , *this); + + iReader->StartReceivingL(iBufPool.ProvideBufferL()); + } + + /*not deleting connector as yet, notify all could leave in subsession and also delete conn on conn error*/ + //intimate all subsessions + NotifyAllL(aNewState, aStatus ); + + //on error or connect timeout close connection, i.e. intimate all subsessions and delete connection obj + if(aStatus != KErrNone) + { + //listenaccepted does not comeback with error intimations, hence safe to decrement listen count + //currently no risk of double decrementing listener count + //CloseConnection(); + } + + + + MSRPLOG("CMSRPConnection::ConnectionEstablishedL() exit") + } + +TInt CMSRPConnection::getConnectionState() + { + return iConnectionState; + // iConnection state should not be Tint, it should be MMSRPConnection::TMSRPConnectionState. + } + +// ----------------------------------------------------------------------------- +// CMSRPConnection::ReadStatus +// ----------------------------------------------------------------------------- +// +void CMSRPConnection::ReadStatusL(RMsrpBuf& aBuf, TInt aStatus) + { + MSRPLOG("CMSRPConnection::ReadStatusL() enter") + if(aStatus == KErrNone) + { + //post to parser and return immediate + iParser->ParseL(aBuf); + + RMsrpBuf copy(aBuf); + if(copy.MsrpRightExtract() > KThreshold) + { + iReader->StartReceivingL(copy); + } + else + { + iReader->StartReceivingL(iBufPool.ProvideBufferL()); + } + return; + } + //read error or connection error + //intimate all subsessions + NotifyAllL(EError, aStatus ); + //CloseConnection(); + + MSRPLOG("CMSRPConnection::ReadStatusL() exit") + } + +void CMSRPConnection::ParseStatusL (CMSRPMessageHandler* aMsg, TInt aStatus) + { + MSRPLOG("CMSRPConnection::ParseStatus enter") + if (aStatus != KErrNone) + { + NotifyAllL(EError, aStatus ); + //CloseConnection(); + return; + } + + /*if error, count is zero*/ + //while msg not consumed try to handover + TBool consumed = FALSE; + for ( TInt i = 0; (!consumed) && i < iSubsessions.Count(); i++ ) + { + consumed = iSubsessions[ i ]->MessageReceivedL( aMsg ); + } + + //if unclaimed by any subsession, callback to first subsession + if(!consumed && iSubsessions.Count()) + { + iSubsessions[0]->UnclaimedMessageL( aMsg ); + } + + MSRPLOG("CMSRPConnection::ParseStatus exit") + } + +// ----------------------------------------------------------------------------- +// CMSRPConnection::WriteSocketError +// ----------------------------------------------------------------------------- +// +void CMSRPConnection::WriteSocketError(TInt aStatus) + { + MSRPLOG("CMSRPConnection::WriteSocketError() enter") + TInt err =0; + TRAP(err, NotifyAllL(EError, aStatus)); + //CloseConnection(); + MSRPLOG("CMSRPConnection::WriteSocketError() exit") + } + +// ----------------------------------------------------------------------------- +// CMSRPConnection::Send +// ----------------------------------------------------------------------------- +// +void CMSRPConnection::SendL(MMSRPWriterObserver& aMsg) + { + MSRPLOG("CMSRPConnection::SendL() enter") + if(iConnectionState == EConnected) + iWriter->RequestSendL(aMsg); + MSRPLOG("CMSRPConnection::SendL() exit") + } + +// ----------------------------------------------------------------------------- +// CMSRPConnection::TimerExpired +// ----------------------------------------------------------------------------- +// +void CMSRPConnection::TimerExpiredL() + { + MSRPLOG("CMSRPConnection::TimerExpired() enter") + if(iConnectionState == EListening) + NotifyAllL(EListenTimedOut, KErrTimedOut); + else + NotifyAllL(EConnectTimedOut, KErrTimedOut); + //iConnMngr.ListenCancel(this); + MSRPLOG("CMSRPConnection::TimerExpired() exit") + } + + +// ----------------------------------------------------------------------------- +// CMSRPConnection::Remove +// ----------------------------------------------------------------------------- +// +void CMSRPConnection::Remove(MMSRPConnectionObserver* aSubsession) + { + MSRPLOG("CMSRPConnection::Remove() enter") + TInt index = iSubsessions.Find(aSubsession); + //iSubsessions[index].DisconnectIssued; + if(index != KErrNotFound) + iSubsessions.Remove(index); + MSRPLOG("CMSRPConnection::Remove() exit") + } + +// ----------------------------------------------------------------------------- +// CMSRPConnection::CloseConnection +// ----------------------------------------------------------------------------- +// +void CMSRPConnection::CloseConnection() + { + MSRPLOG("CMSRPConnection::CloseConnection() enter") + //for connected no listen cancel needed + //for listener error listener deleted + if(/*iConnectionState == EListenConnected ||*/ iConnectionState == EListening || iConnectionState == EListenTimedOut) + iConnMngr.ListenCancel(this); + else + //deleting connection, takes care of issuing cancel connect on connector also (if connecting) + iConnMngr.Remove(this); + MSRPLOG("CMSRPConnection::CloseConnection() exit") + } + + + +// ----------------------------------------------------------------------------- +// CMSRPConnection::NotifyAll +// ----------------------------------------------------------------------------- +// +void CMSRPConnection::NotifyAllL(TInt aNewState, TInt aStatus ) + { + MSRPLOG("CMSRPConnection::NotifyAll() enter") + iConnectionState = aNewState; + for ( TInt i = 0; i < iSubsessions.Count(); i++ ) + { + //make sure connectionstate does not release in notify + //else returns a value to reflect the same + iSubsessions[ i ]->ConnectionStateL( aNewState, aStatus ); + } + MSRPLOG("CMSRPConnection::NotifyAll() exit") + } + + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/CMSRPConnectionManager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/CMSRPConnectionManager.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,404 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMSRPConnectionManager.h" +#include "MSRPCommon.h" +#include "CMSRPConnection.h" +#include "CMSRPConnListener.h" +#include +#if defined(__SERIES60_) +#include +#endif + +// INTERNAL INCLUDES + +// ----------------------------------------------------------------------------- +// Constructor +// ----------------------------------------------------------------------------- +// +CMSRPConnectionManager::CMSRPConnectionManager( const TUint32 aIapID, MMSRPConnectionManagerObserver& aServer ) + : iIapID( aIapID ), iObserver( aServer ) + { + MSRPLOG( "CMSRPConnectionManager::CMSRPConnectionManager enter" ) + MSRPLOG( "CMSRPConnectionManager::CMSRPConnectionManager exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPConnectionManager* CMSRPConnectionManager::NewL +// ----------------------------------------------------------------------------- +// +/*static*/CMSRPConnectionManager* CMSRPConnectionManager::NewL( const TUint32 aIapID, MMSRPConnectionManagerObserver& aServer ) + { + MSRPLOG( "CMSRPConnectionManager::NewL enter" ) + + // Perform construction. + CMSRPConnectionManager* self = new ( ELeave ) CMSRPConnectionManager( aIapID, aServer ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + + MSRPLOG( "CMSRPConnectionManager::NewL exit" ) + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPConnectionManager::ConstructL +// ----------------------------------------------------------------------------- +// +void CMSRPConnectionManager::ConstructL( ) + { + MSRPLOG( "CMSRPConnectionManager::ConstructL enter" ) + + TInt status = iSocketServer.Connect(); + if (status != KErrNone) + { + //iObserver->HandleError(ESocketServerStartFailed, status , *this );//need to pass connmngr as server handles many connmngrs + //User::Leave(status); + User::Leave(MMSRPConnectionManagerObserver::ESocketServerStartFailed); //leave code instead of observer call, as in constructl itself + } + + status = StartInterface(); + if (status != KErrNone) + { + User::Leave(MMSRPConnectionManagerObserver::EInterfaceStartFailed); + } + + MSRPLOG( "CMSRPConnectionManager::ConstructL exit" ) + } + + +CMSRPConnectionManager::~CMSRPConnectionManager() + { + MSRPLOG( "CMSRPConnectionManager::~CMSRPConnectionManager enter" ) + + delete iConnListener; + iConnectionArray.ResetAndDestroy(); + iConnectionArray.Close(); + iHostResolver.Close(); + iConnection.Close(); + iSocketServer.Close(); + + MSRPLOG( "CMSRPConnectionManager::~CMSRPConnectionManager exit" ) + } + + +// ----------------------------------------------------------------------------- +// CMSRPConnectionManager::ConnectL +// ----------------------------------------------------------------------------- +// +MMSRPConnection& CMSRPConnectionManager::getConnectionL( TDesC8& aHost, TUint aPort ) + { + MSRPLOG( "CMSRPConnectionManager::getConnectionL enter" ) + + TInetAddr hostAddr; + TRAPD(err, ResolveIPAddressL( aHost, hostAddr )); + if(err != KErrNone) + { + //iObserver->HandleError( MMSRPConnectionManagerObserver::EAddressResolveError, err , *this ); + User::Leave(MMSRPConnectionManagerObserver::EAddressResolveError); + } + hostAddr.SetPort(aPort); + + MMSRPConnection* connection = CheckConnection( hostAddr, FALSE ); + + if ( !connection ) + { + connection = CMSRPConnection::NewL( hostAddr, *this ); + CleanupDeletePushL(connection);//as M class + //CleanupStack::PushL( connection ); + iConnectionArray.AppendL( connection ); + CleanupStack::Pop( ); + } + + MSRPLOG( "CMSRPConnectionManager::getConnectionL exit" ) + + return *connection; + } + + +// ----------------------------------------------------------------------------- +// CMSRPConnectionManager::StartListener +//connection calls connmngr listen, which in turn calls listener listen +//if state not listening +// ----------------------------------------------------------------------------- +// +void CMSRPConnectionManager::ListenL(MMSRPConnection* /*aConnection*/) + { + MSRPLOG( "CMSRPConnectionManager::ListenL enter" ) + if(!iConnListener) + { + iConnListener = CMSRPConnListener::NewL(*this); + } + + TRAPD(err,iConnListener->ListenL()); + + if(err != KErrNone) + { + //delete iConnListener; + //iConnListener = NULL; + //iObserver->HandleError( MMSRPConnectionManagerObserver::EListenerStartError, err , *this );//communicate to server to trigger cleanup + + /*subsession can propagate to server (based on error), which handles error*/ + User::Leave(MMSRPConnectionManagerObserver::EListenerStartError); //listenL leaves to subsession + } + + MSRPLOG( "CMSRPConnectionManager::ListenL exit" ) + + } + +// ----------------------------------------------------------------------------- +// CMSRPConnectionManager::ListenCancel +//connection listencancel calls mngr cancel if one registered subsession observer or state notlistening +// ----------------------------------------------------------------------------- +// +void CMSRPConnectionManager::ListenCancel(MMSRPConnection* aConnection) + { + MSRPLOG( "CMSRPConnectionManager::ListenCancel enter" ) + if(iConnListener) + { + iConnListener->ListenCancel(); + } + Remove(aConnection); + + MSRPLOG( "CMSRPConnectionManager::ListenCancel exit" ) + } + + +// ----------------------------------------------------------------------------- +// CMSRPConnectionManager::ListenerState +// ----------------------------------------------------------------------------- +// +void CMSRPConnectionManager::ListenerStateL( TInt aNewState, RSocket* aDataSocket, TInt aStatus ) + { + MSRPLOG( "CMSRPConnectionManager::ListenerStateL enter" ) + if (aNewState == MMSRPListener::EListenAccepted) + { + TInetAddr remoteAddr; + aDataSocket->RemoteName(remoteAddr); + + MMSRPConnection* connection = CheckConnection( remoteAddr, TRUE ); + + if ( !connection ) + { + iConnListener->ListenCompletedL(FALSE); + } + else + { + iConnListener->ListenCompletedL(TRUE); + TRAPD(err, connection->ConnectionEstablishedL(MMSRPConnection::EConnected, aDataSocket, aStatus )); + if(err!=KErrNone) + //non leaving on error, introduce separate fn later + connection->ConnectionEstablishedL(MMSRPConnection::EError, aDataSocket, err ); + } + } + else if (aNewState == MMSRPListener::ETimedOut || aNewState == MMSRPListener::ETerminate) + { + delete iConnListener; + iConnListener = NULL; + //all listening connections, auto deleted on listen timeout in conn + } + else if (aNewState == MMSRPListener::EListenPortError) + { + delete iConnListener; + iConnListener = NULL; + User::Leave(MMSRPConnectionManagerObserver::EListenPortFailed); + //leave here, propagate upto msrpscheduler, in scheduler error intimate server to handle the error + //instead could intimate observer (server) directly + //iObserver->HandleError( MMSRPConnectionManagerObserver::EListenPortFailed, aStatus , *this ); + } + MSRPLOG( "CMSRPConnectionManager::ListenerStateL exit" ) + } + + +// ----------------------------------------------------------------------------- +// CMSRPConnectionManager::CheckConnection +// ----------------------------------------------------------------------------- +// +MMSRPConnection* CMSRPConnectionManager::CheckConnection( TInetAddr& aHostAddress, TBool aListenOnly ) + { + MSRPLOG( "CMSRPConnectionManager::CheckConnection enter" ) + for( TInt i = 0; i < iConnectionArray.Count(); i++ ) + { + if ( iConnectionArray[ i ]->CheckConnection( aHostAddress, aListenOnly ) ) + { + return iConnectionArray[ i ]; + } + } + MSRPLOG( "CMSRPConnectionManager::CheckConnection exit" ) + return NULL; + } + + +// ----------------------------------------------------------------------------- +// CMSRPConnectionManager::StartInterfaceL +// Activates PDP ctx +// ----------------------------------------------------------------------------- +// +TInt CMSRPConnectionManager::StartInterface() + { + + MSRPLOG( "CMSRPConnectionManager::StartInterface enter" ) + + TInt status = KErrNone; + //if( !iConnection.SubSessionHandle() ) + { + status = iConnection.Open( iSocketServer ); + } + +#if defined(__SERIES60_) + if (status == KErrNone) + { + TConnPrefList prefList; + TExtendedConnPref extPrefs; + + extPrefs.SetIapId( iIapID ); + TRAP(status, prefList.AppendL(&extPrefs)); + if (status == KErrNone) + { + status = iConnection.Start( prefList ); + } + } +#else + if (status == KErrNone) + { + TCommDbConnPref prefs; + prefs.SetDialogPreference( ECommDbDialogPrefDoNotPrompt ); + prefs.SetDirection( ECommDbConnectionDirectionUnknown ); + prefs.SetIapId( iIapID ); + + status = iConnection.Start( prefs ); + } +#endif + + MSRPLOG( "CMSRPConnectionManager::StartInterface exit" ) + return status; + + } + +// ----------------------------------------------------------------------------- +// CMSRPConnectionManager::ResolveIPAddressL +// ----------------------------------------------------------------------------- +// +void CMSRPConnectionManager::ResolveIPAddressL( + const TDesC8& aHost, + TInetAddr& aAddress ) + { + MSRPLOG( "CMSRPConnectionManager::ResolveIPAddressL enter" ) + //RHostResolver hostResolver; + TNameEntry entry; + TBuf< KMaxLengthOfUrl > hostAddr; + + if( !iHostResolver.SubSessionHandle() ) + { + User::LeaveIfError( iHostResolver.Open( iSocketServer, KAfInet, + KProtocolInetTcp, iConnection )); + } + + //CleanupClosePushL( hostResolver ); + + hostAddr.Copy( aHost ); + User::LeaveIfError( iHostResolver.GetByName( hostAddr, entry ) ); + if ( !TInetAddr::Cast( entry().iAddr ).IsWildAddr() ) + { + aAddress = TInetAddr::Cast( entry().iAddr ); + } + //CleanupStack::PopAndDestroy( ); + MSRPLOG( "CMSRPConnectionManager::ResolveIPAddressL exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPIncomingListener::ResolveLocalIPAddressL +// Resolves the local IP address. +// ----------------------------------------------------------------------------- +// +void CMSRPConnectionManager::ResolveLocalIPAddressL(TInetAddr& aLocalAddr) + { + MSRPLOG( "CMSRPConnectionManager::ResolveLocalIPAddressL enter" ) + if (!iLocalAddr.IsUnspecified()) + { + aLocalAddr = iLocalAddr; + return; + } + /* Open an RSocket and find its address */ + RSocket socket; + User::LeaveIfError(socket.Open(iSocketServer, KAfInet, KSockDatagram, KProtocolInetUdp,iConnection)); + + CleanupClosePushL(socket); + + TSoInetInterfaceInfo networkInfo; + TPckg opt(networkInfo); + User::LeaveIfError(socket.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl)); + TSoInetIfQuery query; + TPckg queryBuf(query); + TInt res = KErrNone; + do + { + res = socket.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, opt); + if (!res && opt().iState == EIfUp) + { + query.iName = opt().iName; + res = socket.GetOpt(KSoInetIfQueryByName, KSolInetIfQuery, queryBuf); + if (!res && query.iZone[1] == iIapID) + { + networkInfo = opt(); + break; + } + } + } + while (res == KErrNone); + User::LeaveIfError(res); + CleanupStack::PopAndDestroy(1); + aLocalAddr = networkInfo.iAddress; + iLocalAddr = aLocalAddr; + MSRPLOG( "CMSRPConnectionManager::ResolveLocalIPAddressL exit" ) + } + +void CMSRPConnectionManager::Remove(MMSRPConnection* aConn) + { + MSRPLOG( "CMSRPConnectionManager::Remove connection enter" ) + TInt index = iConnectionArray.Find(aConn); + + delete iConnectionArray[index]; + iConnectionArray.Remove(index); + MSRPLOG( "CMSRPConnectionManager::Remove connection exit" ) + } + + +RSocketServ& CMSRPConnectionManager::SocketServer() + { + MSRPLOG( "CMSRPConnectionManager::SocketServer fetch enter" ) + MSRPLOG( "CMSRPConnectionManager::SocketServer fetch exit" ) + return iSocketServer; + + } + +RConnection& CMSRPConnectionManager::SocketServerConn() + { + MSRPLOG( "CMSRPConnectionManager::SocketServerConn fetch enter" ) + MSRPLOG( "CMSRPConnectionManager::SocketServerConn fetch exit" ) + return iConnection; + } + +/* +TBool CMSRPConnectionManager::MatchIapId(TUint32 aIapID) + { + return (aIapID == iIapID); + } +*/ + + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/CMSRPConnector.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/CMSRPConnector.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,168 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// INTERNAL INCLUDES +#include "CMSRPConnector.h" +#include "MSRPCommon.h" + +// ----------------------------------------------------------------------------- +// CMSRPConnListener::NewL +// Static constructor +// ----------------------------------------------------------------------------- +// +/*static*/ MMSRPConnector* CMSRPConnector::NewL(MMSRPConnectionManager& aConnMngr, MMSRPConnectorObserver& aConnection) + { + MSRPLOG( "CMSRPConnector::NewL enter" ) + CMSRPConnector* self = new (ELeave) CMSRPConnector( aConnMngr, aConnection ); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + MSRPLOG( "CMSRPConnector::NewL exit" ) + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPConnector::CMSRPConnector +// Constructor +// ----------------------------------------------------------------------------- +// +CMSRPConnector::CMSRPConnector(MMSRPConnectionManager& aConnMngr, MMSRPConnectorObserver& aConnection) + : CActive(CActive::EPriorityStandard), iConnMngr(aConnMngr), iConnection( aConnection ) + { + CActiveScheduler::Add(this); + } + +// ----------------------------------------------------------------------------- +// CMSRPConnector::~CMSRPConnector +// Destructor +// ----------------------------------------------------------------------------- +// +CMSRPConnector::~CMSRPConnector() + { + MSRPLOG( "CMSRPConnector::~CMSRPConnector enter" ) + delete iTimer; + Cancel(); + if(iSocket) + { + iSocket->Close(); + delete iSocket; + } + MSRPLOG( "CMSRPConnector::~CMSRPConnector exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPConnector::ConstructL +// 2nd phase constructor +// ----------------------------------------------------------------------------- +// +void CMSRPConnector::ConstructL() + { + //iState = ENotConnected; + iTimer = CMSRPTimeOutTimer::NewL( *this ); + //create socket + + iSocket = new (ELeave) RSocket(); + User::LeaveIfError( iSocket->Open( + iConnMngr.SocketServer(), KAfInet, KSockStream, KProtocolInetTcp, iConnMngr.SocketServerConn())); + User::LeaveIfError( iSocket->SetOpt( KSoReuseAddr, KSolInetIp, ETrue ) ); + iSocket->SetLocalPort(KMsrpPort); + } + +// ----------------------------------------------------------------------------- +// CMSRPConnector::DoCancel +// Cancels outstanding request. +// ----------------------------------------------------------------------------- +// +void CMSRPConnector::DoCancel() + { + MSRPLOG( "CMSRPConnector::DoCancel enter" ) + iSocket->CancelConnect(); + MSRPLOG( "CMSRPConnector::DoCancel exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPConnector::Connect +// ----------------------------------------------------------------------------- +// +void CMSRPConnector::Connect(TInetAddr& aRemoteAddr) + { + MSRPLOG( "CMSRPConnector::Connect enter" ) + iSocket->Connect( aRemoteAddr, iStatus ); + //iState = EConnecting; + SetActive(); + iTimer->After( KTimeOutInSeconds * KSecondinMicroseconds ); + MSRPLOG( "CMSRPConnector::Connect exit" ) + } + + +// ----------------------------------------------------------------------------- +// CMSRPConnector::TimerExpired +// ----------------------------------------------------------------------------- +// +void CMSRPConnector::TimerExpiredL() + { + MSRPLOG( "CMSRPConnector::TimerExpired enter" ) + iConnection.ConnectionEstablishedL(MMSRPConnection::EConnectTimedOut, iSocket, KErrTimedOut); + MSRPLOG( "CMSRPConnector::TimerExpired exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPConnector::RunL +// ----------------------------------------------------------------------------- +// +void CMSRPConnector::RunL() + { + MSRPLOG( "CMSRPConnector::RunL enter" ) + iTimer->Cancel(); + + if(iStatus.Int() != KErrNone) + { + MSRPLOG2( "CMSRPConnector::RunL Connection Error %d", iStatus.Int() ); + iConnection.ConnectionEstablishedL(MMSRPConnection::EError, iSocket, iStatus.Int()); + return; + } + + iConnection.ConnectionEstablishedL(MMSRPConnection::EConnected, iSocket, KErrNone); + MSRPLOG( "CMSRPConnector::RunL exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPConnector::RunError +// ----------------------------------------------------------------------------- +// +TInt CMSRPConnector::RunError(TInt aError) + { + //handle error delete connector on error + //make sure ConnectorStateL does not leave on EError + MSRPLOG( "CMSRPConnector::RunError enter" ) + TRAPD(err, iConnection.ConnectionEstablishedL(MMSRPConnection::EError, iSocket, aError)); + MSRPLOG( "CMSRPConnector::RunError exit" ) + return err; + } + +// ----------------------------------------------------------------------------- +// CMSRPConnector::ConnectComplete +// ----------------------------------------------------------------------------- +// +void CMSRPConnector::ConnectComplete() + { + MSRPLOG( "CMSRPConnector::ConnectComplete enter" ) + iSocket = NULL; + MSRPLOG( "CMSRPConnector::ConnectComplete exit" ) + } + + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/CMSRPMessageChunkState.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/CMSRPMessageChunkState.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,99 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#include "CMSRPMessageChunkState.h" + + +EXPORT_C CMSRPMessageChunkState* CMSRPMessageChunkState::NewL( ) + { + CMSRPMessageChunkState* self = new (ELeave) CMSRPMessageChunkState( ); + CleanupStack::PushL( self ); + // self->ConstructL( ); + CleanupStack::Pop( self ); + return self; + } + + +EXPORT_C CMSRPMessageChunkState::~CMSRPMessageChunkState() + { + // MSRPStrings::Close(); + } + +CMSRPMessageChunkState::CMSRPMessageChunkState( ) + { + } +/* +void CMSRPMessageChunkState::ConstructL( ) + { + + } +*/ +EXPORT_C void CMSRPMessageChunkState::SetStartPos(TInt aStartPos) + { + iStartPos = aStartPos ; + } + +EXPORT_C TInt CMSRPMessageChunkState::GetStartPos( ) + { + return iStartPos; + } + +EXPORT_C void CMSRPMessageChunkState::SetEndPos(TInt aEndPos) + { + iEndPos = aEndPos ; + } + +EXPORT_C TInt CMSRPMessageChunkState::GetEndPos( ) + { + return iEndPos; + } + +EXPORT_C TBool CMSRPMessageChunkState::GetResponseReceived() + { + if(iResponseReceived) + return ETrue; + else + return EFalse; + + } + +EXPORT_C void CMSRPMessageChunkState::SetResponseReceived(TBool aResponseReceived) + { + iResponseReceived = aResponseReceived; + } + +EXPORT_C TDesC8& CMSRPMessageChunkState::GetTransactionId( ) + { + return iTransactionId; + } + +EXPORT_C void CMSRPMessageChunkState::SetTransactionId(TDesC8& aTransactionId ) + { + iTransactionId = aTransactionId ; + } + +EXPORT_C void CMSRPMessageChunkState::SetResponseSent(TBool aResponseSent) + { + iResponseSent = aResponseSent; + } + +EXPORT_C TBool CMSRPMessageChunkState::GetResponseSent( ) + { + if(iResponseSent) + return ETrue; + else + return EFalse; + } diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/CMSRPMessageHandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/CMSRPMessageHandler.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,1337 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMSRPMessageHandler.h" + + +// INCLUDES +#include +#include + +#include "MMSRPWriterObserver.h" +#include "CMSRPMessage.h" +#include "CMSRPResponse.h" +#include "CMSRPByteRangeHeader.h" +#include "CMSRPToPathHeader.h" +#include "CMSRPFromPathHeader.h" +#include "CMSRPMessageIdHeader.h" +#include "CMSRPSuccessReportHeader.h" +#include "CMSRPFailureReportHeader.h" +#include "CMSRPContentTypeHeader.h" +#include "MSRPStrings.h" +#include "MsrpStrConsts.h" +#include "TMSRPUtil.h" +#include "MMSRPConnection.h" +#include "MMSRPMessageObserver.h" + +// Constants +const TInt KEndlineConstLength = 10; + + +TInt CMSRPMessageHandler::LinkOffset() + { + return _FOFF(CMSRPMessageHandler,iLink); + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageHandler::NewL +// ----------------------------------------------------------------------------- +// +CMSRPMessageHandler* CMSRPMessageHandler::NewL( MMSRPMessageObserver* aMessageObserver, const TDesC8& aMessage ) + { + CMSRPMessageHandler* self = CMSRPMessageHandler::NewLC( aMessageObserver, aMessage ); + CleanupStack::Pop( self ); + return self; + } + +CMSRPMessageHandler* CMSRPMessageHandler::NewL( TMSRPMessageType aMessageType ) + { + CMSRPMessageHandler* self = CMSRPMessageHandler::NewLC( aMessageType ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageHandler::NewLC +// ----------------------------------------------------------------------------- +// +CMSRPMessageHandler* CMSRPMessageHandler::NewLC( MMSRPMessageObserver* aMessageObserver, const TDesC8& aMessage ) + { + CMSRPMessageHandler* self = new (ELeave) CMSRPMessageHandler( aMessageObserver ); + CleanupStack::PushL( self ); + self->ConstructL( aMessage ); + return self; + } + +CMSRPMessageHandler* CMSRPMessageHandler::NewLC( TMSRPMessageType aMessageType ) + { + CMSRPMessageHandler* self = new (ELeave) CMSRPMessageHandler(); + CleanupStack::PushL( self ); + self->ConstructL( aMessageType ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPMessageHandler::ConstructL +// ----------------------------------------------------------------------------- +// +void CMSRPMessageHandler::ConstructL( const TDesC8& aMessage ) + { + MSRPLOG( "CMSRPMessageHandler::ConstructL enter" ) + RDesReadStream readStream( aMessage ); + + if ( CMSRPMessage::IsMessage( aMessage ) ) + { + iMessage = CMSRPMessage::InternalizeL( readStream ); + if( iMessage->IsContent() ) + { + iContentPtr.Set(iMessage->Content()); + } + } + else + { + User::Leave( KErrArgument ); + } + + iBuffer.CreateL( KMaxBufferSize ); + iState = EIdle; + MSRPStrings::OpenL(); + MSRPLOG( "CMSRPMessageHandler::ConstructL exit" ) + } + + +void CMSRPMessageHandler::ConstructL( TMSRPMessageType aMessageType ) + { + MSRPLOG2( "CMSRPMessageHandler::ConstructL enter - MessageType %d", aMessageType ) + if( aMessageType == EMSRPMessage ) + { + iMessage = new ( ELeave ) CMSRPMessage(); + } + else if( aMessageType == EMSRPResponse ) + { + iResponse = new ( ELeave ) CMSRPResponse(); + } + else if( aMessageType == EMSRPReport ) + { + // Since Reports are not supported now.. jus create a message class + iMessage = new ( ELeave ) CMSRPMessage(); + } + else + { + // Maybe AUTH or some unrecognized request. For now just create a message class + iMessage = new ( ELeave ) CMSRPMessage(); + } + + iActiveMsgType = aMessageType; + iBuffer.CreateL( KSmallBuffer ); + iState = EIdle; + MSRPStrings::OpenL(); + MSRPLOG( "CMSRPMessageHandler::ConstructL exit" ) + } + + +// ----------------------------------------------------------------------------- +// Constructor +// ----------------------------------------------------------------------------- +// +CMSRPMessageHandler::CMSRPMessageHandler( MMSRPMessageObserver* aMessageObserver ) + { + iMSRPMessageObserver = aMessageObserver; + } + +CMSRPMessageHandler::CMSRPMessageHandler( ) + { + + } + +// ----------------------------------------------------------------------------- +// Destructor +// ----------------------------------------------------------------------------- +// +CMSRPMessageHandler::~CMSRPMessageHandler( ) + { + delete iMessage; + delete iResponse; + delete iFileBuffer; + iBuffer.Close(); + MSRPStrings::Close(); + iChunkList.ResetAndDestroy(); + iChunkList.Close(); + //iFile.Flush(); + iFile.Close(); + } + + +void CMSRPMessageHandler::AddHeaderL( TMsrpHeaderType aHeaderType, TPtrC8& aHeaderValue, TPtrC8& /*aHeaderTypeAndValue*/ ) + { + MSRPLOG( "CMSRPMessageHandler::AddHeaderL enter" ) + CMSRPMessageBase* messageBase = NULL; + if( iResponse ) + { + messageBase = iResponse; + } + else + { + messageBase = iMessage; + } + + TInt err = KErrNone; + switch( aHeaderType ) + { + case EToPath: + { + messageBase->SetToPathHeader( CMSRPToPathHeader::DecodeL( aHeaderValue ) ); + break; + } + case EFromPath: + { + messageBase->SetFromPathHeader( CMSRPFromPathHeader::DecodeL( aHeaderValue ) ); + break; + } + case EMessageId: + { + messageBase->SetMessageIdHeader( CMSRPMessageIdHeader::NewL( aHeaderValue ) ); + break; + } + case EByteRange: + { + TInt startPos(0); + TInt endPos(0); + TInt total(0); + err = ExtractByteRangeParams( aHeaderValue, startPos, endPos, total ); + messageBase->SetByteRangeHeader( CMSRPByteRangeHeader::NewL( startPos, endPos, total )); + break; + } + case ESuccessReport: + { + if( aHeaderValue == MSRPStrings::StringF( MSRPStrConsts::EYes ).DesC()) + { + messageBase->SetSuccessReportHeader( + CMSRPSuccessReportHeader::NewL( MSRPStrings::StringF( MSRPStrConsts::EYes ) ) ); + } + else if( aHeaderValue == MSRPStrings::StringF( MSRPStrConsts::ENo ).DesC()) + { + messageBase->SetSuccessReportHeader( + CMSRPSuccessReportHeader::NewL( MSRPStrings::StringF( MSRPStrConsts::ENo ) ) ); + } + else + { + err = KErrArgument; + } + break; + } + case EFailureReport: + { + if( aHeaderValue == MSRPStrings::StringF( MSRPStrConsts::EYes ).DesC()) + { + messageBase->SetFailureReportHeader( + CMSRPFailureReportHeader::NewL( MSRPStrings::StringF( MSRPStrConsts::EYes ) ) ); + } + else if( aHeaderValue == MSRPStrings::StringF( MSRPStrConsts::ENo ).DesC()) + { + messageBase->SetFailureReportHeader( + CMSRPFailureReportHeader::NewL( MSRPStrings::StringF( MSRPStrConsts::ENo ) ) ); + } + else if( aHeaderValue == MSRPStrings::StringF( MSRPStrConsts::EPartial ).DesC()) + { + messageBase->SetFailureReportHeader( + CMSRPFailureReportHeader::NewL( MSRPStrings::StringF( MSRPStrConsts::EPartial ) ) ); + } + else + { + err = KErrArgument; + } + break; + } + case EContentType: + { + messageBase->SetContentTypeHeader( CMSRPContentTypeHeader::NewL( aHeaderValue ) ); + break; + } + case EStatus: + { + break; // required for reports only. Not handled now + } + default: + { + break; + } + } + User::LeaveIfError(err); + + MSRPLOG( "CMSRPMessageHandler::AddHeaderL exit" ) + } + + +void CMSRPMessageHandler::AddContentL( TPtrC8& aContent ) + { + MSRPLOG( "CMSRPMessageHandler::AddContentL enter" ) + if( iMessage ) + { + if( iBuffer.Length() + aContent.Length() > iBuffer.MaxLength() ) + { + iBuffer.ReAllocL(iBuffer.Length() + aContent.Length()); + iBuffer.Append(aContent); + } + else + { + iBuffer.Append(aContent); + } + } + MSRPLOG( "CMSRPMessageHandler::AddContentL exit" ) + } + + +void CMSRPMessageHandler::SetTransactionId( TPtrC8& aTransactionId ) + { + MSRPLOG( "CMSRPMessageHandler::SetTransactionId enter" ) + iTransactionId = aTransactionId; + MSRPLOG( "CMSRPMessageHandler::SetTransactionId exit" ) + } + + +void CMSRPMessageHandler::SetStatusOfResponseL( TPtrC8& aStatusCode, TPtrC8& /*aStatusMessage*/ ) + { + MSRPLOG( "CMSRPMessageHandler::SetStatusOfResponseL enter" ) + if( iResponse ) + { + TUint statusCodeVal = TMSRPUtil::ConvertToNumber( aStatusCode ); + RStringF statusString = GetStatusStringL( statusCodeVal ); + iResponse->SetStatusCodeL( statusCodeVal ); + iResponse->SetReasonPhrase( statusString ); + } + MSRPLOG( "CMSRPMessageHandler::SetStatusOfResponseL exit" ) + } + + +void CMSRPMessageHandler::EndOfMessageL( TMsrpMsgEndStatus aStatus ) + { + MSRPLOG( "CMSRPMessageHandler::EndOfMessageL enter" ) + if( iMessage && iBuffer.Length() ) + { + HBufC8* contentOfMessage = HBufC8::NewL( iBuffer.Length() ); + *contentOfMessage = iBuffer; + iMessage->SetContent( contentOfMessage ); + iBuffer.Zero(); + } + iMsgEndStatus = aStatus; + MSRPLOG( "CMSRPMessageHandler::EndOfMessageL exit" ) + } + + +MMSRPIncomingMessage::TMSRPMessageType CMSRPMessageHandler::MessageType( ) + { + MSRPLOG( "CMSRPMessageHandler::MessageType enter" ) + MSRPLOG2("Message Type = %d", iActiveMsgType ); + return iActiveMsgType; + } + + +CMSRPMessage* CMSRPMessageHandler::GetIncomingMessage( ) + { + MSRPLOG( "CMSRPMessageHandler::GetIncomingMessage enter" ) + if( iMessage ) + { + return iMessage; + } + return NULL; + } + + +void CMSRPMessageHandler::UpdateResponseStateL(CMSRPMessageHandler *incomingMsgHandler) + { + MSRPLOG( "CMSRPMessageHandler::UpdateResponseState enter" ) + TBuf8<100> iTransactionId = incomingMsgHandler->TransactionId(); + for(TInt i=0;iGetTransactionId()) + { + iChunkList[i]->SetResponseSent(ETrue); + ReceiveFileStateL(iChunkList[i]->GetEndPos()- iChunkList[i]->GetStartPos() + 1); + } + } + MSRPLOG( "CMSRPMessageHandler::UpdateResponseState exit" ) + } + + +void CMSRPMessageHandler::ReceiveFileStateL( TInt aBytesTransferred ) + { + MSRPLOG( "CMSRPMessageHandler::ReceiveFileState enter" ) + MSRPLOG2( "CMSRPMessageHandler::ReceiveFileState Notify %d", iProgress ) + MSRPLOG2( "CMSRPMessageHandler::ReceiveFileState iFileNotified %d", iNotifiedBytes ) + MSRPLOG2( "CMSRPMessageHandler::ReceiveFileState iunnotified %d", iPendingBytes ) + MSRPLOG2( "CMSRPMessageHandler::ReceiveFileState aBytesTransferred %d", aBytesTransferred ) + MSRPLOG2( "CMSRPMessageHandler::ReceiveFileState iFileSize %d", iFileSize ) + + iPendingBytes += aBytesTransferred; + + if(iNotifiedBytes + iPendingBytes == iFileSize) + { + iFileTransferComplete = ETrue; + } + + if(iPendingBytes >= KMaxChunkReadSize) + { + MSRPLOG( "CMSRPMessageHandler::ReceiveFileState unnotified exceeds threshold" ) + MSRPLOG2( "CMSRPMessageHandler::ReceiveFileState iFileReceiveComplete: %d", iFileTransferComplete ) + + iNotifiedBytes += iPendingBytes; + iPendingBytes = 0; + //notify client of progress + if(iProgress && !iFileTransferComplete) + iMSRPMessageObserver->MessageReceiveProgressL(iNotifiedBytes, iFileSize); + } + + MSRPLOG( "CMSRPMessageHandler::ReceiveFileState exit" ) + } + + +TBool CMSRPMessageHandler::SendResponseL( MMSRPMessageObserver* aMessageObserver, + MMSRPConnection& aConnection, TUint aResponseCode ) + { + MSRPLOG( "CMSRPMessageHandler::SendResponseL enter" ) + + iMSRPMessageObserver = aMessageObserver; + + if( !aResponseCode ) + { + aResponseCode = CheckValidityOfMessage( EMSRPMessage, iMessage ); + } + + TBool sendResponse = ETrue; + if( iMessage->FailureReportHeader() ) + { + HBufC8* frHeaderValue = iMessage->FailureReportHeader()->ToTextValueLC(); + if( frHeaderValue->Des() == MSRPStrings::StringF( MSRPStrConsts::ENo ).DesC() ) + { + sendResponse = EFalse; + } + else if( (frHeaderValue->Des() == MSRPStrings::StringF( MSRPStrConsts::EPartial ).DesC()) + && (aResponseCode == CMSRPResponse::EAllOk) ) + { + sendResponse = EFalse; + } + CleanupStack::PopAndDestroy(frHeaderValue); + } + + if( !iMessage->ToPathHeader() || !iMessage->FromPathHeader() ) + { + aResponseCode = CMSRPResponse::EUnknownCode; + sendResponse = EFalse; + } + + if(sendResponse) + { + RStringF statusString = GetStatusStringL( aResponseCode ); + iResponse = new ( ELeave ) CMSRPResponse( aResponseCode, statusString ) ; + + HBufC8* fromPathValue = iMessage->FromPathHeader()->ToTextValueLC(); + iResponse->SetToPathHeader( CMSRPToPathHeader::DecodeL( *fromPathValue ) ); + CleanupStack::PopAndDestroy(fromPathValue); + + HBufC8* toPathValue = iMessage->ToPathHeader()->ToTextValueLC(); + iResponse->SetFromPathHeader( CMSRPFromPathHeader::DecodeL( *toPathValue ) ); + CleanupStack::PopAndDestroy(toPathValue); + + iActiveMsgType = EMSRPResponse; + aConnection.SendL( *this ); + } + + MSRPLOG( "CMSRPMessageHandler::SendResponseL exit" ) + + if( aResponseCode == CMSRPResponse::EAllOk ) + return ETrue; + else + return EFalse; + } + + +TBool CMSRPMessageHandler::IfResponseReqL() + { + TBool responseReq = ETrue; + if( iMessage->FailureReportHeader() ) + { + HBufC8* frHeaderValue = iMessage->FailureReportHeader()->ToTextValueLC(); + if( frHeaderValue->Des() == MSRPStrings::StringF( MSRPStrConsts::ENo ).DesC() ) + { + responseReq = EFalse; + } + else if( (frHeaderValue->Des() == MSRPStrings::StringF( MSRPStrConsts::EPartial ).DesC())) + { + responseReq = EFalse; + } + CleanupStack::PopAndDestroy(frHeaderValue); + } + return responseReq; + } + + +TDesC8& CMSRPMessageHandler::TransactionId( ) + { + MSRPLOG( "CMSRPMessageHandler::TransactionId enter" ) + return iTransactionId; + } + + +CMSRPResponse* CMSRPMessageHandler::GetIncomingResponse( ) + { + MSRPLOG( "CMSRPMessageHandler::GetIncomingResponse enter" ) + if( iResponse ) + { + return iResponse; + } + return NULL; + } + + +void CMSRPMessageHandler::SendMessageL( MMSRPConnection& aConnection ) + { + MSRPLOG( "CMSRPMessageHandler::SendMessageL enter" ) + iActiveMsgType = EMSRPMessage; + aConnection.SendL( *this ); + MSRPLOG( "CMSRPMessageHandler::SendMessageL exit" ) + } + + +void CMSRPMessageHandler::SendFileL(MMSRPConnection& aConnection) + { + MSRPLOG( "CMSRPMessageHandler::SendFileL enter" ) + /* Flags */ + isFile = ETrue; + iProgress = iMessage->GetNotifyProgress(); + + User::LeaveIfError(iFs.Connect()); + User::LeaveIfError(iFile.Open(iFs, iMessage->GetFileName(), EFileShareReadersOrWriters)); + iFile.Size(iFileSize); + iFileBuffer = HBufC8::NewL(KMaxChunkReadSize); + FillFileBufferL(); + iActiveMsgType = EMSRPMessage; + aConnection.SendL( *this ); + + MSRPLOG( "CMSRPMessageHandler::SendFileL exit" ) + } + + +TInt CMSRPMessageHandler::FillFileBufferL() + { + MSRPLOG( "CMSRPMessageHandler::FillFileBufferL enter" ) + iStartPosInBuffer = 0; + iEndPosInBuffer = 0; + iBufPosInFile+=iFileBuffer->Length(); + iFileBuffer->Des().Zero(); + TPtr8 ptr(iFileBuffer->Des()); + User::LeaveIfError(iFile.Read(iBufPosInFile, ptr, KMaxChunkReadSize)); + MSRPLOG2( "CMSRPMessageHandler::FillFileBufferL File Buffer Length %d", iFileBuffer->Length()); + MSRPLOG( "CMSRPMessageHandler::FillFileBufferL exit" ) + return iFileBuffer->Length(); + } + + +void CMSRPMessageHandler::ReceiveFileL( ) + { + MSRPLOG( "CMSRPMessageHandler::ReceiveFileL enter" ) + isFile = ETrue; + iProgress = iMessage->GetNotifyProgress(); + + User::LeaveIfError(iFs.Connect()); + User::LeaveIfError(iFile.Replace(iFs,iMessage->GetFileName(),EFileWrite)); + iFileSize = iMessage->GetFileSize(); + iFileBuffer = HBufC8::NewL(KMaxChunkReadSize); + + MSRPLOG( "CMSRPMessageHandler::ReceiveFileL exit" ) + } + + +void CMSRPMessageHandler::WritetoFileL(CMSRPMessageHandler *incomingMsgHandler ) + { + MSRPLOG( "CMSRPMessageHandler::WriteToFile enter" ) + CMSRPMessage* inFileChunk = incomingMsgHandler->GetIncomingMessage(); + HBufC8* messageContent = NULL; + if(inFileChunk->IsContent()) + { + messageContent = HBufC8::NewL(inFileChunk->Content().Length()); + *messageContent = inFileChunk->Content(); + WriteChunkToFileL(*messageContent,incomingMsgHandler->TransactionId()); + + if (!incomingMsgHandler->IfResponseReqL()) + ReceiveFileStateL(messageContent->Length()); + } + delete messageContent; + MSRPLOG( "CMSRPMessageHandler::WriteToFile exit" ) + } + + +void CMSRPMessageHandler::WriteChunkToFileL(const TDesC8& aFileChunk ,TDesC8& aTransactionId) + { + MSRPLOG( "CMSRPMessageHandler::WriteChunktoFile enter" ) + if(iBufPosInFile<(iFileSize-1)) + { + iFile.Write(iBufPosInFile,aFileChunk); + + /* Create and update the structure */ + CMSRPMessageChunkState* iChunk = CMSRPMessageChunkState::NewL( ); + iChunk->SetStartPos(iBufPosInFile); + iBufPosInFile += aFileChunk.Length(); + iChunk->SetEndPos(iBufPosInFile-1); + iChunk->SetTransactionId(aTransactionId); + iChunkList.Append(iChunk); + } + else + { + //Receive Bytes greater than file Size + User::Leave( KErrArgument ); + } + + MSRPLOG( "CMSRPMessageHandler::WriteChunktoFile exit" ) + + } + + +TBool CMSRPMessageHandler::IsOwnerOfResponse( MMSRPIncomingMessage& aIncomingMessage ) + { + MSRPLOG( "CMSRPMessageHandler::IsOwnerOfResponse enter" ) + if(isFile) + { + /* compare for transaction id */ + for(TInt i=0;iGetTransactionId()) + { + if( iState == EWaitingForResponse || ( iState == EMessageSent && iResponseNeeded )) + { + if (i == iChunkList.Count()-1) + { + iResponseNeeded = EFalse; + iState = EMessageDone; + } + } + return ETrue; + } + } + } + if( aIncomingMessage.TransactionId() == iTransactionId ) + { + if( iState == EWaitingForResponse || ( iState == EMessageSent && iResponseNeeded )) + { + iResponseNeeded = EFalse; + return ETrue; + } + } + + MSRPLOG( "CMSRPMessageHandler::IsOwnerOfResponse exit" ) + return EFalse; + } + + +void CMSRPMessageHandler::ConsumeFileResponseL(MMSRPIncomingMessage& aIncomingMessage ) + { + MSRPLOG( "CMSRPMessageHandler::ConsumeFileResponseL enter" ) + CMSRPResponse* response = aIncomingMessage.GetIncomingResponse(); + TUint statusCode = response->StatusCode(); + + for(TInt i=0;iGetTransactionId()) + { + iChunkList[i]->SetResponseReceived(ETrue); + SendFileStateL(iChunkList[i]->GetEndPos()- iChunkList[i]->GetStartPos() + 1 ) ; + } + } + + MSRPLOG( "CMSRPMessageHandler::ConsumeFileResponseL exit" ) + } + + +void CMSRPMessageHandler::SendFileStateL(TInt aBytesTransferred ) + { + MSRPLOG( "CMSRPMessageHandler::SendFileStateL enter" ) + MSRPLOG2( "CMSRPMessageHandler::SendFileStateL granularity %d", iProgress ) + MSRPLOG2( "CMSRPMessageHandler::SendFileStateL iFileNotified %d", iNotifiedBytes ) + MSRPLOG2( "CMSRPMessageHandler::SendFileStateL iunnotified %d", iPendingBytes ) + MSRPLOG2( "CMSRPMessageHandler::SendFileStateL aBytesTransferred %d", aBytesTransferred ) + MSRPLOG2( "CMSRPMessageHandler::SendFileStateL iFileSize %d", iFileSize ) + + iPendingBytes += aBytesTransferred; + + if(iNotifiedBytes + iPendingBytes == iFileSize) + { + iFileTransferComplete = ETrue; + } + + if(iPendingBytes >= KMaxChunkReadSize) + { + MSRPLOG( "CMSRPMessageHandler::SendFileStateL unnotified exceeds threshold" ) + MSRPLOG2( "CMSRPMessageHandler::SendFileStateL iFileSendComplete: %d", iFileTransferComplete ) + iNotifiedBytes += iPendingBytes; + iPendingBytes = 0; + + //notify client of progress + if( iProgress && !iFileTransferComplete )//send progress requested and avoid double notifn. as send complete not handled in waitfor clientstate + iMSRPMessageObserver->MessageSendProgressL(iNotifiedBytes, iFileSize);//iByteinPos + + } + MSRPLOG( "CMSRPMessageHandler::SendFileStateL exit" ) + } + + +TBool CMSRPMessageHandler::FileTransferComplete( ) + { + if(iFileTransferComplete) + return ETrue; + else + return EFalse; + } + + +TBool CMSRPMessageHandler::IsInFile() + { + if(isFile) + { + return ETrue; + } + return EFalse; + } + + +TBool CMSRPMessageHandler::ConsumeResponseL( MMSRPIncomingMessage& aIncomingMessage ) + { + MSRPLOG( "CMSRPMessageHandler::ConsumeResponseL enter" ) + + TBool ret; + CMSRPResponse* response = aIncomingMessage.GetIncomingResponse(); + TUint statusCode = response->StatusCode(); + + if( iMessage->FailureReportHeader() && + (iMessage->FailureReportHeader()->ToTextValueLC()->Des() == + MSRPStrings::StringF( MSRPStrConsts::EPartial ).DesC()) && + statusCode == CMSRPResponse::EAllOk ) + { + iState = EMessageDone; + ret = EFalse; + } + else + { + RStringF statusString = response->ReasonPhrase(); + iResponse = new (ELeave) CMSRPResponse( statusCode, statusString ); + HBufC8* toPathValue = response->ToPathHeader()->ToTextValueLC(); + HBufC8* fromPathValue = response->FromPathHeader()->ToTextValueLC(); + iResponse->SetToPathHeader( CMSRPToPathHeader::DecodeL( toPathValue->Des() ) ); + iResponse->SetFromPathHeader( CMSRPFromPathHeader::DecodeL( fromPathValue->Des() ) ); + CleanupStack::PopAndDestroy(fromPathValue); + CleanupStack::PopAndDestroy(toPathValue); + iState = EMessageDone; + ret = ETrue; + } + + if( iMessage->FailureReportHeader() ) + { + CleanupStack::PopAndDestroy(); // FR header value from above + } + + MSRPLOG( "CMSRPMessageHandler::ConsumeResponseL exit" ) + return ret; + } + + +TBool CMSRPMessageHandler::IsMessageComplete() + { + MSRPLOG( "CMSRPMessageHandler::IsMessageComplete enter" ) + if( iState == EMessageDone ) + return ETrue; + else + return EFalse; + } + + +TBool CMSRPMessageHandler::GetSendResultL( TUint &aErrorCode, HBufC8* &aMessageId ) + { + MSRPLOG( "CMSRPMessageHandler::GetSendResult enter" ) + if( iState == EMessageDone ) + { + aMessageId = iMessage->MessageIdHeader()->ToTextValueLC(); + CleanupStack::Pop(aMessageId); + if(iResponse) + { + TUint code = iResponse->StatusCode(); + if( code == CMSRPResponse::EAllOk ) + { + aErrorCode = ENoError; + } + else if ( code == CMSRPResponse::ETimeout ) + { + aErrorCode = ENetworkTimeout; + } + else + { + aErrorCode = EUnrecoverableError; + } + } + else + { + aErrorCode = ENoError; + } + } + MSRPLOG( "CMSRPMessageHandler::GetSendResult exit" ) + if( aErrorCode == EUnrecoverableError ) + { + return ETrue; + } + else + { + return EFalse; + } + } + + +MMSRPWriterObserver::TWriteStatus CMSRPMessageHandler::GetSendBufferL( TPtrC8& aData, TBool aInterrupt ) + { + MSRPLOG( "CMSRPMessageHandler::GetSendBufferL enter" ) + iInterrupt = aInterrupt; + iWriteDone = EFalse; + iBuffer.Zero(); + + while( !iWriteDone ) + { + if( iState == EIdle ) + { + if( iActiveMsgType == EMSRPMessage ) + { + CreateByteRangeHeaderL(); + } + WriteInitialLineToBufferL(); + WriteHeadersToBufferL(); + } + + else if( iState == EInProgress ) + { + if( iMessage->IsFile()) + { + if (iActiveMsgType == EMSRPMessage) + WriteFileContentToBufferL(); + else + WriteEndLineToBuffer(); + } + else + { + if( iContentPtr.Length() ) + WriteContentToBuffer(); + else + WriteEndLineToBuffer(); + } + } + else + { + User::LeaveIfError(KErrArgument); + } + } + + aData.Set(iBuffer); + MSRPLOG( "CMSRPMessageHandler::GetSendBufferL exit" ) + return EMsrpSocketWrite; + } + + +MMSRPWriterObserver::TMsgStatus CMSRPMessageHandler::WriteDoneL( TInt aStatus ) + { + MSRPLOG( "CMSRPMessageHandler::WriteDoneL enter" ) + MMSRPWriterObserver::TMsgStatus retStatus = EUndefined; + + if( !aStatus ) + { + /*if file send and message and response not needed, update progress*/ + if (isFile && iActiveMsgType == EMSRPMessage && iResponseNeeded == FALSE) + { + if (iFileBytesSent > 0) + SendFileStateL(iFileBytesSent); + } + + if( iState == EMessageSent ) + { + switch( iActiveMsgType ) + { + case EMSRPMessage: + { + if( iResponseNeeded ) + { + iState = EWaitingForResponse; + } + else + { + iState = EMessageDone; + } + iMSRPMessageObserver->MessageSendCompleteL(); + break; + } + case EMSRPResponse: + { + iState = EMessageDone; + iMSRPMessageObserver->MessageResponseSendCompleteL(*this); + break; + } + } + //iActiveMsgType = EMSRPNotDefined; + retStatus = MMSRPWriterObserver::EComplete; + } + else if( iState == EInProgress ) + { + retStatus = MMSRPWriterObserver::EPending; + } + else if(iState == EChunkSent) + { + retStatus = MMSRPWriterObserver::EInterrupted; + iState = EIdle; + } + else + { + iMSRPMessageObserver->WriterError(); + } + } + MSRPLOG( "CMSRPMessageHandler::WriteDone exit" ) + return retStatus; + } + + +void CMSRPMessageHandler::CreateByteRangeHeaderL() + { + MSRPLOG( "CMSRPMessageHandler::CreateByteRangeHeaderL enter" ) + CMSRPByteRangeHeader* byteRange = NULL; + + if ( iMessage->IsFile()) + { + byteRange = CMSRPByteRangeHeader::NewL( iBufPosInFile+iStartPosInBuffer+1,KUnknownRange,iFileSize); + + CleanupStack::PushL(byteRange); + iMessage->SetByteRangeHeader( byteRange ); + CleanupStack::Pop(byteRange); + } + else + { + if( !iMessage->ByteRangeHeader() ) + { + if ( iMessage->IsContent() ) + { + byteRange = CMSRPByteRangeHeader::NewL( 1, + iMessage->Content().Length(), iMessage->Content().Length() ); + CleanupStack::PushL(byteRange); + } + else + { + byteRange = CMSRPByteRangeHeader::NewL( 1, 0, 0 ); + CleanupStack::PushL(byteRange); + } + iMessage->SetByteRangeHeader( byteRange ); + CleanupStack::Pop(byteRange); + } + } + MSRPLOG( "CMSRPMessageHandler::CreateByteRangeHeaderL exit" ) + } + + +void CMSRPMessageHandler::CreateTransactionId() + { + MSRPLOG( "CMSRPMessageHandler::CreateTransactionId enter" ) + + TTime now; + now.HomeTime(); + TInt64 seed = now.Int64(); + TInt random = Math::Rand( seed ); + iTransactionId.NumUC( random ); + + MSRPLOG( "CMSRPMessageHandler::CreateTransactionId exit" ) + } + + +void CMSRPMessageHandler::WriteInitialLineToBufferL() + { + MSRPLOG( "CMSRPMessageHandler::WriteInitialLineToBufferL enter" ) + + iBuffer.Append( MSRPStrings::StringF( MSRPStrConsts::EMSRP ).DesC() ); + + iBuffer.Append( KSpaceChar ); + + if (! (iActiveMsgType == EMSRPResponse) ) + { + CreateTransactionId(); + } + + iBuffer.Append( iTransactionId ); + + iBuffer.Append( KSpaceChar ); + + if ( iActiveMsgType == EMSRPMessage ) + { + iBuffer.Append( MSRPStrings::StringF( MSRPStrConsts::ESend ).DesC() ); + } + else if ( iActiveMsgType == EMSRPResponse ) + { + TBuf8< KMaxLengthOfStatusCode > statusCode; + statusCode.NumUC( iResponse->StatusCode() ); + iBuffer.Append( statusCode ); + iBuffer.Append( KSpaceChar ); + iBuffer.Append( iResponse->ReasonPhrase().DesC() ); + } + else + { + User::Leave( KErrArgument ); + } + + iBuffer.Append( KCRAndLF ); + + iState = EInProgress; + MSRPLOG( "CMSRPMessageHandler::WriteInitialLineToBufferL exit" ) + } + + +void CMSRPMessageHandler::WriteHeadersToBufferL() + { + MSRPLOG( "CMSRPMessageHandler::WriteHeadersToBufferL enter" ) + CMSRPMessageBase* messageBase = NULL; + if( iActiveMsgType == EMSRPMessage ) + { + messageBase = iMessage; + } + else if ( iActiveMsgType == EMSRPResponse ) + { + messageBase = iResponse; + } + else + { + User::Leave( KErrArgument ); + } + + // Check if appending headers will exceed max size + + __ASSERT_ALWAYS( messageBase->ToPathHeader(), User::Leave( KErrNotFound ) ); + iBuffer.Append( messageBase->ToPathHeader()->ToTextLC()->Des() ); + CleanupStack::PopAndDestroy(); // above + iBuffer.Append( KCRAndLF ); + + __ASSERT_ALWAYS( messageBase->FromPathHeader(), User::Leave( KErrNotFound ) ); + iBuffer.Append( messageBase->FromPathHeader()->ToTextLC()->Des() ); + CleanupStack::PopAndDestroy(); // above + iBuffer.Append( KCRAndLF ); + + if( iActiveMsgType != EMSRPResponse ) + { + __ASSERT_ALWAYS( messageBase->MessageIdHeader(), User::Leave( KErrNotFound ) ); + iBuffer.Append( messageBase->MessageIdHeader()->ToTextLC()->Des() ); + CleanupStack::PopAndDestroy(); // above + iBuffer.Append( KCRAndLF ); + } + + if( iActiveMsgType == EMSRPMessage ) + { + if ( messageBase->SuccessReportHeader() ) + { + iBuffer.Append( messageBase->SuccessReportHeader()->ToTextLC()->Des() ); + CleanupStack::PopAndDestroy(); // above + iBuffer.Append( KCRAndLF ); + } + + if ( messageBase->FailureReportHeader() ) + { + HBufC8* valueString = messageBase->FailureReportHeader()->ToTextValueLC(); + if ( valueString->Des() == MSRPStrings::StringF( MSRPStrConsts::EYes ).DesC() || + valueString->Des() == MSRPStrings::StringF( MSRPStrConsts::EPartial ).DesC() ) + { + iResponseNeeded = ETrue; + } + CleanupStack::PopAndDestroy(valueString); + + iBuffer.Append( messageBase->FailureReportHeader()->ToTextLC()->Des() ); + CleanupStack::PopAndDestroy(); // above + iBuffer.Append( KCRAndLF ); + } + else + { + iResponseNeeded = ETrue; + } + } + + if( iActiveMsgType != EMSRPResponse ) + { + iBuffer.Append( messageBase->ByteRangeHeader()->ToTextLC()->Des() ); + CleanupStack::PopAndDestroy(); // above + iBuffer.Append( KCRAndLF ); + } + + if( iActiveMsgType == EMSRPMessage ) + { + if ( messageBase->ContentTypeHeader() ) + { + iBuffer.Append( messageBase->ContentTypeHeader()->ToTextLC()->Des() ); + CleanupStack::PopAndDestroy(); // above + iBuffer.Append( KCRAndLF ); + iBuffer.Append( KCRAndLF ); + + if(!iMessage->IsFile() && !iMessage->IsContent()) + { + iBuffer.Append( KCRAndLF ); + } + } + } + + MSRPLOG( "CMSRPMessageHandler::WriteHeadersToBufferL exit" ) + } + + +void CMSRPMessageHandler::WriteFileContentToBufferL() + { + MSRPLOG( "CMSRPMessageHandler::WriteFileContentToBuffer enter" ) + TInt endlineSize = iTransactionId.Length() + KEndlineConstLength; + TInt remBufferSize = iBuffer.MaxLength() - iBuffer.Length() - endlineSize - KCRAndLF().Length(); + TInt chunkLength = iFileBuffer->Length() - iEndPosInBuffer; + + /*if(remBufferSize<0) TODO*/ + if(chunkLength > remBufferSize) + { + iFileBytesSent = remBufferSize; + iBuffer.Append(iFileBuffer->Mid(iEndPosInBuffer, iFileBytesSent)); + iEndPosInBuffer += iFileBytesSent; + if(iInterrupt) + { + WriteEndLineToBuffer(EMessageContinues); + //add chunk entry + CMSRPMessageChunkState* iChunk = CMSRPMessageChunkState::NewL( ); + iChunk->SetStartPos(iBufPosInFile+iStartPosInBuffer); + iChunk->SetEndPos(iBufPosInFile+iEndPosInBuffer-1);//since endpos is pointing to next start pos + iChunk->SetTransactionId(iTransactionId); + iChunkList.Append(iChunk); + + iStartPosInBuffer = iEndPosInBuffer; + iState = EChunkSent; + } + /* else + { + //msg state remains InProgress (in write done return pending) + }*/ + } + else //bytes completed in current file buffer + { + iFileBytesSent = chunkLength; + iBuffer.Append(iFileBuffer->Mid(iEndPosInBuffer, iFileBytesSent)); + iEndPosInBuffer += iFileBytesSent; + iBuffer.Append(KCRAndLF()); + + //add chunk entry + CMSRPMessageChunkState* iChunk = CMSRPMessageChunkState::NewL( ); + iChunk->SetStartPos(iBufPosInFile+iStartPosInBuffer); + iChunk->SetEndPos(iBufPosInFile+iEndPosInBuffer-1); + iChunk->SetTransactionId(iTransactionId); + iChunkList.Append(iChunk); + + if(FillFileBufferL() > 0) + { + //next file buffer has data + WriteEndLineToBuffer(EMessageContinues); + iState = EChunkSent; + } + else + { + WriteEndLineToBuffer(EMessageEnd); + iState = EMessageSent; + } + + } + + iWriteDone = ETrue; + MSRPLOG( "CMSRPMessageHandler::WriteFileContentToBuffer exit" ) + } + + +void CMSRPMessageHandler::WriteContentToBuffer() + { + MSRPLOG( "CMSRPMessageHandler::WriteContentToBuffer enter" ) + + TInt remBufferSize = iBuffer.MaxLength() - iBuffer.Length(); + TInt remContentLength = iContentPtr.Length() + KCRAndLF().Length(); + + if( remContentLength > remBufferSize ) + { + iBuffer.Append( iContentPtr.Mid(0, remBufferSize) ); + iContentPtr.Set(iContentPtr.Mid(remBufferSize)); + iWriteDone = ETrue; + } + else + { + iBuffer.Append( iContentPtr ); + iContentPtr.Set(KNullDesC8); + iBuffer.Append( KCRAndLF ); + } + + MSRPLOG( "CMSRPMessageHandler::WriteContentToBuffer exit" ) + } + + +void CMSRPMessageHandler::WriteEndLineToBuffer(MMSRPMessageHandler::TMsrpMsgEndStatus aEndFlag) + { + MSRPLOG( "CMSRPMessageHandler::WriteEndLineToBuffer enter" ) + + TInt remBufferSize = iBuffer.MaxLength() - iBuffer.Length(); + TInt endlineSize = iTransactionId.Length() + KEndlineConstLength; + + if( endlineSize <= remBufferSize ) + { + iBuffer.Append( KDashLine ); + iBuffer.Append( iTransactionId ); + + if(iActiveMsgType == EMSRPResponse) + { + iBuffer.Append( KMessageEndSign ); + iState = EMessageSent; + } + else + { + if( aEndFlag ) + { + iBuffer.Append( KMessageContinuesSign ); + } + else + { + iBuffer.Append( KMessageEndSign ); + iState = EMessageSent; + } + } + iBuffer.Append( KCRAndLF ); + } + iWriteDone = ETrue; + MSRPLOG( "CMSRPMessageHandler::WriteEndLineToBuffer exit" ) + } + + +TInt CMSRPMessageHandler::ExtractByteRangeParams( TDesC8& aHeaderValue, TInt& aStartPos, TInt& aEndPos, TInt& aTotal ) + { + MSRPLOG( "CMSRPMessageHandler::ExtractByteRangeParams exit" ) + + TChar dashCharacter( KDashCharacter ); + TInt position1 = aHeaderValue.Locate( dashCharacter ); + if ( position1 == KErrNotFound ) + { + // no data + return KErrArgument; + } + TPtrC8 startPosDes = aHeaderValue.Left( position1 ); + TChar divideCharacter( KDividedCharacter ); + TInt position2 = aHeaderValue.Locate( divideCharacter ); + if ( position2 == KErrNotFound ) + { + // no data + return KErrArgument; + } + TPtrC8 endPosDes = aHeaderValue.Mid( position1 + 1, position2 - ( position1 + 1 ) ); + TPtrC8 totalDes = aHeaderValue.Mid( position2 + 1 ); + + aStartPos = TMSRPUtil::ConvertToNumber( startPosDes ); + aEndPos = TMSRPUtil::ConvertToNumber( endPosDes ); + aTotal = TMSRPUtil::ConvertToNumber( totalDes ); + + MSRPLOG( "CMSRPMessageHandler::ExtractByteRangeParams exit" ) + return KErrNone; + } + + +RStringF CMSRPMessageHandler::GetStatusStringL( TUint aStatusCode ) + { + MSRPLOG( "CMSRPMessageHandler::GetStatusString enter" ) + RStringF statusString; + CleanupClosePushL( statusString ); + + switch( aStatusCode ) + { + case CMSRPResponse::EAllOk: + { + statusString = MSRPStrings::StringF( MSRPStrConsts::EAllOk ); + break; + } + case CMSRPResponse::EUnintelligibleRequest: + { + statusString = MSRPStrings::StringF( MSRPStrConsts::EUnintelligibleRequest ); + break; + } + case CMSRPResponse::EActionNotAllowed: + { + statusString = MSRPStrings::StringF( MSRPStrConsts::EActionNotAllowed ); + break; + } + case CMSRPResponse::ETimeout: + { + statusString = MSRPStrings::StringF( MSRPStrConsts::ETimeout ); + break; + } + case CMSRPResponse::EStopSending: + { + statusString = MSRPStrings::StringF( MSRPStrConsts::EStopSending ); + break; + } + case CMSRPResponse::EMimeNotUnderstood: + { + statusString = MSRPStrings::StringF( MSRPStrConsts::EMimeNotUnderstood ); + break; + } + case CMSRPResponse::EParameterOutOfBounds: + { + statusString = MSRPStrings::StringF( MSRPStrConsts::EParameterOutOfBounds ); + break; + } + case CMSRPResponse::ESessionDoesNotExist: + { + statusString = MSRPStrings::StringF( MSRPStrConsts::ESessionDoesNotExist ); + break; + } + case CMSRPResponse::EUnknownRequestMethod: + { + statusString = MSRPStrings::StringF( MSRPStrConsts::EUnknownRequestMethod ); + break; + } + case CMSRPResponse::ESessionAlreadyBound: + { + statusString = MSRPStrings::StringF( MSRPStrConsts::ESessionAlreadyBound ); + break; + } + default: + { + break; + } + } + + CleanupStack::PopAndDestroy( ); + MSRPLOG( "CMSRPMessageHandler::GetStatusString exit" ) + return statusString; + } + + +TUint CMSRPMessageHandler::CheckValidityOfMessage( TMSRPMessageType aMessageType, CMSRPMessageBase* aMessage ) + { + MSRPLOG( "CMSRPMessageHandler::CheckValidityOfMessage enter" ) + + if( aMessageType == EMSRPMessage ) + { + if(!aMessage->MessageIdHeader()) + { + return CMSRPResponse::EUnintelligibleRequest; + } + CMSRPMessage* message = static_cast(aMessage); + if(message->IsContent() && !message->ContentTypeHeader()) + { + return CMSRPResponse::EUnintelligibleRequest; + } + } + + MSRPLOG( "CMSRPMessageHandler::CheckValidityOfMessage exit" ) + return CMSRPResponse::EAllOk; + } + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/CMSRPMsgParser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/CMSRPMsgParser.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,1102 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// INCLUDES + +// CLASS HEADER +#include "CMSRPMsgParser.h" +#include "MSRPCommon.h" + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::NewL +// Static constructor +// ----------------------------------------------------------------------------- +// +/*static*/CMSRPMsgParser* CMSRPMsgParser::NewL(MMSRPParserObserver& aConnection) + { + MSRPLOG( "CMSRPMsgParser::NewL enter" ) + CMSRPMsgParser* self = new (ELeave) CMSRPMsgParser(aConnection ); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + MSRPLOG( "CMSRPMsgParser::NewL exit" ) + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::CMSRPMsgParser +// Constructor +// ----------------------------------------------------------------------------- +// +CMSRPMsgParser::CMSRPMsgParser(MMSRPParserObserver& aConnection) + : iConnection( aConnection ) + { + + } + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::~CMSRPMsgParser +// Destructor +// ----------------------------------------------------------------------------- +// +CMSRPMsgParser::~CMSRPMsgParser() + { + MSRPLOG( "CMSRPMsgParser::~CMSRPMsgParser enter" ) + delete iLocalBuf; + delete iEndToken; + delete iMessage; + iParseBuffers.ResetAndDestroy(); + iParseBuffers.Close(); + MSRPLOG( "CMSRPMsgParser::~CMSRPMsgParser exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::ConstructL +// 2nd phase constructor +// ----------------------------------------------------------------------------- +// +void CMSRPMsgParser::ConstructL() + { + iState = ETitleLine; + //to avoid leak on newl leave + RMsrpBuf buf(iBufPool.ProvideBufferL()); + iLocalBuf = new (ELeave) RMsrpBuf(buf); + //iLocalBuf = new (ELeave) RMsrpBuf(iBufPool.ProvideBufferL()); + iEndToken = HBufC8::NewL(KMSRPEndTokenMax); + } + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::ParseL +// ----------------------------------------------------------------------------- +// +TBool CMSRPMsgParser::ParseL() + { + TMatchType match = EFullMatch; + TBool ret = TRUE; + + /*parse until a parse element spans buffers. + if parse element completes exactly at buffer boundaries, + might end up parsing greater than bufsize+1_element in one runl. + to avoid, use transitioned flag (set in handle full match)*/ + while (match == EFullMatch) + //while (ret == TRUE)/*parse all parseable data*/ + { + MSRPLOG( "CMSRPMsgParser::ParseL enter" ) + if(!iParseBuffers.Count()) + { + MSRPLOG( "CMSRPMsgParser::ParseL exit" ) + return FALSE; + } + + TPtrC8 token(KCRAndLF()); + if (iState == EBody) + { + token.Set(iEndToken->Des()); + } + + TInt matchPos; + match = FindToken(iParseBuffers[0]->Ptr(),token,matchPos); + if(match == EFullMatch) + { + ret = HandleFullMatchL(token, matchPos); + } + else if (match == EPartialMatch) + { + ret = HandlePartialMatchL(token, matchPos); + } + else //if (match == ENoMatch) + { + ret = HandleNoMatchL(token, matchPos); + } + } + MSRPLOG( "CMSRPMsgParser::ParseL exit" ) + return ret; + } + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::HandleFullMatchL +// ----------------------------------------------------------------------------- +// +TBool CMSRPMsgParser::HandleFullMatchL(TPtrC8& aToken, TInt aMatchPos, TBool aCopyToLocal) + { + MSRPLOG( "CMSRPMsgParser::HandleFullMatchL enter" ) + + TPtrC8 buf = iParseBuffers[0]->Ptr().Left(aMatchPos + aToken.Length()); + if(aCopyToLocal) + { + iLocalBuf->Append(buf); + } + else + { + HandleStateL(buf, aMatchPos); + } + + if((aMatchPos + aToken.Length()) != iParseBuffers[0]->Ptr().Length()) + { + iParseBuffers[0]->MsrpMidTPtr(aMatchPos + aToken.Length()); + } + else + { + //transitioned + RMsrpBuf* headBuf = iParseBuffers[0]; + iParseBuffers.Remove(0); + delete headBuf; + if(!iParseBuffers.Count()) + return FALSE; + } + MSRPLOG( "CMSRPMsgParser::HandleFullMatchL exit" ) + return TRUE; + } + + + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::HandlePartialMatchL +// ----------------------------------------------------------------------------- +// +TBool CMSRPMsgParser::HandlePartialMatchL(TPtrC8& aToken, TInt aCurBufMatchPos) + { + MSRPLOG( "CMSRPMsgParser::HandlePartialMatchL enter" ) + TBool ret = TRUE; + TInt matchTokenLen = iParseBuffers[0]->Ptr().Length()- aCurBufMatchPos; + TPtrC8 matchToken = aToken.Left(matchTokenLen); + TPtrC8 remainingToken = aToken.Mid(matchTokenLen); + TPtrC8 emptyToken; + + if(iParseBuffers.Count() < 2) + { + if (iState == EBody && aCurBufMatchPos) + //if some bytes to return in body, return now (xcluding token part) rather than parse again + { + ret = HandleFullMatchL(emptyToken, aCurBufMatchPos);//parse true return nxt parse false + } + return FALSE;//buffer count greater than 0 but content size smaller than complete lexical element + } + + //Look to complete token + TInt nxtBufMatchPos; + TMatchType match; + TPtrC8 headOfNxtBuf = iParseBuffers[1]->Ptr().Left(remainingToken.Length()); + match = FindToken(headOfNxtBuf, remainingToken, nxtBufMatchPos); + + if(nxtBufMatchPos!=0) //nxt buf does not complete token + { + if (iState != EBody) + { + User::LeaveIfError(KErrCorrupt); + } + //false partial alarm for body, dont retain token part + //need to update curbuf as false tokenpart also needs to be returned + aCurBufMatchPos += matchToken.Length(); + //ret = HandleFullMatchL(matchToken, aCurBufMatchPos);//parse true return true + ret = HandleFullMatchL(emptyToken, aCurBufMatchPos); + } + else + { + if(match == EPartialMatch) //completes part token but bytes insufficient + { + if (iState == EBody && aCurBufMatchPos) + { + ret = HandleFullMatchL(emptyToken, aCurBufMatchPos);//parse true ret false + } + return FALSE; + } + else //complete token + { + TBool addToLocal = FALSE; + if(iState != EBody) + { + addToLocal = TRUE; + } + + ret = HandleFullMatchL(matchToken, aCurBufMatchPos, addToLocal); + ret = HandleFullMatchL(remainingToken, nxtBufMatchPos, addToLocal);//if token.length() and matches state token upto length, transition state + //ret cud be false, if nxtbuf exactly completes token + + if(addToLocal == TRUE) + { + HandleStateL(*iLocalBuf, aCurBufMatchPos+nxtBufMatchPos);//nxtBuf==0, just token + iLocalBuf->Zero(); + } + } + } + MSRPLOG( "CMSRPMsgParser::HandlePartialMatchL exit" ) + return ret; + } + + + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::HandleNoMatchL +// ----------------------------------------------------------------------------- +// +TBool CMSRPMsgParser::HandleNoMatchL(TPtrC8& aToken, TInt aCurBufMatchPos) + { + MSRPLOG( "CMSRPMsgParser::HandleNoMatchL enter" ) + + TPtrC8 emptyToken; + TBool ret = FALSE; + + aCurBufMatchPos = iParseBuffers[0]->Ptr().Length(); + + if (iState == EBody /*&& aCurBufMatchPos*/) + { + ret = HandleFullMatchL(emptyToken, aCurBufMatchPos); + } + else if(iParseBuffers.Count() >= 2) + { + //if header find token in nxt buf + TInt nxtBufMatchPos; + TMatchType match; + match = FindToken(iParseBuffers[1]->Ptr(),aToken,nxtBufMatchPos); + + if(match == EFullMatch) + { + ret = HandleFullMatchL(emptyToken, aCurBufMatchPos, TRUE); + ret = HandleFullMatchL(aToken, nxtBufMatchPos, TRUE); + HandleStateL(*iLocalBuf, aCurBufMatchPos+nxtBufMatchPos); + iLocalBuf->Zero(); + } + else if (iParseBuffers.Count()>2) + { + User::LeaveIfError(KErrCorrupt); + } + //else count==2, bytes insufficient in nxt buf, return false + } + MSRPLOG( "CMSRPMsgParser::HandleNoMatchL exit" ) + return ret; + } + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::HandleStateL +// ----------------------------------------------------------------------------- +// +void CMSRPMsgParser::HandleStateL(const TDesC8& aString, TInt aMatchPos) + { + MSRPLOG( "CMSRPMsgParser::HandleStateL enter" ) + switch(iState) + { + case ETitleLine: + HandleTitleLineL(aString, aMatchPos); + break; + + case EToPath: + case EFromPath: + //case EMandatoryHeader: + HandleHeaderL(aString, aMatchPos); + break; + + case EOptionalHeaders: + HandleOptionalHeaderL(aString, aMatchPos); + break; + + case EExtraCRLF: + HandleXtraCrlfL(aString, aMatchPos); + break; + + case EBody: + HandleBodyL(aString, aMatchPos); + break; + + case EEndofEndLine: + HandleEndofEndLineL(aString, aMatchPos); + break; + + default: + User::LeaveIfError(KErrUnknown); + break; + } + MSRPLOG( "CMSRPMsgParser::HandleStateL exit" ) + } + + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::HandleTitleLineL +// ----------------------------------------------------------------------------- +// +void CMSRPMsgParser::HandleTitleLineL(const TDesC8& aString, TInt /*aMatchPos*/) + { + MSRPLOG( "CMSRPMsgParser::HandleTitleLineL enter" ) + TPtrC8 msrp(aString.Left(KMSRP().Length())); + if(msrp.Compare(KMSRP())) + User::LeaveIfError(KErrCorrupt); + if(aString[KMSRP().Length()] != ' ') + User::LeaveIfError(KErrCorrupt); + + TPtrC8 trans_id = aString.Mid(KMSRP().Length()+1); + TInt pos = trans_id.Locate(MSRP_SPACE); + /*if(pos == KErrNotFound) + User::LeaveIfError(KErrCorrupt);*/ + if (pos < KMSRPIDLenMin || pos > KMSRPIDLenMax) + User::LeaveIfError(KErrCorrupt); + trans_id.Set(trans_id.Left(pos)); + + TPtr8 ptr = iEndToken->Des(); + ptr.Zero(); + ptr.Append(KCRAndLF); + ptr.Append(KDashLine()); + ptr.Append(trans_id); + + TPtrC8 method = aString.Mid(KMSRP().Length()+1+trans_id.Length()+1); + pos = method.Locate(MSRP_SPACE); + + if(pos == KErrNotFound) + { + pos = method.Locate(MSRP_CARRIAGE); + + if(pos == KErrNotFound) + User::LeaveIfError(KErrCorrupt); + + method.Set(method.Left(pos)); + + if (!method.Compare(KMSRPSend())) + { + iMessage = CMSRPMessageHandler::NewL(MMSRPIncomingMessage::EMSRPMessage); + } + else if (!method.Compare(KMSRPReport())) + { + iMessage = CMSRPMessageHandler::NewL(MMSRPIncomingMessage::EMSRPReport); + } + else //extn + { + iMessage = CMSRPMessageHandler::NewL(MMSRPIncomingMessage::EMSRPNotDefined); + } + } + else //response + { + TPtrC8 null; + method.Set(method.Left(pos)); + iMessage = CMSRPMessageHandler::NewL(MMSRPIncomingMessage::EMSRPResponse); + iMessage->SetStatusOfResponseL(method, null); + } + iMessage->SetTransactionId(trans_id); + iState = EToPath; + MSRPLOG( "CMSRPMsgParser::HandleTitleLineL exit" ) + } + +#if 0 +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::HandleTitleLineL +// ----------------------------------------------------------------------------- +// +void CMSRPMsgParser::HandleTitleLineL(const TDesC8& aString, TInt /*aMatchPos*/) + { + MSRPLOG( "CMSRPMsgParser::HandleTitleLineL enter" ) + TLex8 lex(aString); + + //MSRP + lex.Mark(); + lex.SkipCharacters(); + if(lex.TokenLength() != 4) + { + User::LeaveIfError(KErrCorrupt); + } + TPtrC8 first_token = lex.MarkedToken(); + if (first_token.Compare(KMSRP())) + { + User::LeaveIfError(KErrCorrupt); + } + + //SP + if(lex.Peek() != MSRP_SPACE) + { + User::LeaveIfError(KErrCorrupt); + } + lex.Inc(); + + //trans-id + lex.Mark(); + lex.SkipCharacters(); + if (lex.TokenLength() < KMSRPIDLenMin || lex.TokenLength() > KMSRPIDLenMax) + { + User::LeaveIfError(KErrCorrupt); + } + + //SP + if(lex.Peek() != MSRP_SPACE) + { + User::LeaveIfError(KErrCorrupt); + } + lex.Inc(); + + TPtrC8 trans_id = lex.MarkedToken(); + TPtr8 ptr = iEndToken->Des(); + ptr.Zero(); + ptr.Append(kEndMarker()); + ptr.Append(trans_id); + + //method + lex.Mark(); + lex.SkipCharacters(); + if(lex.TokenLength() != 0) + { + User::LeaveIfError(KErrCorrupt); + } + TPtrC8 method = lex.MarkedToken(); + + //create msg + //set trans_id + if (!method.Compare(KMSRPSend())) + { + //type = ESend + //set type + } + else if (!method.Compare(KMSRPReport())) + { + //type = EReport + //set type + } + else //if 3 digit string + { + //type = EResponse + //set type + //set status code + + //remaining SP comment\r\n + /*ignore comment*/ + + } + //else extn method + + //remaining \r\n + //TODO: comment, extn method and check remaining bytes is as xpected + + iState = EToPath; + + MSRPLOG( "CMSRPMsgParser::HandleTitleLineL exit" ) + } +#endif + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::HandleHeaderL +// ----------------------------------------------------------------------------- +// +void CMSRPMsgParser::HandleHeaderL(const TDesC8& aString, TInt /*aMatchPos*/) + { + MSRPLOG( "CMSRPMsgParser::HandleHeaderL enter" ) + TInt pos = aString.Locate(MSRP_COLON); + if(pos == KErrNotFound) + User::LeaveIfError(KErrCorrupt); + + TPtrC8 header_name = aString.Left(pos); + TUint8 nxtChar = aString[pos+1]; + + if(nxtChar != MSRP_SPACE) + User::LeaveIfError(KErrCorrupt); + + TPtrC8 header_val = aString.Mid(pos+2); + header_val.Set(header_val.Left(header_val.Length()-2)); + + if(!header_val.Length()) + User::LeaveIfError(KErrCorrupt); + + MMSRPMessageHandler::TMsrpHeaderType headerType = MMSRPMessageHandler::EHeaderUnknown; + if(iState == EToPath) + { + if(header_name.Compare(KMSRPToPath())) + User::LeaveIfError(KErrCorrupt); + headerType = MMSRPMessageHandler::EToPath; + iState = EFromPath; + } + else if(iState == EFromPath) + { + headerType = MMSRPMessageHandler::EFromPath; + if(header_name.Compare(KMSRPFromPath())) + User::LeaveIfError(KErrCorrupt); + iState = EOptionalHeaders; + } + else //find header id + { + if(!header_name.Compare(KMSRPMessageID())) + { + headerType = MMSRPMessageHandler::EMessageId; + } + else if(!header_name.Compare(KMSRPByteRange())) + { + headerType = MMSRPMessageHandler::EByteRange; + } + else if(!header_name.Compare(KMSRPSuccessReport())) + { + headerType = MMSRPMessageHandler::ESuccessReport; + } + else if(!header_name.Compare(KMSRPFailureReport())) + { + headerType = MMSRPMessageHandler::EFailureReport; + } + else if(!header_name.Compare(KMSRPStatus())) + { + headerType = MMSRPMessageHandler::EStatus; + } + else if(!header_name.Compare(KMSRPContentType())) + { + headerType = MMSRPMessageHandler::EContentType; + iState = EExtraCRLF; + } + } + + //message->add_header + TPtrC8 fullHeader(aString); + iMessage->AddHeaderL(headerType, header_val, fullHeader); + //TODO: //only for to-path from-path add_header error + //switch iState = EBody, mode = EError //essentially start looking for end token + //if mode is error don't issue callbacks, on transition from EndofEndLine, + //delete message and switch to normal mode + + MSRPLOG( "CMSRPMsgParser::HandleHeaderL exit" ) + + } + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::HandleOptionalHeaderL +// ----------------------------------------------------------------------------- +// +void CMSRPMsgParser::HandleOptionalHeaderL(const TDesC8& aString, TInt aMatchPos) + { + MSRPLOG( "CMSRPMsgParser::HandleOptionalHeaderL enter" ) + TPtrC8 endTokenwoStartCrlf = (*iEndToken).Mid(KCRAndLF().Length()); + TPtrC8 fullToken(aString.Left(endTokenwoStartCrlf.Length())); + if (fullToken.Compare(endTokenwoStartCrlf)) + { + HandleHeaderL(aString,aMatchPos); + return; + } + //iState = EEndOfEndLine; + aMatchPos -= fullToken.Length(); + HandleEndofEndLineL(aString.Mid(fullToken.Length()),aMatchPos); + MSRPLOG( "CMSRPMsgParser::HandleOptionalHeaderL exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::HandleXtraCrlfL +// ----------------------------------------------------------------------------- +// +void CMSRPMsgParser::HandleXtraCrlfL(const TDesC8& /*aString*/, TInt aMatchPos) + { + MSRPLOG( "CMSRPMsgParser::HandleXtraCrlfL enter" ) + if(aMatchPos) + User::LeaveIfError(KErrCorrupt); + iState = EBody; + MSRPLOG( "CMSRPMsgParser::HandleXtraCrlfL exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::HandleBodyL +// ----------------------------------------------------------------------------- +// +void CMSRPMsgParser::HandleBodyL(const TDesC8& aString, TInt aMatchPos) + { + MSRPLOG( "CMSRPMsgParser::HandleBodyL enter" ) + TPtrC8 token = aString.Mid(aMatchPos); + + //if(!aString.Length()) + // return; + + if(aMatchPos!=0) + { + TPtrC8 content(aString.Left(aMatchPos)); + iMessage->AddContentL(content); + } + + //partial or full match + if(token.Length()) + { + + //if(aMatchPos == 0) + { + //TPtrC8 firstPart = (*iEndToken).Left(token.Length()); + TPtrC8 lastPart = (*iEndToken).Right(token.Length()); + + //if(firstPart == lastPart) + /*Solns: set iFlagFirstPartMatch on first match and then transition + false transition to endline and transition back to body on endline parse error + add initial \r\n (disallowed in trans_id) to searchEndToken on transition to body - + for optional header, token has no init crlf*/ + + + + if (!token.Compare(lastPart)) + { + iState = EEndofEndLine; + } + /*else if(!token.Compare(firstPart)); + else User::LeaveIfError(KErrCorrupt);*/ + } + //else //full token matches + } + MSRPLOG( "CMSRPMsgParser::HandleBodyL exit" ) + return; + } + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::HandleEndofEndLineL +// ----------------------------------------------------------------------------- +// +void CMSRPMsgParser::HandleEndofEndLineL(const TDesC8& aString, TInt aMatchPos) + { + MSRPLOG( "CMSRPMsgParser::HandleEndofEndLineL enter" ) + if(aMatchPos != 1) + User::LeaveIfError(KErrCorrupt); + + MMSRPMessageHandler::TMsrpMsgEndStatus endType = MMSRPMessageHandler::EMessageEnd; + if(aString[0] == MSRP_END) + endType = MMSRPMessageHandler::EMessageEnd; + else if (aString[0] == MSRP_CONTINUE) + endType = MMSRPMessageHandler::EMessageContinues; + else if (aString[0] == MSRP_TERMINATE) + endType = MMSRPMessageHandler::EMessageTerminated; + else + User::LeaveIfError(KErrCorrupt); + + iMessage->EndOfMessageL(endType); + iConnection.ParseStatusL( iMessage, KErrNone); + iMessage = NULL; + + iState = ETitleLine; + MSRPLOG( "CMSRPMsgParser::HandleEndofEndLineL exit" ) + } + + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::FindToken +// ----------------------------------------------------------------------------- +// +CMSRPMsgParser::TMatchType CMSRPMsgParser::FindToken( const TDesC8& aString, const TDesC8& aToken, TInt& aMatchPos) + { + MSRPLOG( "CMSRPMsgParser::FindToken enter" ) + TMatchType ret = ENoMatch; + aMatchPos = KErrNotFound; + if(!aString.Length() || !aToken.Length()) + return ret; + aMatchPos = aString.Find(aToken); + + if(aMatchPos == KErrNotFound) + { + TUint8 lastChar = aString[aString.Length()-1]; + TPtrC8 tempToken; + tempToken.Set(aToken); + + TInt tokenPos = tempToken.LocateReverse(lastChar); + while (tokenPos != KErrNotFound) + { + TPtrC8 headPartofToken = tempToken.Left(tokenPos+1); + TPtrC8 tailPartofString = aString.Right(tokenPos+1); + if(!headPartofToken.Compare(tailPartofString)) + break; + tempToken.Set(tempToken.Left(tokenPos)); //if 0 + tokenPos = tempToken.LocateReverse(lastChar); + } + if(tokenPos != KErrNotFound) + { + ret = EPartialMatch; + aMatchPos = aString.Length() - (tokenPos+1); + } + return ret; + } + MSRPLOG( "CMSRPMsgParser::FindToken exit" ) + return EFullMatch; + } + + +//test cases +//shyamprasad, prasad, xyz, add, dan, shyamprasad +//pr, prasad + +#if 0 +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::ExecuteStateL +// ----------------------------------------------------------------------------- +// +CMSRPMsgParser::TDataCheck CMSRPMsgParser::ExecuteStateL() + { + TDataCheck ret = EWaitForDataPost; + + switch(iState) + { + case ETitleLine: + ret = HandleTitleLineL(); + break; + + case EToPath: + case EFromPath: + case EMandatoryHeader: + ret = HandleMandatoryHeaderL(); + break; + + + case EOptionalHeaders: + //ret = HandleOptionalHeaderL(); + break; + + + case EBody: + + break; + + default: + User::LeaveIfError(KErrUnknown); + break; + } + return ret; + } + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::HandleTitleLineL +// ----------------------------------------------------------------------------- +// +CMSRPMsgParser::TDataCheck CMSRPMsgParser::HandleTitleLineL() + { + TDataCheck ret; + + VARS(lex, transitioned, base_offset, lex_bytesdone); + SET_LEX(lex); + + TOKEN(first_token); + ret = GetNextToken(lex, transitioned, first_token, base_offset, lex_bytesdone); + RET_CHECK(ret,lex,MSRP_SPACE);//if transitioned, set mode local, being done above based on local buf length + LEX_INC_AVAILABLE(lex, lex_bytesdone, transitioned); + + + if(first_token.iLength == 4) + { + FETCH_TOKENSTRING(first_string, first_token, transitioned); + if (first_string.Compare(KMSRP())) + { + User::LeaveIfError(KErrCorrupt); + } + } + else + { + User::LeaveIfError(KErrCorrupt); + } + + TOKEN(trans_id); + ret = GetNextToken(lex, transitioned, trans_id, base_offset, lex_bytesdone); + RET_CHECK(ret,lex,MSRP_SPACE); + LEX_INC_AVAILABLE(lex, lex_bytesdone, transitioned); + + if (trans_id.iLength < KMSRPIDLenMin || trans_id.iLength > KMSRPIDLenMax) + { + User::LeaveIfError(KErrCorrupt); + } + + TOKEN(method); + ret = GetNextToken(lex, transitioned, method, base_offset, lex_bytesdone); + FETCH_TOKENSTRING(method_string, method, transitioned); + + if (!method_string.Compare(KMSRPSend())) + { + RET_CHECK(ret,lex,MSRP_CARRIAGE); + LEX_INC_AVAILABLE(lex, lex_bytesdone, transitioned); + //create msg with correct type + } + else if (!method_string.Compare(KMSRPReport)) + { + RET_CHECK(ret,lex,MSRP_CARRIAGE); + LEX_INC_AVAILABLE(lex, lex_bytesdone, transitioned); + //create msg with correct type + } + else //if 3 digit string + { + RET_CHECK_LENIENT(ret,lex,MSRP_SPACE,val); + if (val) + { + LEX_INC_AVAILABLE(lex, lex_bytesdone, transitioned); + TOKEN(reason); + ret = GetNextToken(lex, transitioned, reason, base_offset, lex_bytesdone); + } + RET_CHECK(ret,lex,MSRP_CARRIAGE); + LEX_INC_AVAILABLE(lex, lex_bytesdone, transitioned); + //create msg with correct type + //set status code == method_string + } + //else extn method, TODO + + //set trans_id + + //EOL data sufficiency and increment + ret = IsDataSufficient(lex, transitioned, base_offset, lex_bytesdone); + RET_CHECK(ret,lex,MSRP_NEWLINE); + LEX_INC_AVAILABLE(lex, lex_bytesdone, transitioned); + + STATE_COMPLETE(EToPath, lex_bytesdone); + return ret; + } + + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::HandleMandatoryHeaderL +// ----------------------------------------------------------------------------- +// +CMSRPMsgParser::TDataCheck CMSRPMsgParser::HandleMandatoryHeaderL() + { + TDataCheck ret; + VARS(lex, transitioned, base_offset, lex_bytesdone); + SET_LEX(lex); + + TOKEN(header); + ret = GetNextToken(lex, transitioned, header, base_offset, lex_bytesdone); + RET_CHECK(ret,lex,MSRP_SPACE); + LEX_INC_AVAILABLE(lex, lex_bytesdone, transitioned); + + TOKEN(header_val); + ret = GetNextToken(lex, transitioned, header_val, base_offset, lex_bytesdone); + RET_CHECK(ret,lex,MSRP_CARRIAGE); + LEX_INC_AVAILABLE(lex, lex_bytesdone, transitioned); + + //EOL data sufficiency and increment + ret = IsDataSufficient(lex, transitioned, base_offset, lex_bytesdone); + RET_CHECK(ret,lex,MSRP_NEWLINE); + LEX_INC_AVAILABLE(lex, lex_bytesdone, transitioned); + + FETCH_TOKENSTRING(header_string, header, transitioned); + FETCH_TOKENSTRING(val_string, header_val, transitioned); + + //check last char is colon and reduce string len by 1 + //HEADER_CHECK(header_string); + + switch (iState) + { + case EToPath: + if (header_string.Compare(KMSRPToPath())) + { + User::LeaveIfError(KErrCorrupt); + } + //AddHeader callback + STATE_COMPLETE(EFromPath, lex_bytesdone); + break; + + case EFromPath: + if (header_string.Compare(KMSRPFromPath())) + { + User::LeaveIfError(KErrCorrupt); + } + //AddHeader callback + STATE_COMPLETE(EMandatoryHeader, lex_bytesdone); + break; + + case EMandatoryHeader: + //Findheaderid and give appropriate callback + STATE_COMPLETE(EOptionalHeaders, lex_bytesdone); + break; + + default: + User::LeaveIfError(KErrUnknown); + break; + } + return ret; + } + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::HandleOptionalHeaderL +// ----------------------------------------------------------------------------- +// +#if 0 +CMSRPMsgParser::TDataCheck CMSRPMsgParser::HandleOptionalHeaderL() + { + //get first token compare against endline + //if yes msg done and handover bodiless msg to conn + //if not, get next token and give header callback + + TDataCheck ret; + VARS(lex, transitioned, base_offset, lex_bytesdone); + SET_LEX(lex); + + TOKEN(header); + ret = GetNextToken(lex, transitioned, header, base_offset, lex_bytesdone); + RET_CHECK(ret,lex,MSRP_SPACE); + LEX_INC_AVAILABLE(lex, lex_bytesdone, transitioned); + + TOKEN(header_val); + ret = GetNextToken(lex, transitioned, header_val, base_offset, lex_bytesdone); + RET_CHECK(ret,lex,MSRP_CARRIAGE); + LEX_INC_AVAILABLE(lex, lex_bytesdone, transitioned); + + //EOL data sufficiency and increment + ret = IsDataSufficient(lex, transitioned, base_offset, lex_bytesdone); + RET_CHECK(ret,lex,MSRP_NEWLINE); + LEX_INC_AVAILABLE(lex, lex_bytesdone, transitioned); + + FETCH_TOKENSTRING(header_string, header, transitioned); + FETCH_TOKENSTRING(val_string, header_val, transitioned); + + //check last char is colon and reduce string len by 1 + HEADER_CHECK(header_string); + + switch (iState) + { + case EToPath: + if (header_string.Compare(KMSRPToPath())) + { + User::LeaveIfError(KErrCorrupt); + } + //AddHeader callback + STATE_COMPLETE(EFromPath, lex_bytesdone); + break; + + case EFromPath: + if (header_string.Compare(KMSRPFromPath())) + { + User::LeaveIfError(KErrCorrupt); + } + //AddHeader callback + STATE_COMPLETE(EMandatoryHeader, lex_bytesdone); + break; + + case EMandatoryHeader: + //Findheaderid and give appropriate callback + STATE_COMPLETE(EOptionalHeaders, lex_bytesdone); + break; + + default: + User::LeaveIfError(KErrUnknown); + break; + } + return ret; + } + +#endif + + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::GetNextToken +// ----------------------------------------------------------------------------- +// +//TBD: convert to macros +CMSRPMsgParser::TDataCheck CMSRPMsgParser::GetNextToken(TLex8& aLex, TBool& aTransitioned, TToken& aToken, TInt& aBaseOffset, TInt& aLexBytesDone) + { + TDataCheck ret = EContinueNormal; + + aLex.Mark(); + aToken.iOffset += aBaseOffset + aLex.MarkedOffset(); + do + { + aLex.SkipCharacters(); + if (aLex.TokenLength() > 0) + { + aLexBytesDone += aLex.TokenLength(); + aToken.iLength += aLex.TokenLength(); + TPtrC8 tokenString = aLex.MarkedToken(); + if(aTransitioned) + { + //TODO: leave or parse error if append not possible + iLocalBuf->Ptr().Append(tokenString); + } + } + ret = IsDataSufficient(aLex, aTransitioned, aBaseOffset, aLexBytesDone); + //if(ret == EContinueTransitioned) aBytesParsed = 0; + } while (ret == EContinueTransitioned); + + return ret; + } + + +// ----------------------------------------------------------------------------- +// CMSRPMsgParser::IsDataSufficient +// not called if in Body, only header data sufficiency check +// ----------------------------------------------------------------------------- +//TBD: convert to macro +CMSRPMsgParser::TDataCheck CMSRPMsgParser::IsDataSufficient(TLex8& aLex, TBool& aTransitioned, TInt& aBaseOffset, TInt& aLexBytesDone) + { + if(aLex.Peek() == 0) + { + /*iParseBuffers[0] being parsed*/ + aBaseOffset += iParseBuffers[0]->Ptr().Length(); + aLexBytesDone = 0; + if(aTransitioned) + { + delete iParseBuffers[0]; + } + else + { + if (iMode == EQueueBuf) + { + /*non collated buffer existence means spanning across buf pools*/ + if (iParseBuffers.Count() < 2) + return EWaitForDataPost; //aLexBytesDone =0, nothing copied to local buf + else if (iSthgParsed) + return EContinueInNextParse; //aLexBytesDone =0 + else + iLocalBuf->Ptr().Append(*iParseBuffers[0]); + } + /*in case of localbuf, we are about to begin parsing first buf and copy tokens*/ + aTransitioned = TRUE; + } + +#if 0 + /*for queuebuf avoid copying till bufpool spanning of a parse element can be confirmed*/ + if (iMode == EQueueBuf) + { + if (!aTransitioned) + { + /*non collated buffer existence means spanning across buf pools*/ + if (iParseBuffers.Count() < 2) + return EWaitForDataPost; //aLexBytesDone =0, nothing copied to local buf + else if (iSthgParsed) + return EContinueInNextParse; //aLexBytesDone =0 + else + { + //copy to local + aTransitioned = TRUE; + iLocalBuf->Ptr().Append(*iParseBuffers[0]); + aBaseOffset += iParseBuffers[0]->Ptr().Length(); + aLexBytesDone = 0; + delete iParseBuffers[0]; + } + } + else //once transitioned tokens are being copied,iParseBuffers[0] being parsed, hence no existence check + { + //only free + aBaseOffset += iParseBuffers[0]->Ptr().Length(); + aLexBytesDone = 0; + delete iParseBuffers[0]; + } + } + else //if (iMode == ELocalBuf) + { + if (!aTransitioned) + { + /*sthg parsed is always false for local buf*/ + /*also if not transitioned in this pass, means count of buffers in queue is atleast 1*/ + /*if (iParseBuffers.Count() < 1) + return EWaitForDataPost; + else if (iSthgParsed) + return EContinueInNextParse;*/ + //no action + aTransitioned = TRUE; + aBaseOffset += iParseBuffers[0]->Ptr().Length(); + aLexBytesDone = 0; + } + else //once transitioned tokens are being copied,iParseBuffers[0] being parsed, hence no existence check + { + //only free + aBaseOffset += iParseBuffers[0]->Ptr().Length(); + aLexBytesDone = 0; + //delete iParseBuffers[0]; + } + } +#endif + if(!iParseBuffers.Count()) + return EWaitForDataPost; //aLexBytesDone = 0 //no rbuf to delete + + //reassign lex to zeroth + aLex.Assign(*iParseBuffers[0]); + + return EContinueTransitioned; + } + return EContinueNormal; + } + +#endif diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/CMSRPParser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/CMSRPParser.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,162 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// INCLUDES + +// CLASS HEADER +#include "CMSRPParser.h" +#include "MSRPCommon.h" + +// ----------------------------------------------------------------------------- +// CMSRPParser::NewL +// Static constructor +// ----------------------------------------------------------------------------- +// +/*static*/MMSRPParser* CMSRPParser::NewL(MMSRPParserObserver& aConnection) + { + MSRPLOG( "CMSRPParser::NewL enter" ) + CMSRPParser* self = new (ELeave) CMSRPParser(aConnection); + CleanupStack::PushL(self); + self->ConstructL(aConnection); + CleanupStack::Pop(self); + MSRPLOG( "CMSRPParser::NewL exit" ) + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPParser::CMSRPParser +// Constructor +// ----------------------------------------------------------------------------- +// +CMSRPParser::CMSRPParser(MMSRPParserObserver& aConnection) + : CActive(CActive::EPriorityStandard), iConnection( aConnection ) + { + CActiveScheduler::Add(this); + } + +// ----------------------------------------------------------------------------- +// CMSRPParser::~CMSRPParser +// Destructor +// ----------------------------------------------------------------------------- +// +CMSRPParser::~CMSRPParser() + { + MSRPLOG( "CMSRPParser::~CMSRPParser enter" ) + Cancel(); + delete iParser; + MSRPLOG( "CMSRPParser::~CMSRPParser exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPParser::ConstructL +// 2nd phase constructor +// ----------------------------------------------------------------------------- +// +void CMSRPParser::ConstructL(MMSRPParserObserver& aConnection) + { + //iState = EIdle; + iParser = CMSRPMsgParser::NewL(aConnection); + } + +// ----------------------------------------------------------------------------- +// CMSRPParser::DoCancel +// Cancels outstanding request. +// ----------------------------------------------------------------------------- +// +void CMSRPParser::DoCancel() + { + MSRPLOG( "CMSRPParser::DoCancel enter" ) + //TRequestStatus* status = &iStatus; + //User::RequestComplete( status, KErrCancel ); + MSRPLOG( "CMSRPParser::DoCancel exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPParser::Parse +// ----------------------------------------------------------------------------- +// +void CMSRPParser::ParseL(RMsrpBuf& aBuf) + { + MSRPLOG( "CMSRPParser::ParseL enter" ) + + if(!IsActive()) + { + TRequestStatus* status = &iStatus; + SetActive(); + User::RequestComplete( status, KErrNone ); + } + + //collate with last element in array, else claim ownership + if(iParser->iParseBuffers.Count()) + { + if(iParser->iParseBuffers[iParser->iParseBuffers.Count()-1]->Collate(aBuf)) + return; + } + + RMsrpBuf* buf = new (ELeave) RMsrpBuf(aBuf); + CleanupDeletePushL(buf); + iParser->iParseBuffers.AppendL(buf); + CleanupStack::Pop( ); + MSRPLOG( "CMSRPParser::ParseL exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPParser::CancelReceiving +// ----------------------------------------------------------------------------- +// +/*void CMSRPParser::CancelReceiving() + { + Cancel(); + }*/ + + +// ----------------------------------------------------------------------------- +// CMSRPParser::RunL +// ----------------------------------------------------------------------------- +// +void CMSRPParser::RunL() + { + MSRPLOG( "CMSRPParser::RunL enter" ) + + TBool reschedule = iParser->ParseL(); + + //count could be > 0 but data could be insufficient to parse + if(reschedule && iParser->iParseBuffers.Count()) + { + TRequestStatus* status = &iStatus; + SetActive(); + User::RequestComplete( status, KErrNone ); + } + MSRPLOG( "CMSRPParser::RunL exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPParser::RunError +// ----------------------------------------------------------------------------- +// +TInt CMSRPParser::RunError(TInt /*aError*/) + { + MSRPLOG( "CMSRPParser::RunError enter" ) + //aError = KErrNone; + //ParseError//non leaving introduce + TRAPD(err,iConnection.ParseStatusL(NULL, KErrCorrupt)); + MSRPLOG( "CMSRPParser::RunError exit" ) + return err; + } + + +// End of File + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/CMSRPReader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/CMSRPReader.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,140 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// INCLUDES + +// CLASS HEADER +#include "CMSRPReader.h" +#include "MSRPCommon.h" + +// ----------------------------------------------------------------------------- +// CMSRPReader::NewL +// Static constructor +// ----------------------------------------------------------------------------- +// +/*static*/MMSRPReader* CMSRPReader::NewL(RSocket& aSocket, MMSRPReaderObserver& aConnection) + { + MSRPLOG( "CMSRPReader::NewL enter" ) + CMSRPReader* self = new (ELeave) CMSRPReader( aSocket, aConnection ); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + MSRPLOG( "CMSRPReader::NewL exit" ) + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPReader::CMSRPReader +// Constructor +// ----------------------------------------------------------------------------- +// +CMSRPReader::CMSRPReader(RSocket& aSocket, MMSRPReaderObserver& aConnection) + : CActive(CActive::EPriorityStandard), iConnection( aConnection ), iSocket(aSocket) + { + CActiveScheduler::Add(this); + } + +// ----------------------------------------------------------------------------- +// CMSRPReader::~CMSRPReader +// Destructor +// ----------------------------------------------------------------------------- +// +CMSRPReader::~CMSRPReader() + { + MSRPLOG( "CMSRPReader::~CMSRPReader enter" ) + Cancel(); + delete iBuf; + MSRPLOG( "CMSRPReader::~CMSRPReader exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPReader::ConstructL +// 2nd phase constructor +// ----------------------------------------------------------------------------- +// +void CMSRPReader::ConstructL() + { + //iState = EIdle; + } + +// ----------------------------------------------------------------------------- +// CMSRPReader::DoCancel +// Cancels outstanding request. +// ----------------------------------------------------------------------------- +// +void CMSRPReader::DoCancel() + { + MSRPLOG( "CMSRPReader::DoCancel enter" ) + iSocket.CancelRecv(); + MSRPLOG( "CMSRPReader::DoCancel exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPReader::Connect +// ----------------------------------------------------------------------------- +// +void CMSRPReader::StartReceivingL(RMsrpBuf aBuf) + { + MSRPLOG( "CMSRPReader::StartReceivingL enter" ) + //claim ownership, + delete iBuf; + iBuf = NULL; + iBuf = new (ELeave) RMsrpBuf(aBuf); + //make sure that iBuf' ptr length is updated and not some local copy + iSocket.RecvOneOrMore( *iBuf, 0, iStatus, iNumberOfBytesRead ); + SetActive(); + MSRPLOG( "CMSRPReader::StartReceivingL exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPReader::IsMessageMSRPReport +// ----------------------------------------------------------------------------- +// +/*void CMSRPReader::CancelReceiving() + { + Cancel(); + }*/ + + +// ----------------------------------------------------------------------------- +// CMSRPReader::RunL +// ----------------------------------------------------------------------------- +// +void CMSRPReader::RunL() + { + MSRPLOG( "CMSRPReader::RunL enter" ) + Deque(); + CActiveScheduler::Add(this); + iConnection.ReadStatusL(*iBuf, iStatus.Int()); + MSRPLOG( "CMSRPReader::RunL exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPReader::RunError +// ----------------------------------------------------------------------------- +// +TInt CMSRPReader::RunError(TInt /*aError*/) + { + MSRPLOG( "CMSRPReader::RunError enter" ) + MSRPLOG( "CMSRPReader::RunError exit" ) + //iBuf cud b invalid, if iBuf alloc leaves + //iConnection.ReadStatus(/**iBuf*/, aError); + return KErrNone; + } + + +// End of File + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/CMSRPScheduler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/CMSRPScheduler.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMSRPScheduler.h" + +// INTERNAL INCLUDES +#include "MSRPCommon.h" +#include "CMSRPServer.h" + +// ================= MEMBER FUNCTIONS ========================================== + +// The class constructor. +CMSRPScheduler::CMSRPScheduler() + { + MSRPLOG( "CMSRPScheduler: CMSRPScheduler::CMSRPScheduler()" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPScheduler::SetServer +// Gives a pointer of the current CMSRPServer instance to the scheduler. +// ----------------------------------------------------------------------------- +// +void CMSRPScheduler::SetServer( CMSRPServer* aServer ) + { + MSRPLOG( "CMSRPScheduler::SetServer enter" ) + iServer = aServer; + MSRPLOG( "CMSRPScheduler::SetServer exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPScheduler::Error +// Overridden to handle leaves in request functions and unexpected situations. +// ----------------------------------------------------------------------------- +// +void CMSRPScheduler::Error( TInt /*aError*/ ) const + { + MSRPLOG( "CMSRPScheduler: CMSRPScheduler::Error enter" ) + if ( iServer->IsActive() ) + { + __DEBUGGER() + } + else + { + // Relay the error code to the client and restart the server. + iServer->ReStart(); + } + MSRPLOG( "CMSRPScheduler: CMSRPScheduler::Error exit" ) + } + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/CMSRPServer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/CMSRPServer.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,196 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMSRPServer.h" + +// INTERNAL INCLUDE FILES +#include "MSRPCommon.h" +#include "MSRPServerCommon.h" +#include "CMSRPServerSession.h" +#include "CMSRPConnectionManager.h" +#include "TStateFactory.h" + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CMSRPServer::CMSRPServer +// Constructor +// ----------------------------------------------------------------------------- +// +CMSRPServer::CMSRPServer() : +CPolicyServer( EPriorityStandard, MSRPServerPolicy, ESharableSessions ) + { + MSRPLOG( "MSRPServer: CMSRPServer::CMSRPServer enter" ) + MSRPLOG( "MSRPServer: CMSRPServer::CMSRPServer exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPServer::ConstructL +// 2nd phase constructor +// ----------------------------------------------------------------------------- +// +void CMSRPServer::ConstructL() + { + MSRPLOG( "MSRPServer: CMSRPServer::ConstructL enter" ) + + //const TInt err( Start( KMSRPServerName ) ); + //__ASSERT_ALWAYS( err == KErrNone, PanicServer( EMSRPServerStartError ) ); + StartL( KMSRPServerName ); + + MSRPLOG( "MSRPServer: CMSRPServer::ConstructL exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPServer::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CMSRPServer* CMSRPServer::NewLC() + { + MSRPLOG( "MSRPServer::NewL enter" ) + + CMSRPServer* self = new( ELeave ) CMSRPServer(); + + CleanupStack::PushL( self ); + self->ConstructL(); + + MSRPLOG( "CMSRPServer::NewL exit" ) + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPServer::~CMSRPServer +// destructor +// ----------------------------------------------------------------------------- +// +CMSRPServer::~CMSRPServer() + { + MSRPLOG( "CMSRPServer::~CMSRPServer enter" ) + + if( iStateFactory ) + { + delete iStateFactory; + iStateFactory = NULL; + } + + delete iConnectionManager; + MSRPLOG( "CMSRPServer::~CMSRPServer exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPServer::NewSessionL +// Creates new session if the clients version number matches with server +// version number +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +CSession2* CMSRPServer::NewSessionL( + const TVersion &aVersion, // Clients version of the server + const RMessage2& /*aMessage*/ ) const // Message + { + MSRPLOG( "CMSRPServer::NewSessionL enter" ) + + // Check we're the right version. + TVersion versionInfo( KMSRPServerMajorVersionNumber, + KMSRPServerMinorVersionNumber, + KMSRPServerBuildVersionNumber ); + + if ( !User::QueryVersionSupported( versionInfo, aVersion ) ) + { + User::Leave( KErrNotSupported ); + } + + // let's create the session + CMSRPServer* self = const_cast< CMSRPServer* >( this ); + CMSRPServerSession* session = + CMSRPServerSession::NewL( *self ); + + MSRPLOG( "CMSRPServer::NewSessionL exit" ) + return session; + } + +// ---------------------------------------------------------------------------- +// CMSRPServer::ConnectionManager +// ---------------------------------------------------------------------------- +// +MMSRPConnectionManager& CMSRPServer::ConnectionManager() const + { + return *iConnectionManager; + } + +CStateFactory& CMSRPServer::StateFactory() const + { + return *iStateFactory; + } + + +// ---------------------------------------------------------------------------- +// CMSRPServer::SessionCreated +// ---------------------------------------------------------------------------- +// +void CMSRPServer::SessionCreated() + { + MSRPLOG2( "CMSRPServer::SessionCreated enter, count = %d", iSessionCount ) + iSessionCount++; + MSRPLOG2( "CMSRPServer::SessionCreated exit, count = %d", iSessionCount ) + } + + +// ---------------------------------------------------------------------------- +// CMSRPServer::SessionCreated +// ---------------------------------------------------------------------------- +// +void CMSRPServer::CreatingSubSessionL( const TUint aIapID ) + { + MSRPLOG( "CMSRPServer::CreatingSubSessionL ") + if ( !iConnectionManager ) + { + iConnectionManager = CMSRPConnectionManager::NewL( aIapID,*this ); + } + + if ( !iStateFactory ) + { + iStateFactory = CStateFactory::NewL( ); + } + MSRPLOG( "CMSRPServer::SubSessionCreated exit") + } + + +// ---------------------------------------------------------------------------- +// CMSRPServer::SessionDeleted +// ---------------------------------------------------------------------------- +// +void CMSRPServer::SessionDeleted() + { + iSessionCount--; + if( !iSessionCount ) + { + delete iConnectionManager; + iConnectionManager = NULL; + CActiveScheduler::Stop(); + } + } + +void CMSRPServer::HandleError(TInt /*aError*/, TInt /*aStatus*/, MMSRPConnection& /*aConnection*/) + { + + // Really no use of the observer. Connection errors should be informed via Connection!! + + } + + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/CMSRPServerSession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/CMSRPServerSession.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,265 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#include "E32cmn.h" + +#include "MSRPCommon.h" +#include "CMSRPServer.h" +#include "CMSRPServerSession.h" +#include "CMSRPServerSubSession.h" +#include + + +CMSRPServerSession::CMSRPServerSession(CMSRPServer& aServer) +: CSession2(), iMSRPServer(aServer), iSubSessionList(_FOFF(CMsrpHandleObj,iLink)) + { + } + + +CMSRPServerSession::~CMSRPServerSession() + { + CMsrpHandleObj* pHandleObj; + TSglQueIter iter(iSubSessionList); + pHandleObj = iter++; + while ( pHandleObj ) + { + iSubSessionList.Remove(*pHandleObj); + delete pHandleObj; + pHandleObj = iter++; + } + + iMSRPServer.SessionDeleted(); + } + + +CMSRPServerSession* CMSRPServerSession::NewLC( CMSRPServer& aServer ) + { + CMSRPServerSession* self = new(ELeave) CMSRPServerSession(aServer); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + + +CMSRPServerSession* CMSRPServerSession::NewL( CMSRPServer& aServer ) + { + CMSRPServerSession* self = CMSRPServerSession::NewLC(aServer); + CleanupStack::Pop(self); + return self; + } + + +void CMSRPServerSession::ConstructL() + { + MSRPLOG( "CMSRPServerSession::ConstructL" ); + iMSRPServer.SessionCreated(); + } + +/* The Client Server Session protocol + MSRP sub session creation and deletion + 1. Client creates a MSRP sub session by sending a code EMSRPCreateSession. + No other parameters are required. + As a result of this the server returns it a handle to a the created sub-session. + The returned handle is used in the client side reflection and is used by the + client sub-session to communicate with the server side subsession. + 2. The Client deletes the MSRP sub session by sending a code EMSRPDeleteSession. + The handle of the sub session to be deleted is send as a argument. + +*/ +void CMSRPServerSession::ServiceL( const RMessage2& aMessage ) + { + /* RProcess proc; + RThread thread; + MSRPLOG2( "CMSRPServerSession::ServiceL... Server Process Priority%d", proc.Priority()); + MSRPLOG2( "CMSRPServerSession::ServiceL... Server Thread Priority%d", thread.Priority());*/ + // Implements + // - Handling of Session requests like Capability Query. + // - Handling of Session requests like Application Capability checks. + // - Creation/Deletion request for MSRP SubSessions. + // - Dispatch of messages to relevant MSRP subsessions. + + MSRPLOG( "CMSRPServerSession::ServiceL() Entered" ); + switch(aMessage.Function()) + { + case EMSRPCreateSubSession: + MSRPLOG( "CMSRPServerSession::ServiceL... EMSRPCreateSubSession" ); + CreateSubSessionL(aMessage); + break; + + case EMSRPCloseSubSession: + MSRPLOG( "CMSRPServerSession::ServiceL... EMSRPCloseSubSession" ); + CloseSubSessionL(aMessage); + break; + + default: + MSRPLOG( "CMSRPServerSession::ServiceL... default" ); + // Message for the subSession + DispatchToSubSessionL(aMessage); + break; + } + + MSRPLOG( "CMSRPServerSession::ServiceL() Exit" ); + + } + + +void CMSRPServerSession::CreateSubSessionL( const RMessage2& aMessage ) + { + MSRPLOG( "Entered createSubSessionL()" ); + + /* First notify the Server so that connections can be started */ + iMSRPServer.CreatingSubSessionL( aMessage.Int0() ); + + CMSRPServerSubSession* subSession = CMSRPServerSubSession::NewL( *this, iMSRPServer.StateFactory()); + CleanupStack::PushL(subSession); + + //check handle doesnt preexist or add current time to handle + //generate new handle + CMsrpHandleObj* handleObj = CMsrpHandleObj::NewL(subSession); + + CleanupStack::Pop(subSession); //Ownership with handleobj + CleanupStack::PushL(handleObj); //dummy push + iSubSessionList.AddLast(*handleObj); //ownership of handle with list + CleanupStack::Pop(handleObj); //dummy pop + + WriteResponseL(aMessage, ESubSessionHandle, handleObj->Handle()); + + + MSRPLOG2("CMSRPServerSession::CreateSubSessionL Created subsession with handle %d", handleObj->Handle()) + aMessage.Complete(KErrNone); + } + + +void CMSRPServerSession::CloseSubSessionL( const RMessage2& aMessage ) + { + MSRPLOG( "Entered deleteSubSessionL()" ); + // Locate the subSession and delete. + TInt handle = aMessage.Int3(); + CMsrpHandleObj* pHandleObj = FindHandle(handle); + + if(!pHandleObj) + { + _LIT(KBadHandle,"Bad Handle"); + aMessage.Panic(KBadHandle,EBadSubsessionHandle); + } + + iSubSessionList.Remove(*pHandleObj); + delete pHandleObj; + aMessage.Complete(KErrNone); + } + + +void CMSRPServerSession::DispatchToSubSessionL( const RMessage2& aMessage ) + { + MSRPLOG( "Entered dispatchToSubSession()" ); + // Get the sub session handle + TInt handle = aMessage.Int3(); + MSRPLOG2( "Received aMessage for subSession ( %d ) ", aMessage.Int3()); + CMsrpHandleObj* pHandleObj = FindHandle(handle); + if(!pHandleObj) + { + _LIT(KBadHandle,"Bad Handle"); + aMessage.Panic(KBadHandle,EBadSubsessionHandle); + } + pHandleObj->Subsession()->ServiceL(aMessage); + + } + + +void CMSRPServerSession::WriteResponseL( const RMessage2& aMessage, + TServerClientResponses aResponseItem, + TInt aValue ) + { + MSRPLOG( "CMSRPServerSession::WriteResponseL..." ); + //Package the interger value and do a write. + TPckg< TInt > valuePackage(aValue); + + aMessage.WriteL(aResponseItem, valuePackage); + } + + +MMSRPConnectionManager& CMSRPServerSession::ConnectionManager() + { + return iMSRPServer.ConnectionManager(); + } + +CMsrpHandleObj* CMSRPServerSession::FindHandle( TInt aHandle ) + { + CMsrpHandleObj* pHandleObj = NULL; + TSglQueIter iter(iSubSessionList); + + pHandleObj = iter++; + while ( pHandleObj ) + { + if(pHandleObj->Compare(aHandle)) + break; + pHandleObj = iter++; + } + return pHandleObj; + } + + + + +// CHandleObj class function definitions + +CMsrpHandleObj* CMsrpHandleObj::NewL( CMSRPServerSubSession* aSubSession) + { + CMsrpHandleObj* self = new(ELeave) CMsrpHandleObj(aSubSession); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + + +CMSRPServerSubSession* CMsrpHandleObj::Subsession() const + { + return iSubSession; + } + + +TUint CMsrpHandleObj::Handle() const + { + return iHandle; + } + + +TBool CMsrpHandleObj::Compare( TUint aHandle ) const + { + if (iHandle == aHandle) + return ETrue; + + return EFalse; + } + + +CMsrpHandleObj::~CMsrpHandleObj() + { + delete iSubSession; + } + + +void CMsrpHandleObj::ConstructL() + { + iHandle = Math::Random(); + } + + +CMsrpHandleObj::CMsrpHandleObj( CMSRPServerSubSession* aSubSession) + { + iSubSession = aSubSession; + } diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/CMSRPServerSubSession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/CMSRPServerSubSession.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,600 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + + +#include "MSRPCommon.h" +#include "MSRPServerCommon.h" +#include "CMSRPServerSubSession.h" +#include "MMSRPConnectionManager.h" +#include "CMSRPServerSession.h" +#include "CMSRPMessageBase.h" +#include "MMSRPConnection.h" +#include "CMSRPMessageHandler.h" +#include "CMSRPResponse.h" +#include "s32mem.h" +#include "CMSRPMessage.h" +#include "TStateFactory.h" +#include "TStates.h" +#include "CMsrpToPathHeader.h" +#include "CMSRPFromPathHeader.h" + + +CRMessageContainer::CRMessageContainer() + { + iStatus = FALSE; + } + +CRMessageContainer::~CRMessageContainer() + { + + } + +TInt CRMessageContainer::Write(TInt aParam,const TDesC8& aDes,TInt aOffset) const + { + // Write the data, change status and complete the RMessage. + return iMsg.Write(aParam, aDes, aOffset); + } + +void CRMessageContainer:: ReadL(TInt aParam,TDes8& aDes,TInt aOffset) const + { + // Write the data, change status and complete the RMessage. + return iMsg.ReadL(aParam, aDes, aOffset); + } + +void CRMessageContainer::Complete(TInt aReason) + { + iStatus = FALSE; + iMsg.Complete(aReason); + } + +TBool CRMessageContainer::Check() + { + return iStatus; + } + +TBool CRMessageContainer::set(const RMessage2& aMessage) + { + if(FALSE == iStatus) + { + iMsg = aMessage; // Exclicit copy. + iStatus = TRUE; + return iStatus; + } + else + { + MSRPLOG("CRMessageContainer::set Error!! Container already full"); + return FALSE; + } + } + +CMSRPServerSubSession* CMSRPServerSubSession::NewL( CMSRPServerSession& aServerSession, CStateFactory& aStateFactory ) + { + CMSRPServerSubSession* self = + CMSRPServerSubSession::NewLC( aServerSession, aStateFactory ); + + CleanupStack::Pop(self); + return self; + } + + +CMSRPServerSubSession* CMSRPServerSubSession::NewLC( CMSRPServerSession& aServerSession,CStateFactory& aStateFactory ) + { + + CMSRPServerSubSession* self = + new (ELeave) CMSRPServerSubSession( aServerSession, aStateFactory ); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + + +CMSRPServerSubSession::CMSRPServerSubSession( CMSRPServerSession& aServerSession,CStateFactory& aStateFactory ) + : iServerSession(aServerSession), iStateFactory(aStateFactory) + + { + } + + +CMSRPServerSubSession::~CMSRPServerSubSession() + { + MSRPLOG("CMSRPServerSubSession::~CMSRPServerSubSession Entered"); + + iState = NULL; + + iOutMsgQ.Destroy(); + iInCommingMsgQ.Destroy(); + iPendingSendMsgQ.Destroy(); + iPendingForDeletionQ.Destroy(); + + QueueLog(); + + if(iCurrentMsgHandler) + { + delete iCurrentMsgHandler; + iCurrentMsgHandler = NULL; + } + + if(iConnection) + { + iConnection->ReleaseConnection(*this); + iConnection = NULL; + } + + if(iLocalSessionID) + { + delete iLocalSessionID; + iLocalSessionID = NULL; + } + + if( iRemoteSessionID ) + { + delete iRemoteSessionID; + iRemoteSessionID = NULL; + } + + if( iReceivedResp ) + { + delete iReceivedResp; + iReceivedResp = NULL; + } + if( iReceiveFileMsgHdler ) + { + delete iReceiveFileMsgHdler; + iReceiveFileMsgHdler = NULL; + } + + MSRPLOG("CMSRPServerSubSession::~CMSRPServerSubSession Exit"); + } + + +void CMSRPServerSubSession::ConstructL( ) + { + // Not the place where this should be done!! + MSRPLOG("CMSRPServerSubSession::ConstructL"); + iState = iStateFactory.getStateL( EIdle ); + iLocalSessionID = CreateSubSessionIDL(); + } + + +HBufC8* CMSRPServerSubSession::CreateSubSessionIDL( ) + { + MSRPLOG("CMSRPServerSubSession::CreateSubSessionIDL"); + HBufC8 *sessID = HBufC8::NewLC(KMSRPSessIdLength); + TInt64 randSeed(Math::Random()); + TInt rand; + + /* Append Random bits using two Random strings */ + rand = Math::Rand(randSeed); + (sessID->Des()).AppendNumFixedWidth(rand,EHex,KMSRPSessIdLength/2); + rand = Math::Rand(randSeed); + (sessID->Des()).AppendNumFixedWidth(rand,EHex,KMSRPSessIdLength/2); + + CleanupStack::Pop(1);// sessID + return sessID; + } + + +TBool CMSRPServerSubSession::ProcessEventL( TMSRPFSMEvent aEvent) + { + // Call the relevant state. Setup Traps for graceful error propagation to the client. + MSRPLOG("CMSRPServerSubSession::ProcessEventL() Entered"); + + QueueLog(); + + iState = iState->EventL(aEvent, this); + + MSRPLOG("CMSRPServerSubSession::ProcessEventL() Exit "); + return TRUE; + } + + +TBool CMSRPServerSubSession::ServiceL( const RMessage2& aMessage ) + { + MSRPLOG("CMSRPServerSubSession::ServiceL()"); + + // Process Client Server functions to FSM Events. + + // Getting rid of the switch for translation. + TMSRPFSMEvent event = (TMSRPFSMEvent) (aMessage.Function() - 2); + + // Store the incomming aMessage to form the context of the state machine. + iClientMessage = &aMessage; + + return ProcessEventL(event); + } + + +MMSRPConnectionManager& CMSRPServerSubSession::ConnectionManager( ) + { + return iServerSession.ConnectionManager(); + } + + +// Implementation of interfaces from MMSRPConnectionObserver. +void CMSRPServerSubSession::ConnectionStateL( TInt /*aNewState*/, TInt /*aStatus*/ ) + { + ProcessEventL(EConnectionStateChangedEvent); + } + + +TBool CMSRPServerSubSession::MessageReceivedL( CMSRPMessageHandler* aMsg ) + { + MSRPLOG("CMSRPServerSubSession::MessageReceivedL - New message received"); + TBool retVal = FALSE; + if(checkMessageForSelfL(aMsg)) + { + iReceivedMsg = aMsg; + ProcessEventL(EMSRPIncomingMessageReceivedEvent); + retVal = TRUE; + } + + return retVal; + } + + +void CMSRPServerSubSession::UnclaimedMessageL( CMSRPMessageHandler* aMsg ) + { + MSRPLOG("CMSRPServerSubSession::UnclaimedMessage - Unclaimed message received!!"); + + if( (aMsg->MessageType() == MMSRPIncomingMessage::EMSRPMessage || + aMsg->MessageType() == MMSRPIncomingMessage::EMSRPNotDefined ) + && EFalse == matchSessionIDL(aMsg->GetIncomingMessage()->ToPathHeader())) + { + TBool sendToClient = aMsg->SendResponseL(this, *iConnection, + CMSRPResponse::ESessionDoesNotExist); + iPendingForDeletionQ.Queue(*aMsg); + } + else + { + delete aMsg; + } + } + + +// Implementation of interface from MMSRPMsgObserver. + +void CMSRPServerSubSession::MessageSendCompleteL() + { + // Called when a message is fully sent out. + ProcessEventL(EMSRPDataSendCompleteEvent); + } + +void CMSRPServerSubSession::MessageResponseSendCompleteL(CMSRPMessageHandler& aMsg) + { + // Called when a message is fully sent out. + // Common event handling. + iReceivedResp = &aMsg; + if(iFileShare) + { + ProcessEventL(EMSRPResponseSendCompleteEvent); + } + if(iPendingForDeletionQ.explicitRemove(iReceivedResp)) + { + delete iReceivedResp; + iReceivedResp = NULL; + } + + } + + +void CMSRPServerSubSession::MessageSendProgressL(TInt aBytesSent, TInt aTotalBytes) + { + iBytesTransferred = aBytesSent; + iTotalBytes = aTotalBytes; + ProcessEventL(EMSRPSendProgressEvent); + } + + +void CMSRPServerSubSession::MessageReceiveProgressL(TInt aBytesRecvd, TInt aTotalBytes) + { + iBytesTransferred = aBytesRecvd; + iTotalBytes = aTotalBytes; + ProcessEventL(EMSRPReceiveProgressEvent); + } + + +void CMSRPServerSubSession::WriterError() + { + + } + + +// Utility Stuff - Common functions used often by States. +void CMSRPServerSubSession::CompleteClient(TInt aReason) + { + iClientMessage->Complete(aReason); + iClientMessage = NULL; + } + +TInt CMSRPServerSubSession::Write(TInt aParam,const TDesC8& aDes) + { + TInt retVal = iClientMessage->Write(aParam, aDes); + return retVal; + } + + +TBool CMSRPServerSubSession::QueueClientSendRequestsL() + { + // Generic function to Queue the client send requests message. Would be used by + // many states to add to the pending client requests queue. + MSRPLOG("CMSRPServerSubSession::QueueClientSendRequestsL"); + + const RMessage2* aMessage = iClientMessage; + iClientMessage = NULL; + + aMessage->ReadL( 0, iSendMSRPdataPckg); + + CMSRPMessageHandler *aMessageHandler + = CMSRPMessageHandler::NewL(this, + iSendMSRPdataPckg().iExtMessageBuffer); + + iPendingSendMsgQ.Queue(*aMessageHandler); + aMessage->Complete( KErrNone ); + return TRUE; + } + + +void CMSRPServerSubSession::NotifyFileReceiveResultToClientL(CMSRPMessageHandler */*msgHandler*/) + { + //TODO + MSRPLOG("CMSRPServerSubSession::NotifyFileReceiveResultToClientL enter"); + iSendResultListenMSRPDataPckg().iStatus = 200; + iSendResultListenMSRPDataPckg().iIsProgress = FALSE; + iResponseListner.Write(0,iSendResultListenMSRPDataPckg); + iResponseListner.Complete( KErrNone ); + MSRPLOG("CMSRPServerSubSession::NotifyFileReceiveResultToClientL exit"); + } + + +void CMSRPServerSubSession::NotifyFileSendResultToClientL(CMSRPMessageHandler */*msgHandler*/) + { + //TODO + MSRPLOG("CMSRPServerSubSession::NotifyFileSendResultToClientL enter"); + iSendResultListenMSRPDataPckg().iStatus = 200; + iSendResultListenMSRPDataPckg().iIsProgress = FALSE; + iResponseListner.Write(0,iSendResultListenMSRPDataPckg); + iResponseListner.Complete( KErrNone ); + MSRPLOG("CMSRPServerSubSession::NotifyFileSendResultToClientL exit"); + } + + +TBool CMSRPServerSubSession::SendProgressToClientL(CMSRPMessageHandler */*msgHandler*/) + { + MSRPLOG("CMSRPServerSubSession::SendProgressToClientL enter"); + iSendResultListenMSRPDataPckg().iStatus = KErrNone; + iSendResultListenMSRPDataPckg().iIsProgress = TRUE; + iSendResultListenMSRPDataPckg().iBytesSent = iBytesTransferred; + iSendResultListenMSRPDataPckg().iTotalBytes = iTotalBytes; + + iResponseListner.Write(0,iSendResultListenMSRPDataPckg); + iResponseListner.Complete( KErrNone ); + + MSRPLOG("CMSRPServerSubSession::SendProgressToClientL exit"); + return TRUE; + } + + +TBool CMSRPServerSubSession::ReceiveProgressToClientL(CMSRPMessageHandler */*msgHandler*/) + { + MSRPLOG("CMSRPServerSubSession::ReceiveProgressToClientL enter"); + iListenMSRPdataPckg().iStatus = KErrNone; + iListenMSRPdataPckg().iIsProgress = TRUE; + iListenMSRPdataPckg().iBytesRecvd = iBytesTransferred; + iListenMSRPdataPckg().iTotalBytes = iTotalBytes; + + iIncommingMessageListner.Write(0,iListenMSRPdataPckg); + iIncommingMessageListner.Complete( KErrNone ); + MSRPLOG("CMSRPServerSubSession::ReceiveProgressToClientL exit"); + return TRUE; + } + + +TBool CMSRPServerSubSession::sendResultToClientL(CMSRPMessageHandler *msgHandler) + { + MSRPLOG("CMSRPServerSubSession::sendResultToClientL"); + HBufC8* messageId = NULL; + TUint i=0; + + // Allocates memory. + TBool error = msgHandler->GetSendResultL( i, messageId ); + + iSendResultListenMSRPDataPckg().iIsProgress = FALSE; + iSendResultListenMSRPDataPckg().iMessageId = *messageId; + iSendResultListenMSRPDataPckg().iStatus = i; + iResponseListner.Write(0,iSendResultListenMSRPDataPckg); + + delete messageId; + iResponseListner.Complete( KErrNone ); + return error; + } + + +TBool CMSRPServerSubSession::sendMsgToClientL(CMSRPMessageHandler *incommingMsgHandler) + { + // Use the client send result listner to respond. + // Extract the data and complete the iIncommingMessageListner. + MSRPLOG("CMSRPServerSubSession::sendMsgToClientL"); + CMSRPMessage* inMsg = incommingMsgHandler->GetIncomingMessage(); + + CBufSeg* buf1 = CBufSeg::NewL( 256 ); // expandsize 256 + CleanupStack::PushL( buf1 ); + RBufWriteStream writeStream( *buf1 ); + CleanupClosePushL( writeStream ); + + inMsg->ExternalizeL( writeStream ); + writeStream.CommitL(); + + iListenMSRPdataPckg().iIsProgress = FALSE; + if ( buf1->Size() > KMaxLengthOfIncomingMessageExt ) + { + // invalid message size + iListenMSRPdataPckg().iStatus = KErrArgument; + } + else + { + buf1->Read( 0, iListenMSRPdataPckg().iExtMessageBuffer, buf1->Size() ); + iListenMSRPdataPckg().iStatus = KErrNone; + } + + CleanupStack::PopAndDestroy(2); // buf1, writestream + + iIncommingMessageListner.Write(0,iListenMSRPdataPckg); + iIncommingMessageListner.Complete(KErrNone); + + return TRUE; + } + +void CMSRPServerSubSession::ReadSendDataPckgL() + { + iClientMessage->ReadL( 0, iSendMSRPdataPckg); + return; + } + +TBool CMSRPServerSubSession::listnerSetupComplete() + { + if(iIncommingMessageListner.Check() && iResponseListner.Check()) + return TRUE; + + return FALSE; + } + +CMSRPServerSubSession::TQueueType CMSRPServerSubSession::getQToProcess() + { + // Check the pending incomming message queue and client request queue and + // decides which to process. + // The longer queue is given a priority. If queues are equal incomming message queue + // is given priority. + + if(iPendingSendMsgQ.Length() > iInCommingMsgQ.Length()) + return TClientQueue; + else + return TInCommingMsgQueue; + } + + +TBool CMSRPServerSubSession::QueuesEmpty() + { + // Returns TRUE if there are no messages to process. + if(iPendingSendMsgQ.isEmpty() && iInCommingMsgQ.isEmpty()) + return TRUE; + else + return FALSE; + } + +TBool CMSRPServerSubSession::informConnectionReadyToClient() + { + // The function informs the Client side that the pending connection request(Connect or Listen) + // is now complete. + + if(EDownstream == iConnDirection) + { + // Case of Connect request. + iConnectionListner.Complete(KErrNone); + } + else + { + // Case of Listen. + iIncommingMessageListner.Complete(KErrNone); + } + return TRUE; + } + +void CMSRPServerSubSession::QueueLog() + { + if(iOutMsgQ.Length() || iInCommingMsgQ.Length() || iPendingSendMsgQ.Length()|| + iPendingForDeletionQ.Length()) + { + // If any of the Queue is not empty. Log a event. + MSRPLOG2("CMSRPServerSubSession::ProcessEventL() Queue iOutMsgQ %d", + iOutMsgQ.Length()); + + MSRPLOG2("CMSRPServerSubSession::ProcessEventL() Queue iInCommingMsgQ %d", + iInCommingMsgQ.Length()); + + MSRPLOG2("CMSRPServerSubSession::ProcessEventL() Queue iPendingSendMsgQ %d", + iPendingSendMsgQ.Length()); + + MSRPLOG2("CMSRPServerSubSession::ProcessEventL() Queue iPendingForDeletionQ %d", + iPendingForDeletionQ.Length()); + } + else + { + MSRPLOG("CMSRPServerSubSession::ProcessEventL() Queue All Empty"); + } + } + + +TBool CMSRPServerSubSession::checkMessageForSelfL(CMSRPMessageHandler *aMsgHandler) + { + MSRPLOG("CMSRPServerSubSession::checkMessageForSelfL"); + CMSRPMessageBase *message = aMsgHandler->GetIncomingResponse(); + if(!message) + { + message = aMsgHandler->GetIncomingMessage(); + } + + if(!message) + return FALSE; + + // Check if the sessionID in the 'To' path matches the LocalSessionID. + if(FALSE == matchSessionIDL(message->ToPathHeader())) + return FALSE; + + // Check if the sessionID in the 'From' path matches the known RemoteSessionID. + return matchSessionIDL(message->FromPathHeader(), FALSE); + } + + +TBool CMSRPServerSubSession::matchSessionIDL(const CMSRPHeaderBase *aPathHeader, TBool local) + { + TBool retVal = FALSE; + + HBufC8* textValue = aPathHeader->ToTextValueLC(); + TPtrC8 receivedSessionID = extractSessionID(*textValue); + + if(local && receivedSessionID == *iLocalSessionID) + retVal = TRUE; + + + if(!local && receivedSessionID == *iRemoteSessionID) + retVal = TRUE; + + CleanupStack::PopAndDestroy(textValue); + + return retVal; + } + + +TPtrC8 CMSRPServerSubSession::extractSessionID(const TDesC8& aPathBuffer) + { + // Extracts the sessionId from aPathBuffer and matches it again + TInt posEndOfSessionString = + aPathBuffer.LocateReverseF(KSemiColonCharacter); + TInt posStartOfSessionString = + aPathBuffer.LocateReverseF(KDividedCharacter) + 1; + + TPtrC8 receivedSessionId = aPathBuffer.Mid(posStartOfSessionString, \ + (posEndOfSessionString - posStartOfSessionString)); + + return receivedSessionId; + } + + +CStateFactory& CMSRPServerSubSession::StateFactory() + { + return iStateFactory; + } + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/CMSRPTimeOutTimer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/CMSRPTimeOutTimer.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// CLASS HEADER +#include "CMSRPTimeOutTimer.h" + +// INTERNAL INCLUDES +#include "MMSRPTimeOutObserver.h" +#include "MsrpCommon.h" + +// ----------------------------------------------------------------------------- +// CMSRPTimeOutTimer::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CMSRPTimeOutTimer* CMSRPTimeOutTimer::NewL( + MMSRPTimeOutObserver& aTimeOutNotify ) + { + CMSRPTimeOutTimer* self = new( ELeave ) CMSRPTimeOutTimer( aTimeOutNotify ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPTimeOutTimer::CMSRPTimeOutTimer +// Constructor. +// ----------------------------------------------------------------------------- +// +CMSRPTimeOutTimer::CMSRPTimeOutTimer( MMSRPTimeOutObserver& aTimeOutNotify ) + : CTimer( EPriorityStandard ), iNotifier( aTimeOutNotify ) + { + } + +// ----------------------------------------------------------------------------- +// CMSRPTimeOutTimer::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CMSRPTimeOutTimer::ConstructL() + { + CTimer::ConstructL(); + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// CMSRPTimeOutTimer::~CMSRPTimeOutTimer +// Destructor. +// ----------------------------------------------------------------------------- +// +CMSRPTimeOutTimer::~CMSRPTimeOutTimer() + { + Cancel(); + } + +// ----------------------------------------------------------------------------- +// CMSRPTimeOutTimer::RunL +// To inform the notifier that xx seconds is up. +// ----------------------------------------------------------------------------- +// +void CMSRPTimeOutTimer::RunL() + { + MSRPLOG( "CMSRPTimeOutTimer::RunL() enter" ) + // Tell the notifier that times out. + iNotifier.TimerExpiredL(); + MSRPLOG( "CMSRPTimeOutTimer::RunL() exit" ) + } + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/CMSRPWriter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/CMSRPWriter.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,231 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// INCLUDES + +// CLASS HEADER +#include "CMSRPWriter.h" +#include "MSRPCommon.h" + +// ----------------------------------------------------------------------------- +// CMSRPParser::NewL +// Static constructor +// ----------------------------------------------------------------------------- +// +/*static*/MMSRPWriter* CMSRPWriter::NewL(RSocket& aSocket, MMSRPWriterErrorObserver& aConnection) + { + MSRPLOG( "CMSRPWriter::NewL enter" ) + CMSRPWriter* self = new (ELeave) CMSRPWriter( aSocket, aConnection ); + CleanupStack::PushL(self); + //self->ConstructL(); + CleanupStack::Pop(self); + MSRPLOG( "CMSRPWriter::NewL exit" ) + return self; + } + +// ----------------------------------------------------------------------------- +// CMSRPWriter::CMSRPWriter +// Constructor +// ----------------------------------------------------------------------------- +// +CMSRPWriter::CMSRPWriter(RSocket& aSocket, MMSRPWriterErrorObserver& aConnection) + : CActive(CActive::EPriorityStandard), iConnection( aConnection ), iSocket(aSocket) + { + CActiveScheduler::Add(this); + } + +// ----------------------------------------------------------------------------- +// CMSRPWriter::~CMSRPWriter +// Destructor +// ----------------------------------------------------------------------------- +// +CMSRPWriter::~CMSRPWriter() + { + MSRPLOG( "CMSRPWriter::~CMSRPWriter enter" ) + Cancel(); + iSendQueue.Reset(); + iSendQueue.Close(); + MSRPLOG( "CMSRPWriter::~CMSRPWriter exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPWriter::ConstructL +// 2nd phase constructor +// ----------------------------------------------------------------------------- +// +/* +void CMSRPWriter::ConstructL() + { + //iWriteIssued = FALSE; + //iState = EIdle; + } +*/ + +// ----------------------------------------------------------------------------- +// CMSRPWriter::DoCancel +// Cancels outstanding request. +// ----------------------------------------------------------------------------- +// +void CMSRPWriter::DoCancel() + { + MSRPLOG( "CMSRPWriter::DoCancel enter" ) + + if(iWriteIssued) + { + MSRPLOG( "CMSRPWriter::write issued cancelled" ) + iSocket.CancelWrite(); + } + else + { + //MSRPLOG( "CMSRPWriter::self complete cancelled" ) + //TRequestStatus* status = &iStatus; + //User::RequestComplete( status, KErrCancel ); + } + MSRPLOG( "CMSRPWriter::DoCancel exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPWriter::Parse +// ----------------------------------------------------------------------------- +// +void CMSRPWriter::RequestSendL(MMSRPWriterObserver& aMsg) + { + MSRPLOG( "CMSRPWriter::RequestSendL enter" ) + iSendQueue.AppendL(&aMsg); + if(!IsActive()) + { + /*avoid invoking send in other active object context*/ + //SendL + TRequestStatus* status = &iStatus; + SetActive(); + User::RequestComplete( status, KErrNone ); + } + MSRPLOG( "CMSRPWriter::RequestSendL exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPWriter::CancelReceiving +// ----------------------------------------------------------------------------- +// +/*void CMSRPWriter::CancelReceiving() + { + Cancel(); + }*/ + + +// ----------------------------------------------------------------------------- +// CMSRPWriter::RunL +// ----------------------------------------------------------------------------- +// +void CMSRPWriter::RunL() + { + MSRPLOG( "CMSRPWriter::RunL enter" ) + + TInt status = iStatus.Int(); + + if(status != KErrNone) + { + //socket error + iConnection.WriteSocketError(status); + return; + } + + if(iWriteIssued) + { + iWriteIssued = FALSE; + MMSRPWriterObserver::TMsgStatus msgState = MMSRPWriterObserver::EComplete; + msgState = iSendQueue[0]->WriteDoneL(status); + + if(msgState != MMSRPWriterObserver::EPending) + { + MMSRPWriterObserver* obs = iSendQueue[0]; + iSendQueue.Remove(0); + if(msgState == MMSRPWriterObserver::EInterrupted) + iSendQueue.AppendL(obs); + } + } + + SendL(); + + MSRPLOG( "CMSRPWriter::RunL exit" ) + } + +// ----------------------------------------------------------------------------- +// CMSRPWriter::RunError +// ----------------------------------------------------------------------------- +// +TInt CMSRPWriter::RunError(TInt aError) + { + MSRPLOG( "CMSRPWriter::RunError enter" ) + MSRPLOG( "CMSRPWriter::RunError exit" ) + /*get send buffer errors shud b handled in SendL + * by deleting msg obs from writer queue, if part of msg written to conn is 0 or complete + * send failed msg error to client in msghandler b4 getsend returns*/ + iConnection.WriteSocketError(aError); + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CMSRPWriter::SendL +// ----------------------------------------------------------------------------- +// +void CMSRPWriter::SendL() + { + TBool interruptSend = FALSE; + + //while(iSendQueue.Count()) + if(iSendQueue.Count()) + { + MMSRPWriterObserver::TWriteStatus ret = MMSRPWriterObserver::EMsrpSocketWrite; + TPtrC8 data(NULL,0); + + if(iSendQueue.Count()>1) + interruptSend = TRUE; + + ret = iSendQueue[0]->GetSendBufferL(data, interruptSend); + + Deque(); + CActiveScheduler::Add(this); + SetActive(); + + if( ret == MMSRPWriterObserver::EMsrpSocketWrite ) //KErrNone == 0 + { + iSocket.Write( data, iStatus ); + iWriteIssued = TRUE; + } + else if (ret == MMSRPWriterObserver::EMsrpAvoidSocketWrite)//EAvoidSocketWrite + { + TRequestStatus* status = &iStatus; + User::RequestComplete( status, KErrNone ); + iWriteIssued = FALSE; + } + + + /* check in run_error: getsendbufferl leaves are recoverable + * if msg state equivalent to nothing written to connection + * ,remove observer and try to recover + * if writedone leaves, then we can be sure that msg state will reflect socket write issued + * and so no attempt will be made to recover + */ + + //iSendQueue.Remove(0); + + } + } + + +// End of File + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/MSRPmain.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/MSRPmain.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,112 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// INTERNAL INCLUDES +#include "MsrpCommon.h" +#include "MSRPServerCommon.h" +#include "CMSRPScheduler.h" +#include "CMSRPServer.h" + + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// PanicServer +// Panics the MSRP Server +// ----------------------------------------------------------------------------- +// +void PanicServer( + TMSRPPanicCodes aPanicCode ) // Panic code + { + MSRPLOG( "MSRPServer: PanicServer enter" ); + User::Panic( KMSRPServerName, aPanicCode ); + MSRPLOG( "MSRPServer: PanicServer exit" ); + } + +// ----------------------------------------------------------------------------- +// StartServerL +// Starts the MSRPServer +// ----------------------------------------------------------------------------- +// +LOCAL_C void StartServerL() + { + MSRPLOG( "MSRPServer: StartServerL enter" ) + + // create server + TFindServer findMsrpServer( KMSRPServerName ); + TFullName pathName; + + // Search for the server. + if ( findMsrpServer.Next( pathName ) != KErrNone ) + { + // Start scheduler and server. + CMSRPScheduler* scheduler = new (ELeave) CMSRPScheduler; + __ASSERT_ALWAYS( scheduler != + NULL, PanicServer( EMSRPServerSchedulerError ) ); + + CleanupStack::PushL( scheduler ); + CActiveScheduler::Install( scheduler ); + + // Rename the thread. + User::RenameThread( KMSRPServerName ); + + // Create the server + CMSRPServer* server = CMSRPServer::NewLC(); + + // The scheduler needs access to the server instance. + //lint -e{613} scheduler cannot be null, due assertion in creation. + scheduler->SetServer( server ); + + // client alert + RProcess::Rendezvous( KErrNone ); + + // start fielding requests from clients + CActiveScheduler::Start(); // codescanner::activestart + + // finished when the scheduler stops + CleanupStack::PopAndDestroy( 2 ); // scheduler, server, codescanner::cleanup + } + else + { + // already exists + MSRPLOG( "MSRPServer: MSRPServer already running" ) + User::Leave( KErrAlreadyExists ); + } + + MSRPLOG( "MSRPServer: StartServerL exit" ) + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// E32Main implements the executable entry function. +// Target type of the is EXE. +// Creates a cleanup stack and runs the server. +// ----------------------------------------------------------------------------- +// +GLDEF_C TInt E32Main() + { + __UHEAP_MARK; + + // Get a new clean-up stack. + CTrapCleanup* cleanup = CTrapCleanup::New(); + TRAPD( error, StartServerL() ); + delete cleanup; + __UHEAP_MARKEND; + return error; + } + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/TMSRPUtil.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/TMSRPUtil.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +// INCLUDES +#include + +// CLASS HEADER +#include "TMSRPUtil.h" + +// INTERNAL INCLUDES +#include "MsrpCommon.h" + +// ----------------------------------------------------------------------------- +// TMSRPUtil::ConvertToNumberL +// ----------------------------------------------------------------------------- +// +TInt TMSRPUtil::ConvertToNumber( const TDesC8& aString ) + { + // checking for special characters: + // Unknown byte range end + if ( aString == KAsterisk ) + { + // Range unknown + return KUnknownRange; + } + TLex8 numberToConvert( aString ); + TUint convertedNumber( 0 ); + numberToConvert.Val( convertedNumber, EDecimal ); + + return convertedNumber; + } + +// ----------------------------------------------------------------------------- +// CMSRPListeners::ExractSesssionIdFromToPath +// ----------------------------------------------------------------------------- +// +HBufC8* TMSRPUtil::ExtractSessionIdFromPathLC( TDesC8& aMsrpPath ) + { + // parsing the descriptor URL + // first is the scheme + + TUriParser8 parser; + User::LeaveIfError( parser.Parse( aMsrpPath ) ); + + if(!parser.IsPresent(EUriPort)) + { + User::Leave(KErrArgument); + } + + const TDesC8& remPort = parser.Extract( EUriPort ); + + TUint portNum; + TLex8 portLex(remPort); + User::LeaveIfError( portLex.Val( portNum ) ); //Just validation.Port number is not used + + + if(!parser.IsPresent(EUriPath)) + { + User::Leave(KErrArgument); + } + + const TDesC8& remotePath = parser.Extract( EUriPath ); + + TInt loc = remotePath.Find( KSemicolon ); + if(loc == KErrNotFound) + { + User::Leave(KErrArgument); + } + + TPtrC8 sessionIDPtr; + sessionIDPtr.Set( remotePath.Mid( 1, loc-1) ); + User::LeaveIfError(!sessionIDPtr.Length()?KErrArgument:KErrNone); //No Session ID. ; at the beginning. + + TInt loc2 = remotePath.LocateReverse(KSemiColonCharacter); + User::LeaveIfError(loc2!=loc?KErrArgument:KErrNone); //Two ; in Path + + HBufC8* sessionId = HBufC8::NewLC( sessionIDPtr.Length()); + *sessionId = sessionIDPtr; + + return sessionId; + } + +// End of File diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/TStateFactory.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/TStateFactory.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#include "TStateFactory.h" + +#define ADD_STATE_TO_ARRAY(state) \ + {\ + CleanupStack::PushL( state ); \ + iStateArray.InsertL( state, state->identity() ); \ + CleanupStack::Pop( state ); \ + } + +CStateFactory* CStateFactory::NewL() + { + CStateFactory* factory = CStateFactory::NewLC(); + CleanupStack::Pop( factory ); + return factory; + } + +CStateFactory* CStateFactory::NewLC() + { + CStateFactory* factory = new ( ELeave ) CStateFactory; + CleanupStack::PushL( factory ); + factory->ConstructL(); + return factory; + } + +void CStateFactory::ConstructL( ) + { + TStateBase *state; + + state = new ( ELeave ) TStateIdle; + ADD_STATE_TO_ARRAY( state ); + + state = new ( ELeave ) TStateConnecting; + ADD_STATE_TO_ARRAY( state ); + + state = new ( ELeave ) TStateWaitForClient; + ADD_STATE_TO_ARRAY( state ); + + state = new ( ELeave ) TStateActive; + ADD_STATE_TO_ARRAY( state ); + + state = new ( ELeave ) TStateActiveSend; + ADD_STATE_TO_ARRAY( state ); + + state = new ( ELeave ) TStateFileShare; + ADD_STATE_TO_ARRAY( state ); + + state = new ( ELeave ) TStateError; + ADD_STATE_TO_ARRAY( state ); + } + +CStateFactory::CStateFactory() + { + } + +CStateFactory::~CStateFactory() + { + iStateArray.ResetAndDestroy(); + iStateArray.Close(); + } + +TStateBase* CStateFactory::getStateL(TStates aState) + { + return iStateArray[aState]; + } + diff -r f1578314b8da -r 505ad3f0ce5c Msrp/MsrpServer/src/TStates.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/MsrpServer/src/TStates.cpp Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,1147 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#include "TStates.h" +#include "TStateFactory.h" + +#include "CMSRPServerSubSession.h" +#include "CMSRPMessageHandler.h" +#include "CMSRPResponse.h" +#include "MMSRPConnection.h" + + +TStateBase* TStateBase::HandleStateErrorL(CMSRPServerSubSession *aContext) + { + // Error handling for invalid events received in a given state. + if(NULL != aContext->iClientMessage) + { + // Complete the client with a error. + // Set this to iClientReceivedEventData to NULL. + aContext->CompleteClient(KErrNone); + } + + if(NULL != aContext->iReceivedMsg) + { + // !! Handle + } + return aContext->StateFactory().getStateL(EIdle); + } + +TStateBase * TStateFileShare::processIncommingMessageL(CMSRPServerSubSession *aContext, + CMSRPMessageHandler* incommingMsg) + { + MSRPLOG("TStateFileShare::processIncommingMessage Enter!"); + TStateBase *state = this; + CMSRPMessageHandler *incommingMsgHandler; + if(NULL != incommingMsg) + { + aContext->iInCommingMsgQ.Queue(*incommingMsg); + } + incommingMsgHandler = aContext->iInCommingMsgQ.DeQueue(); + + while (incommingMsgHandler && state == this) + { + if(MMSRPIncomingMessage::EMSRPResponse == incommingMsgHandler->MessageType()) + { + state = handlesResponseL(aContext,incommingMsgHandler); + } + else + { + state = handleRequestsL(aContext,incommingMsgHandler); + } + incommingMsgHandler = aContext->iInCommingMsgQ.DeQueue(); + } + + MSRPLOG("TStateFileShare::processIncommingMessage Exit!"); + return state; + } + +TStateBase* TStateBase::processIncommingMessageL(CMSRPServerSubSession *aContext, + CMSRPMessageHandler* incommingMsg) + { + MSRPLOG("TStateBase::processIncommingMessage Entered!"); + CMSRPMessageHandler *incommingMsgHandler; + if(NULL == incommingMsg) + { + incommingMsgHandler = aContext->iInCommingMsgQ.DeQueue(); + } + else + { + incommingMsgHandler = incommingMsg; + } + + if(incommingMsgHandler) + { + if(MMSRPIncomingMessage::EMSRPResponse == incommingMsgHandler->MessageType()) + { + return handlesResponseL(aContext,incommingMsgHandler); + } + else + { + return handleRequestsL(aContext,incommingMsgHandler); + } + } + else + return NULL; + } + +TStateBase* TStateBase::processPendingMessageQL(CMSRPServerSubSession *aContext) + { + MSRPLOG("TStateBase::processPendingMessagesL Entered!"); + CMSRPMessageHandler *msgHandler; + + msgHandler = aContext->iPendingSendMsgQ.DeQueue(); + msgHandler->SendMessageL(*aContext->iConnection); + + // Shift this to Outgoing Queue. + aContext->iCurrentMsgHandler = msgHandler; + return aContext->StateFactory().getStateL(EActiveSend); + } + +TStateBase* TStateBase::handlesResponseL(CMSRPServerSubSession *aContext, + CMSRPMessageHandler *incommingMsgHandler) + { + TStateBase *nextState; + MSRPLOG("TStateBase::handlesResponseL Entered!"); + + // Search the outgoing Queue to find the owner of the owner of this response. + CMSRPMessageHandler *outgoingMsgHandler = + aContext->iOutMsgQ.getMatch(incommingMsgHandler); + + if(NULL == outgoingMsgHandler) + { + // No outgoingMsgHandler to match the received response. Stray response. + MSRPLOG("TStateBase::handlesResponseL() Received Stray Response!!"); + MSRPLOG("TStateBase::handlesResponseL() No Outgoing message handler found"); + nextState = this; + } + else + { + TBool error = 0; + CleanupStack::PushL(incommingMsgHandler); + TBool sendResult = outgoingMsgHandler->ConsumeResponseL(*incommingMsgHandler); + + if( sendResult ) + { + error = aContext->sendResultToClientL(outgoingMsgHandler); + } + + if(outgoingMsgHandler->IsMessageComplete()) + { + aContext->iOutMsgQ.explicitRemove(outgoingMsgHandler); + delete outgoingMsgHandler; + } + + CleanupStack::Pop(incommingMsgHandler); + if( error ) + { + nextState = aContext->StateFactory().getStateL(EError); + } + else + { + nextState = aContext->StateFactory().getStateL(EWaitForClient); + } + } + + delete incommingMsgHandler; + + MSRPLOG("TStateBase::handlesResponseL Exit!"); + return nextState; + } + +TStateBase* TStateBase::handleRequestsL(CMSRPServerSubSession *aContext, + CMSRPMessageHandler *incommingMsgHandler) + { + MMSRPIncomingMessage::TMSRPMessageType msgType = incommingMsgHandler->MessageType(); + + if(MMSRPIncomingMessage::EMSRPMessage == msgType) // SEND request + { + MSRPLOG("SEND request received"); + TBool sendToClient = incommingMsgHandler->SendResponseL(aContext, + *aContext->iConnection, 0); + if(sendToClient) + { + aContext->sendMsgToClientL(incommingMsgHandler); + } + aContext->iPendingForDeletionQ.Queue(*incommingMsgHandler); + return aContext->StateFactory().getStateL(EWaitForClient); + } + else if(MMSRPIncomingMessage::EMSRPReport == msgType) // Drop Reports + { + MSRPLOG("Reports not supported!!"); + delete incommingMsgHandler; + return this; + } + else // It is an unrecognized request eg. AUTH + { + MSRPLOG("Unrecognized request received"); + TBool sendToClient = incommingMsgHandler->SendResponseL(aContext, + *aContext->iConnection, CMSRPResponse::EUnknownRequestMethod); + aContext->iPendingForDeletionQ.Queue(*incommingMsgHandler); + return aContext->StateFactory().getStateL(EWaitForClient); + } + } + +TStateBase* TStateBase::handleClientListnerCancelL(CMSRPServerSubSession * aContext, + TMSRPFSMEvent aEvent) + { + if(aEvent == EMSRPCancelReceivingEvent) + { + // Confirm completion of the Cancel Request. + aContext->CompleteClient(KErrNone); + + // Complete the Listner if that is active. + if(aContext->iIncommingMessageListner.Check()) + aContext->iIncommingMessageListner.Complete(KErrNone); + } + + if(aEvent == EMSRPCancelSendRespListeningEvent) + { + // Confirm completion of the Cancel Request. + aContext->CompleteClient(KErrNone); + + // Complete the Listner if that is active. + if(aContext->iResponseListner.Check()) + aContext->iResponseListner.Complete(KErrNone); + } + + return aContext->StateFactory().getStateL(EWaitForClient); + } + +TStateBase* TStateBase::handleConnectionStateChangedL(CMSRPServerSubSession *aContext) + { + TStateBase* state = NULL; + TInt iConnectionEvent = aContext->iConnection->getConnectionState(); + + MSRPLOG2("handleConnectionStateChanged::Connection Event %d \n",iConnectionEvent ); + + switch(iConnectionEvent) + { + case -1: // Error Scenario + state = handleConnectionErrorsL(aContext); + break; + + case 1: + case 2: + MSRPLOG("handleConnectionStateChanged::Connection in Progress \n"); + state = this; + break; + + case 3: + // Connected. + MSRPLOG("handleConnectionStateChanged: Connected now." ); + aContext->informConnectionReadyToClient(); + state = aContext->StateFactory().getStateL(EWaitForClient); + break; + + case 4: + case 5: + MSRPLOG("handleConnectionStateChanged: TimeOut now." ); + if(EDownstream == aContext->iConnDirection) + aContext->iConnectionListner.Complete(-33); // TODO : Change to query the exact erorr code from the connection. + else + aContext->iIncommingMessageListner.Complete(-33); // TODO : Change to query the exact erorr code from the connection. + + state = aContext->StateFactory().getStateL(EWaitForClient); + break; + + case 0: + // Not Connected. + MSRPLOG("handleConnectionStateChanged: TimeOut now." ); + state = this; + break; + } + + return state; + } + +TStateBase* TStateBase::handleConnectionErrorsL(CMSRPServerSubSession *aContext) + { + TStateBase* state; + if(TRUE == aContext->iConnectionListner.Check()) + { + // Have a connection listner to inform connection errors. + // This scenario happens where there is a connection error during "Connect" + + aContext->iConnectionListner.Complete(KErrCouldNotConnect); // TODO : Change to query the exact erorr code from the connection. + aContext->iConnection->ReleaseConnection(*aContext); + aContext->iConnection = NULL; + state = aContext->StateFactory().getStateL(EWaitForClient); + } + else + { + // If do not have a connection listner. + // This is a case where a established connection(connect/listen) + // is now reporting a Error. + + // ConnectionErrors in the current scheme of things will be reported via + // iIncommingMessageListner. + + if(!aContext->iIncommingMessageListner.Check()) + { + // Case where the subsession is waiting for the Client subsessions + // to provide it with listner to reports issues on. + // Just move to the EIdle state. EIdle is the not connected state. + + // The connection error here will be reported from the TIdle state. + + state = aContext->StateFactory().getStateL(EIdle); + } + else + { + aContext->iIncommingMessageListner.Complete(KErrDisconnected); + aContext->iConnection->ReleaseConnection(*aContext); + aContext->iConnection = NULL; + state = aContext->StateFactory().getStateL(EIdle); + } + } + return state; + } + +TStateBase* TStateBase::handleQueuesL(CMSRPServerSubSession *aContext) + { + TStateBase * state; + + if( aContext->QueuesEmpty() ) + { + state = aContext->StateFactory().getStateL( EActive ); + } + else + { + if( CMSRPServerSubSession::TInCommingMsgQueue == + aContext->getQToProcess() ) + state = processIncommingMessageL( aContext ); + else + state = processPendingMessageQL( aContext ); + } + + return state; + } + +TStates TStateIdle::identity() + { + return EIdle; + } + +TStateBase* TStateIdle::EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext) + { + // TStateIdle is a state where the subsession is waiting to get connected. + // It is the first state which is entered post sub-session creation. + // Also it is the state that is entered in case there is of a connection error. + + // It may be possible that the client could not be informed about the + // connection error. Thus any client listner setup events will inform the client about + // the current disconnected state. + + // Any existing queues of received messages, received client send requests would be + // retained as it is. Any events for send messages received from the client + // would be queued up. + + // An event from the connection layer is considered invalid as the connection is + // assumed to be dead. Such events will result in a error report being published. + + MSRPLOG2("Entered TStateIdle Event %d",aEvent); + TStateBase* state; + + switch(aEvent) + { + case ELocalMSRPPathEvent: + state = handleLocalMSRPPathRequestL(aContext); + break; + + case EMSRPConnectEvent: + aContext->iConnDirection = EDownstream; + state = handleConnectRequestL(aContext); + break; + + case EMSRPListenEvent: + aContext->iConnDirection = EUpstream; + state = handleListenRequestL( aContext ); + break; + + case EMSRPListenMessagesEvent: + case EMSRPListenSendResultEvent: + // A MSRP Connection error code would be more appropriate here. + aContext->CompleteClient(KErrCouldNotConnect); + state = this; + break; + + case EMSRPCancelReceivingEvent: + case EMSRPCancelSendRespListeningEvent: + state = handleClientListnerCancelL(aContext, aEvent); + break; + + case EConnectionStateChangedEvent: + state = handleConnectionStateChangedL(aContext); + break; + + default: + // Any such error usually a client/server protocol voilation. + // A bug to fix. + MSRPLOG2("TStateIdle::EventL :: Err!! Invalid state to have received %d",aEvent); + state = HandleStateErrorL(aContext); + break; + } + return state; + } + +TStateBase* TStateIdle::handleLocalMSRPPathRequestL( CMSRPServerSubSession *aContext) + { + // The function is reponsible for contructing a Local MSRP path and returning it to the + // client. + // path:msrp://atlanta.example.com:7654/jshA7weztas;tcp + + // !! The current implementation should change to fully construct a MSRP path in the + // subsessoin and send back the result as path buffer. Right now this done in the client. !! + + MSRPLOG("TStateIdle::HandleLocalPathRequestL()"); + + TInetAddr localAddr; + aContext->ConnectionManager().ResolveLocalIPAddressL( localAddr ); + localAddr.Output(aContext->iLocalHost); + + aContext->iLocalPathMSRPDataPckg().iLocalHost.Copy( aContext->iLocalHost ); + aContext->iLocalPathMSRPDataPckg().iSessionID = *(aContext->iLocalSessionID); + + TInt reason = aContext->Write(0, aContext->iLocalPathMSRPDataPckg); + aContext->CompleteClient(KErrNone); + + return this; // No state change. + } + +TStateBase* TStateIdle::handleConnectRequestL(CMSRPServerSubSession *aContext) + { + + if(!aContext->iConnectionListner.set(*(aContext->iClientMessage))) + { + MSRPLOG("TStateIdle::handleConnectRequestL() iConnectionListner is already setup"); + MSRPLOG("TStateIdle::handleConnectRequestL() Invalid state to setup for ConnectionListner"); + return HandleStateErrorL(aContext); + } + aContext->iClientMessage = NULL; + + aContext->iConnectionListner.ReadL( 0, aContext->iConnectMSRPdataPckg ); + + aContext->iRemoteHost = aContext->iConnectMSRPdataPckg().iRemoteHost; + aContext->iRemotePort = aContext->iConnectMSRPdataPckg().iRemotePort; + + aContext->iRemoteSessionID = + HBufC8::NewL( aContext->iConnectMSRPdataPckg().iRemoteSessionID.Length()); + + *(aContext->iRemoteSessionID) = + aContext->iConnectMSRPdataPckg().iRemoteSessionID; + + // Request for a Connection. + MMSRPConnection &connection = + aContext->ConnectionManager().getConnectionL( + aContext->iRemoteHost + ,aContext->iRemotePort); + aContext->iConnection = &connection; + + TBool connReady = initializeConnectionL(aContext); + + if(!connReady) + { + MSRPLOG("TStateIdle:: Transtion to State EConnecting" ); + return aContext->StateFactory().getStateL(EConnecting); + } + else + { + MSRPLOG("TStateIdle:: Transtion to State EConnecting" ); + aContext->informConnectionReadyToClient(); + return aContext->StateFactory().getStateL(EWaitForClient); + } + } + +TStateBase* TStateIdle::handleListenRequestL(CMSRPServerSubSession *aContext) + { + if(!aContext->iIncommingMessageListner.set(*(aContext->iClientMessage))) + { + MSRPLOG("TStateWaitForClient::EventL iIncomming listner is already setup"); + MSRPLOG("TStateWaitForClient::EventL Invalid state to setup a listner"); + return HandleStateErrorL(aContext); + } + aContext->iClientMessage = NULL; + aContext->iIncommingMessageListner.ReadL( 0, aContext->iListenMSRPdataPckg ); + + aContext->iRemoteHost = aContext->iListenMSRPdataPckg().iRemoteHost; + aContext->iRemotePort = aContext->iListenMSRPdataPckg().iRemotePort; + aContext->iRemoteSessionID = + HBufC8::NewL( aContext->iListenMSRPdataPckg().iRemoteSessionID.Length()); + + *(aContext->iRemoteSessionID) = + aContext->iListenMSRPdataPckg().iRemoteSessionID; + + // Request for a Connection. + MMSRPConnection &connection = + aContext->ConnectionManager().getConnectionL( + aContext->iRemoteHost + ,aContext->iRemotePort); + aContext->iConnection = &connection; + + TBool connReady = initializeConnectionL(aContext); + + if(!connReady) + { + MSRPLOG("TStateIdle:: Transtion to State EConnecting" ); + return aContext->StateFactory().getStateL(EConnecting); + } + else + { + MSRPLOG("TStateIdle:: Transtion to State EConnecting" ); + aContext->informConnectionReadyToClient(); + return aContext->StateFactory().getStateL(EWaitForClient); + } + } + +TBool TStateIdle::initializeConnectionL(CMSRPServerSubSession *aContext) + { + // Connect or Listen on Connection. + // Return status based on connection is ready for use or not. + TBool retVal = FALSE; + + if(EDownstream == aContext->iConnDirection) + { + if(3 == aContext->iConnection->ConnectL(*aContext)) + retVal = TRUE; + } + else + { + if(3 == aContext->iConnection->ListenL(*aContext)) + retVal = TRUE; + } + + return retVal; + } + +TStates TStateConnecting::identity() + { + return EConnecting; + } + +TStateBase* TStateConnecting::EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext) + { + MSRPLOG2("Entered TStateConnecting Event %d",aEvent); + TStateBase *state; + + switch(aEvent) + { + case EConnectionStateChangedEvent: + state = handleConnectionStateChangedL(aContext); + break; + + default: + MSRPLOG2("TStateConnecting::EventL :: Err!! Invalid state to have received %d", + aEvent); + state = HandleStateErrorL(aContext); + break; + } + + return state; + } + +TStateBase* TStateWaitForClient::fileSendCompleteL(CMSRPServerSubSession *aContext) + { + CMSRPMessageHandler *outgoingMessageHandler = aContext->iOutMsgQ.getHead(); + + if( outgoingMessageHandler && outgoingMessageHandler->IsMessageComplete() ) + { + aContext->iOutMsgQ.explicitRemove(outgoingMessageHandler); + delete outgoingMessageHandler; + aContext->iSendCompleteNotify = TRUE; + } + return aContext->StateFactory().getStateL( EWaitForClient ); + } + +TStateBase * TStateWaitForClient::handleResponseSentL( CMSRPServerSubSession *aContext) + { + CMSRPMessageHandler *oriMessageHandler = aContext->iReceiveFileMsgHdler; + oriMessageHandler->UpdateResponseStateL(aContext->iReceivedResp); + if(oriMessageHandler->FileTransferComplete() ) + { + aContext->iReceiveCompleteNotify = TRUE; + } + + return aContext->StateFactory().getStateL(EWaitForClient); + } + +TStates TStateWaitForClient::identity() + { + return EWaitForClient; + } + +TStateBase* TStateBase::handleSendFileL(CMSRPServerSubSession *aContext) + { + MSRPLOG("TStateBase::handleSendFileL() enter"); + aContext->ReadSendDataPckgL(); + CMSRPMessageHandler *aMessageHandler = CMSRPMessageHandler::NewL(aContext, + aContext->iSendMSRPdataPckg().iExtMessageBuffer); + + aMessageHandler->SendFileL(*aContext->iConnection); + + aContext->iOutMsgQ.Queue(*aMessageHandler); + aContext->CompleteClient( KErrNone ); + + aContext->iFileShare = TRUE; + MSRPLOG("TStateBase::handleSendFileL() exit"); + if(!aContext->listnerSetupComplete()) + { + return aContext->StateFactory().getStateL(EWaitForClient); + } + + return aContext->StateFactory().getStateL(EFileShare); + } + +TStateBase* TStateBase::handleReceiveFileL(CMSRPServerSubSession *aContext) + { + MSRPLOG("TStateBase::handleReceiveFileL() enter"); + + aContext->ReadSendDataPckgL(); + + aContext->iReceiveFileMsgHdler = CMSRPMessageHandler::NewL(aContext, + aContext->iSendMSRPdataPckg().iExtMessageBuffer); + + + aContext->iReceiveFileMsgHdler->ReceiveFileL(); + aContext->CompleteClient( KErrNone ); + aContext->iFileShare = TRUE; + MSRPLOG("TStateBase::handleReceiveFileL() exit"); + if(!aContext->listnerSetupComplete()) + { + return aContext->StateFactory().getStateL(EWaitForClient); + } + + return aContext->StateFactory().getStateL(EFileShare); + } + +TStateBase* TStateWaitForClient::EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext) + { + // In the TStateWaitForClient stat the server subsession waits for the client to setup + // handlers to receive requests/responses/reports from the MSRP peer. + // TODO - TStateWaitForClient can be removed. Replace this with a eventQueue implementation. + + MSRPLOG2("Entered TStateWaitForClient Event %d",aEvent); + + TStateBase *state = NULL; + switch(aEvent) + { + case EMSRPListenMessagesEvent: + if(!aContext->iIncommingMessageListner.set(*(aContext->iClientMessage))) + { + MSRPLOG("TStateWaitForClient::EventL iIncomming listner is already setup"); + MSRPLOG2("TStateWaitForClient::EventL Invalid state to have received %d", aEvent); + } + aContext->iClientMessage = NULL; + break; + + case EMSRPListenSendResultEvent: + if(!aContext->iResponseListner.set(*(aContext->iClientMessage))) + { + MSRPLOG("TStateWaitForClient::EventL SendResult Listner is already setup"); + MSRPLOG2("TStateWaitForClient::EventL Invalid state to have received %d", aEvent); + } + aContext->iClientMessage = NULL; + break; + + case EMSRPIncomingMessageReceivedEvent: + // Queue any thing that comes. + aContext->iInCommingMsgQ.Queue(*aContext->iReceivedMsg); + break; + + case EMSRPDataSendCompleteEvent: + // Data Send Complete received in the TWaitForClient state is + // not handeled. At Data Send Complete messae with Failure Report + // header set to "no" need to inform the client about completion. + // Currently Queuing of completion events is not supported. + if(aContext->iFileShare) + { + state = fileSendCompleteL(aContext); + break; + } + MSRPLOG2("TStateWaitForClient::Not supported, Please check %d",aEvent); + break; + + case EMSRPResponseSendCompleteEvent: + if(aContext->iFileShare) + { + state = handleResponseSentL(aContext); + break; + } + break; + + case EMSRPDataSendMessageEvent: + aContext->QueueClientSendRequestsL(); + break; + + case EMSRPCancelReceivingEvent: + case EMSRPCancelSendRespListeningEvent: + handleClientListnerCancelL(aContext, aEvent); + break; + + case EConnectionStateChangedEvent: + state = handleConnectionStateChangedL(aContext); + break; + + case EMSRPSendProgressEvent: + case EMSRPReceiveProgressEvent: + //ignore event if no listener + MSRPLOG("TStateWaitForClient::EventL Ignoring Progress Event") + state = aContext->StateFactory().getStateL(EWaitForClient); + break; + + case EMSRPSendFileEvent: + state = handleSendFileL(aContext); + break; + + case EMSRPReceiveFileEvent : + state = handleReceiveFileL(aContext); + break; + + default: + // Any such error usually a client/server protocol voilation or connection/subsession + // protocol voilation. A bug to fix!! + + MSRPLOG2("TStateWaitForClient::EventL :: Err!! Invalid state to have received %d",aEvent); + state = HandleStateErrorL(aContext); + break; + }; + + if(NULL == state) + { + // State not set. + if(!aContext->listnerSetupComplete()) + { + state = this; + } + else if (aContext->iFileShare) + { + state = aContext->StateFactory().getStateL(EFileShare); + + if(aContext->iReceiveCompleteNotify) + { + aContext->NotifyFileReceiveResultToClientL(NULL); + state = aContext->StateFactory().getStateL(EWaitForClient); + } + else if (aContext->iSendCompleteNotify) + { + aContext->NotifyFileSendResultToClientL(NULL); + state = aContext->StateFactory().getStateL(EWaitForClient); + } + else if(!aContext->QueuesEmpty()) + state = state->handleQueuesL(aContext); + } + else + state = handleQueuesL(aContext); + } + return state; + } + +TStates TStateActive::identity() + { + return EActive; + } + +TStateBase* TStateActive::EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext) + { + // TStateActive is entered when the subsession is in a connected state and client setup + // is done. + + MSRPLOG2("Entered TStateActive Event %d",aEvent); + + TStateBase *state; + switch(aEvent) + { + case EMSRPDataSendMessageEvent: + state = handleSendDataL(aContext); + break; + + case EMSRPIncomingMessageReceivedEvent: + state = handleInCommingMessagesL(aContext); + break; + + case EMSRPSendFileEvent: + state = handleSendFileL(aContext); + break; + + case EMSRPReceiveFileEvent : + state = handleReceiveFileL(aContext); + break; + + case EConnectionStateChangedEvent: + state = handleConnectionStateChangedL(aContext); + break; + + case EMSRPCancelReceivingEvent: + case EMSRPCancelSendRespListeningEvent: + state = handleClientListnerCancelL(aContext, aEvent); + break; + + default: + // Any such error usually a client/server protocol voilation or connection/subsession + // protocol voilation. A bug to fix!! + + MSRPLOG2("TStateActive::EventL :: Err!! Invalid state to have received %d",aEvent); + state = HandleStateErrorL(aContext); + break; + } + + return state; + } + +TStateBase* TStateActive::handleSendDataL(CMSRPServerSubSession *aContext) + { + MSRPLOG("TStateActive::handleSendDataL()"); + + aContext->ReadSendDataPckgL(); + + CMSRPMessageHandler *msgHandler + = CMSRPMessageHandler::NewL(aContext, + aContext->iSendMSRPdataPckg().iExtMessageBuffer); + + msgHandler->SendMessageL( *aContext->iConnection ); + aContext->iCurrentMsgHandler = msgHandler; + + aContext->CompleteClient( KErrNone ); + + return aContext->StateFactory().getStateL(EActiveSend); + } + +TStateBase* TStateBase::handleInCommingMessagesL(CMSRPServerSubSession *aContext) + { + CMSRPMessageHandler* incommingMsg = aContext->iReceivedMsg; + aContext->iReceivedMsg = NULL; + + return processIncommingMessageL(aContext, incommingMsg); + } + +TStates TStateFileShare::identity() + { + return EFileShare; + } + +TStateBase* TStateFileShare::EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext) + { + TStateBase *state = NULL; + MSRPLOG2("Entered TStateFileShare Event %d",aEvent); + switch(aEvent) + { + case EMSRPDataSendCompleteEvent: // maps to file send complete + state = fileSendCompleteL(aContext); + break; + + case EMSRPIncomingMessageReceivedEvent: // incoming responses to file chunks + state = handleInCommingMessagesL(aContext); + break; + + case EMSRPResponseSendCompleteEvent: + state = handleResponseSentL(aContext); + break; + + case EMSRPSendProgressEvent: + state = handleSendProgressL(aContext); + break; + + case EMSRPReceiveProgressEvent: + state = handleReceiveProgressL(aContext); + break; + + case EConnectionStateChangedEvent : + state = handleConnectionStateChangedL(aContext); + break; + + + case EMSRPCancelReceivingEvent: + case EMSRPCancelSendRespListeningEvent: + state = handleClientListnerCancelL(aContext, aEvent); + break; + default: + MSRPLOG2("TStateFileShare::EventL :: Err!! Invalid state to have received %d",aEvent); + // state = HandleStateErrorL(aContext); //handle error state + break; + + } + return state; + } + +TStateBase * TStateFileShare::handleSendProgressL( CMSRPServerSubSession *aContext) + { + CMSRPMessageHandler *outgoingMessageHandler = aContext->iOutMsgQ.getHead(); + aContext->SendProgressToClientL(outgoingMessageHandler); + return aContext->StateFactory().getStateL( EWaitForClient ); + } + +TStateBase * TStateFileShare::handleReceiveProgressL( CMSRPServerSubSession *aContext) + { + CMSRPMessageHandler *oriMessageHandler = aContext->iReceiveFileMsgHdler; + aContext->ReceiveProgressToClientL(oriMessageHandler); + return aContext->StateFactory().getStateL( EWaitForClient ); + } + +TStateBase * TStateFileShare::handleResponseSentL( CMSRPServerSubSession *aContext) + { + CMSRPMessageHandler *oriMessageHandler = aContext->iReceiveFileMsgHdler; + oriMessageHandler->UpdateResponseStateL(aContext->iReceivedResp); + + + if(oriMessageHandler->FileTransferComplete() ) + { + //Notify client + aContext->NotifyFileReceiveResultToClientL(oriMessageHandler); + delete oriMessageHandler; + aContext->iReceiveFileMsgHdler = NULL; + return aContext->StateFactory().getStateL(EWaitForClient); + } + + if(!aContext->listnerSetupComplete()) + { + return aContext->StateFactory().getStateL(EWaitForClient); + } + + return aContext->StateFactory().getStateL(EFileShare); + + } + +TStateBase * TStateFileShare::handlesResponseL(CMSRPServerSubSession *aContext, + CMSRPMessageHandler *incommingMsgHandler) + { + TStateBase *nextState; + MSRPLOG("TStateFileShare::handlesFileResponseL Entered!"); + + // Search the outgoing Queue to find the owner of this response. + CMSRPMessageHandler *outgoingMsgHandler = + aContext->iOutMsgQ.getMatch(incommingMsgHandler); + + nextState = this; + if(NULL != outgoingMsgHandler) + { + CleanupStack::PushL(incommingMsgHandler); + outgoingMsgHandler->ConsumeFileResponseL(*incommingMsgHandler); + + if(outgoingMsgHandler->FileTransferComplete()) + { + //notify client + aContext->NotifyFileSendResultToClientL(outgoingMsgHandler); + aContext->iOutMsgQ.explicitRemove(outgoingMsgHandler); + delete outgoingMsgHandler; + nextState = aContext->StateFactory().getStateL(EWaitForClient); + } + + CleanupStack::Pop(incommingMsgHandler); + } + delete incommingMsgHandler; + MSRPLOG("TStateFileShare::handlesResponseL Exit!"); + if(!aContext->listnerSetupComplete()) + { + return aContext->StateFactory().getStateL(EWaitForClient); + } + return nextState; + } + +TStateBase * TStateFileShare::handleRequestsL(CMSRPServerSubSession *aContext, + CMSRPMessageHandler *incommingMsgHandler) + { + if(MMSRPIncomingMessage::EMSRPMessage == incommingMsgHandler->MessageType()) + { + CMSRPMessageHandler *oriMessageHandler = aContext->iReceiveFileMsgHdler; + + if(oriMessageHandler->IsInFile()) + { + oriMessageHandler->WritetoFileL(incommingMsgHandler); + incommingMsgHandler->SendResponseL(aContext, *aContext->iConnection,CMSRPResponse::EAllOk); + if(!incommingMsgHandler->IfResponseReqL()) + { + delete incommingMsgHandler; + if(oriMessageHandler->FileTransferComplete()) + { + aContext->NotifyFileReceiveResultToClientL(oriMessageHandler); + delete oriMessageHandler; + aContext->iReceiveFileMsgHdler = NULL; + return aContext->StateFactory().getStateL(EWaitForClient); + } + } + + else + { + aContext->iPendingForDeletionQ.Queue(*incommingMsgHandler); + } + } + } + else + { + MSRPLOG("Reports not supported.!!"); + delete incommingMsgHandler; + } + if(!aContext->listnerSetupComplete()) + { + return aContext->StateFactory().getStateL(EWaitForClient); + } + return this; + } + +TStateBase* TStateFileShare::fileSendCompleteL(CMSRPServerSubSession *aContext) + { + CMSRPMessageHandler *outgoingMessageHandler = aContext->iOutMsgQ.getHead(); + + if( outgoingMessageHandler && outgoingMessageHandler->IsMessageComplete() ) + { + //notify client + aContext->NotifyFileSendResultToClientL( outgoingMessageHandler ); + aContext->iOutMsgQ.explicitRemove(outgoingMessageHandler); + delete outgoingMessageHandler; + return aContext->StateFactory().getStateL( EWaitForClient ); + } + // response needed keep it on the outmsg queue itself + return aContext->StateFactory().getStateL( EFileShare ); + } + +TStates TStateActiveSend::identity() + { + return EActiveSend; + } + +TStateBase* TStateActiveSend::EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext) + { + // ActiveSend state. The subsession is busy sending earlier data. Any further requests to + // send data from the client will be queued. Any Message received will be queued till + // EMSRPDataSendCompleteEvent is received. + // After this Message Received Queue will be processed to check for any + // incoming messages/responses. + // After that Message send queue will be processed to see if there any pending messages to + // trasmitt. + // If both the queues are empty move back to Active State. + + TStateBase *state; + MSRPLOG2("Entered TStateActiveSend Event %d",aEvent); + + switch(aEvent) + { + case EMSRPDataSendMessageEvent: + aContext->QueueClientSendRequestsL(); + state = this; + break; + + case EMSRPDataSendCompleteEvent: + state = MessageSendCompleteL(aContext); + break; + + case EMSRPIncomingMessageReceivedEvent: + // Queue any thing that comes. + aContext->iInCommingMsgQ.Queue(*aContext->iReceivedMsg); + state = this; + break; + + case EConnectionStateChangedEvent: + state = handleConnectionStateChangedL(aContext); + break; + + case EMSRPCancelReceivingEvent: + case EMSRPCancelSendRespListeningEvent: + state = handleClientListnerCancelL(aContext, aEvent); + break; + + default: + // Any such error usually a client/server protocol voilation or connection/subsession + // protocol voilation. A bug to fix!! + + MSRPLOG2("TStateActiveSend::EventL :: Err!! Invalid state to have received %d",aEvent); + state = HandleStateErrorL(aContext); + break; + } + return state; + } + +TStateBase * TStateActiveSend::MessageSendCompleteL(CMSRPServerSubSession *aContext) + { + // Handle send message complete event. + if( NULL == aContext->iCurrentMsgHandler) + { + MSRPLOG( "TStateActiveSend::MessageSendCompleteL :: iCurrentMsgHandler is NULL \n" ); + return this; + } + + if( aContext->iCurrentMsgHandler->IsMessageComplete() ) + { + // Messages with Failure Report set to "No" will never get a response. + TBool error = aContext->sendResultToClientL( aContext->iCurrentMsgHandler ); + delete aContext->iCurrentMsgHandler; + aContext->iCurrentMsgHandler = NULL; + + return aContext->StateFactory().getStateL( EWaitForClient ); + } + else + { + // Message expects a response to come. Put this out the OutGoing Queue. + aContext->iOutMsgQ.Queue( *(aContext->iCurrentMsgHandler) ); + aContext->iCurrentMsgHandler = NULL; + + // Handle any pending events in Queue. + return handleQueuesL(aContext); + } + } + + +TStates TStateError::identity() + { + return EError; + } + +TStateBase* TStateError::EventL(TMSRPFSMEvent aEvent, CMSRPServerSubSession *aContext) + { + // Error State is entered when we receive an Error Response from the opposite + // end point to which we sent a SEND request. When this state is entered the client + // is expected to close the session without trying to send further messages. + + MSRPLOG2("Entered TStateError Event %d", aEvent); + TStateBase *state; + + switch(aEvent) + { + case EMSRPListenMessagesEvent: + aContext->CompleteClient(KErrCouldNotConnect); + state = this; + break; + + case EMSRPListenSendResultEvent: + aContext->CompleteClient(EInvalidAction); + state = this; + break; + + case EMSRPDataSendMessageEvent: + aContext->CompleteClient(KErrNone); + state = this; + break; + + case EMSRPCancelReceivingEvent: + case EMSRPCancelSendRespListeningEvent: + state = handleClientListnerCancelL(aContext, aEvent); + break; + + case EMSRPIncomingMessageReceivedEvent: + aContext->iInCommingMsgQ.Queue(*aContext->iReceivedMsg); + state = this; + break; + + case EConnectionStateChangedEvent: + state = handleConnectionStateChangedL(aContext); + break; + + default: + MSRPLOG2("TStateError::EventL :: Err!! Invalid state to have received %d",aEvent); + state = HandleStateErrorL(aContext); + break; + } + return state; + } diff -r f1578314b8da -r 505ad3f0ce5c Msrp/inc/MsrpCommon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Msrp/inc/MsrpCommon.h Sat Jun 12 14:30:11 2010 +0530 @@ -0,0 +1,282 @@ +/* +* Copyright (c) 2009-2010 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: +* MSRP Implementation +* +*/ + +#ifndef __MSRPCOMMON_H__ +#define __MSRPCOMMON_H__ + +// EXTERNAL INCLUDES +#include +#include +#include + + +#ifdef UT_TEST + +const TInt KTimeOutInSeconds( 5 ); +const TInt KSecondinMicroseconds( 1000000 ); + +const TInt KListenTimeoutInSeconds( 10 ); +const TInt KBufSize = 4096; +const TInt KThreshold = 3839; + +#else + +const TInt KTimeOutInSeconds( 30 ); +const TInt KSecondinMicroseconds( 1000000 ); + +const TInt KListenTimeoutInSeconds( 30 ); +const TInt KBufSize = 4096; +const TInt KThreshold = 1024; + +#endif + +// CONSTANTS +// Server name. +_LIT( KMSRPServerName, "!MSRPServer" ); +// The name of the MSRP Client module +_LIT( KMSRPClientName, "MSRPClient" ); + +_LIT( KLogDir1, "MSRP" ); +_LIT( KLogFile1, "msrp.txt" ); +_LIT8( KLog8Dir1, "MSRP" ); +_LIT8( KLog8File1, "msrp.txt" ); +_LIT( KMSRPExe, "MSRPServer.exe" ); + +#ifdef __WINSCW__ +_LIT( KProgramsDir, "\\" ); +#else +_LIT( KProgramsDir, "\\sys\\bin\\" ); +#endif + +_LIT8( KCRAndLF, "\r\n" ); +_LIT8( KMatchCRAndLF, "*\r\n*" ); +_LIT8( KMatch2CRAndLF, "*\r\n\r\n*" ); +_LIT8( KSpaceChar, " " ); +_LIT8( KDashLine, "-------" ); +_LIT8( KMessageEndSign, "$" ); +_LIT8( KMessageContinuesSign, "+" ); +_LIT8( KMessageTerminatedSign, "#" ); +_LIT8( KAsterisk, "*" ); + +_LIT8( KMsrpUriScheme, "msrp://" ); +_LIT8( KColon, ":" ); +_LIT8( KSemicolon, ";" ); +_LIT8( KForwardSlash, "/" ); +_LIT8( KTransport, "tcp" ); + +_LIT8( KMSRP,"MSRP" ); +_LIT8( KMSRPSend,"SEND" ); +_LIT8( KMSRPReport,"REPORT" ); +_LIT8( KMSRPMessageID, "Message-ID" ); +_LIT8( KMSRPByteRange,"Byte-Range" ); +_LIT8( KMSRPContentType, "Content-Type" ); +_LIT8( KMSRPToPath, "To-Path" ); +_LIT8( KMSRPFromPath,"From-Path" ); +_LIT8( KMSRPSuccessReport,"Success-Report" ); +_LIT8( KMSRPFailureReport,"Failure-Report" ); +_LIT8( KMSRPStatus, "Status" ); + +// temporary file path +_LIT( KDefaultTempFilePath, "C:\\system\\temp\\" ); + +// CONSTANTS +const TInt KMaxLengthOfUrl = 255; +const TInt KMaxLengthOfHost = 255; +const TInt KMaxLengthOfSessionId = 255; +const TInt KSizeOfProgramPath = 50; + +// maximum length of incoming message buffer (for externalizing CMSRPMessage +// class +const TInt KMaxLengthOfIncomingMessageExt = 4096; + +// max length of small MSRP message +const TInt KMaxLengthOfSmallMSRPMessage = 2048; + +// MSRP port number, IANA assigned +const TInt KMsrpPort = 2855; + +// MSRP server version +const TUint KMSRPServerMajorVersionNumber = 1; +const TUint KMSRPServerMinorVersionNumber = 0; +const TUint KMSRPServerBuildVersionNumber = 0; + +// end of line chars +const TUint KDashCharacter = 0x2D; +const TUint KDividedCharacter = 0x2F; +const TUint KSpaceCharacter = 0x20; + +const TUint KColonCharacter = 0x3A; +const TUint KSemiColonCharacter = 0x3B; +const TInt KMaxLengthOfStatusCode = 3; + +// the maximum length of MSRP end line string +const TInt KMaxLengthOfMessageEndString = 100; + +// the maximum length of transaction id string +const TInt KMaxLengthOfTransactionIdString = 100; + +const TInt KUnknownRange = -1; + +// MACROS +#ifdef _DEBUG + + // logging + #define MSRPLOG( text ) \ + { \ + _LIT( KText, text ); \ + RFileLogger::Write( KLogDir1, KLogFile1, EFileLoggingModeAppend, KText ); \ + RDebug::Print( KText ); \ + } + + #define MSRPLOG2( text, value ) \ + { \ + _LIT( KText, text ); \ + RFileLogger::WriteFormat( KLogDir1, KLogFile1, EFileLoggingModeAppend, \ + TRefByValue( KText() ), value ); \ + RDebug::Print( KText, value ); \ + } + + #define MSRPLOG3( text, value, value2 ) \ + { \ + _LIT( KText, text ); \ + RFileLogger::WriteFormat( KLogDir1, KLogFile1, EFileLoggingModeAppend, \ + TRefByValue( KText() ), value, value2 ); \ + RDebug::Print( KText, value, value2 ); \ + } + +#else + + // not used + #define MSRPLOG( text ) + #define MSRPLOG2( text, value1 ) + #define MSRPLOG3( text, value1, value2 ) + +#endif // END MACROS + +// ENUMS +// MSRP API IPC request definitions + +enum TMSRPRequests + { + EMSRPCreateSubSession, + EMSRPCloseSubSession, + EMSRPLocalPath, + EMSRPConnect, + EMSRPListenConnections, + EMSRPListenMessages, + EMSRPListenSendResult, + EMSRPSendMessage, + EMSRPSendFile, + EMSRPReceiveFile, + EMSRPCancelSending, + EMSRPCancelReceiving, + EMSRPCancelSendRespListening, + EMSRPReserved + }; + +enum TMSRPMessageContent + { + EMSRPChunkEndHeaders, + EMSRPChunkEndNoHeaders, + EMSRPChunkPartialChunkNoHeaders, + EMSRPChunkPartialChunkHeaders + }; + +enum TServerClientResponses + { + ESubSessionHandle=3, // type integer and returned as response to EMSRPCreateSubSession + // Reserved, + }; + +enum TPanicCode + { + EBadRequest = 1, + EBadDescriptor, + EBadSubsessionHandle + }; + +enum TReportStatus + { + EYes, + ENo, + EPartial + }; + +enum TErrorCode + { + EUndefined = -1, + ENoError = 0, + ENetworkTimeout = 1, + EUnrecoverableError = 2, + ELocalTimeout = 3, + EInvalidAction = 4 + }; + + +// Local host name and session id +typedef struct TLocalPathMSRPData + { + TBuf8< KMaxLengthOfHost> iLocalHost; + TBuf8< KMaxLengthOfSessionId > iSessionID; + } TLocalPathMSRPData; + + +// for connection parameters +typedef struct TConnectMSRPData + { + TBuf8< KMaxLengthOfHost > iRemoteHost; + TUint iRemotePort; + TBuf8< KMaxLengthOfSessionId > iRemoteSessionID; + } TConnectMSRPData; + + +// for listening parameters +typedef struct TListenMSRPData + { + TBuf8< KMaxLengthOfHost > iRemoteHost; + TUint iRemotePort; + TBuf8< KMaxLengthOfSessionId > iRemoteSessionID; + TBuf8< KMaxLengthOfIncomingMessageExt > iExtMessageBuffer; + TBool iIsMessage; + TBool iIsProgress; + TInt iBytesRecvd; + TInt iTotalBytes; + TInt iStatus; + } TListenMSRPData; + + +// for sending a message +typedef struct TSendMSRPData + { + TBuf8< KMaxLengthOfIncomingMessageExt > iExtMessageBuffer; + } TSendMSRPData; + + +// for listening to result of a sent message +typedef struct TListenSendResultMSRPData + { + TBuf8< KMaxLengthOfSessionId > iSessionID; + TBuf8< KMaxLengthOfSessionId > iMessageId; + TBool iIsProgress; + TInt iBytesSent; + TInt iTotalBytes; + TInt iStatus; // error codes propagated to the client + } TListenSendResultMSRPData; + + +#endif // __MSRPCOMMON_H__ + +// End of File