diff -r 7fdc9a71d314 -r 8ad140f3dd41 hti/HtiServicePlugins/HtiIpProxyServicePlugin/IPProxyEngine/Src/Ctcpportlistener.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hti/HtiServicePlugins/HtiIpProxyServicePlugin/IPProxyEngine/Src/Ctcpportlistener.h Wed Oct 13 16:17:58 2010 +0300 @@ -0,0 +1,116 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Listens TCP port +* +*/ + + + +#ifndef CTCPPORTLISTENER_H +#define CTCPPORTLISTENER_H + +// INCLUDES +#include +#include + + +// FORWARD DECLARATIONS +class MTCPPortListenerObserver; + +// CLASS DECLARATION + +/** +* ActiveObject which listens a TCP port. +*/ +NONSHARABLE_CLASS( CTCPPortListener ) : public CActive + { + public: // Constructors and destructor + + /** + * Factory function. + * @param aPort TCP port to listen. + * @param aObserver Pointer to observer. + */ + static CTCPPortListener* NewL( TInt aPort, + MTCPPortListenerObserver* aObserver ); + + /** + * Factory function. + * @param aPort TCP port to listen. + * @param aObserver Pointer to observer. + */ + static CTCPPortListener* NewLC( TInt aPort, + MTCPPortListenerObserver* aObserver ); + + /** + * Destructor. + */ + ~CTCPPortListener(); + + public: // New functions + + /** + * Starts listening the port. + */ + void IssueListen(); + + /** + * Retrieve current port number for this listener + * @return Port number for this listening socket + */ + TInt Port() const; + + public: // Functions from base classes + + /** + * From CActive. Pending request has been completed. + */ + void RunL(); + + /** + * From CActive. Pending request has been cancelled. + */ + void DoCancel(); + + /** + * From CActive. RunL has leaved. + */ + TInt RunError( TInt aError ); + + private: + + /** + * Default constructor. + * @param aPort TCP port to listen. + * @param aObserver Pointer to observer. + */ + CTCPPortListener( TInt aPort, + MTCPPortListenerObserver* aObserver ); + + /** + * 2nd phase constructor. + */ + void ConstructL(); + + private: // Data + MTCPPortListenerObserver* iObserver; + TInt iPort; + RSocketServ iSocketServer; + RSocket iListeningSocket; + RSocket* iAcceptedSocket; + }; + +#endif // CTCPPORTLISTENER_H + +// End of File