diff -r 7fdc9a71d314 -r 8ad140f3dd41 hti/PC_Tools/HTIGateway/HtiGateway/inc/datagateway.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hti/PC_Tools/HTIGateway/HtiGateway/inc/datagateway.h Wed Oct 13 16:17:58 2010 +0300 @@ -0,0 +1,131 @@ +/* +* 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: +* This file contains the headers of DataGatewaySOAPServerThread, DataGatewayClientThread and DataGateway +* classes. +*/ + +#ifndef DATAGATEWAY_H +#define DATAGATEWAY_H + +#pragma warning ( disable : 4786 ) + +#include +#include + +#include "util.h" +#include "common.h" +#include "plugin.h" +#include "safequeue.h" +#include "HtiDispatcher.h" +#include "thread.h" + +const int g_DataGatewayDefaultTcpIpPort = 2000; +const int g_DataGatewayDefaultTcpIpBufferSize = 8 * 1024; + +// Maximum time to wait +extern long g_MaximumShutdownWaitTime; + +extern DWORD g_ErrorCode; + +//********************************************************************************** +// Class DataGatewaySOAPServerThread +// +// This thread acts as a SOAP server, it listens to SOAP requests and forwards them +// to HtiDispatcher which then forwards them to correct SOAPHandlers +//********************************************************************************** + +class DataGatewaySOAPServerThread : public Thread +{ +public: + DataGatewaySOAPServerThread(HtiDispatcher* htiDispatcher, int port); + void Run(); + void Stop(); + bool IsRunning(); + +private: + //SafeQueue* m_Queue; + HtiDispatcher* m_HtiDispatcher; + int m_TcpPort; + + bool m_Running; +}; + +//********************************************************************************** +// Class DataGatewayClientThread +// +// This thread serves DataGateway's clients +// Gets Data objects from incoming queue and forwards them to CommChannelPlugin. +// The Data objects are actually SOAP requests which were received by DataGatewaySOAPServerThread handled by SOAPHandler and transferred to HtiMessages and eventually Data objects +// The thread also reads incoming data from CommChannelPlugin and forwards them to outgoing queue which +// HtiDispatcher then reads and forwards to correct SOAPHandler +//********************************************************************************** + +class DataGatewayClientThread : public Thread +{ +public: + DataGatewayClientThread(int port, long bufsize, const string& commchannel); + DataGatewayClientThread(int port, long bufsize, CommChannelPlugin** f); + ~DataGatewayClientThread(); + void Run(); + void Stop(); + +private: + //incoming queue from PC side, outgoing to CommChannelPlugin side + SafeQueue m_ReaderQueue; + //outgoing queue to PC side, incoming from CommChannelPlugin side + SafeQueue m_WriterQueue; + + DataGatewaySOAPServerThread m_SoapListener; + HtiDispatcher m_HtiDispatcher; + + CommChannelPlugin* m_CommChannelPlugin; + const string& m_CommChannelPluginName; + bool m_Running; + bool m_CCLateInit; + long m_TcpIpBufferSize; +}; + +//********************************************************************************** +// Class DataGateway +// +// Main class/thread of HtiGateway +//********************************************************************************** + +class DataGateway : public Thread +{ +public: + DataGateway(int port = g_DataGatewayDefaultTcpIpPort, + long bufsize = g_DataGatewayDefaultTcpIpBufferSize, + const string& commchannel = "", + bool stayalive = false, + bool cclateinit = false); + void Run(); + void Stop(); + bool IsRunning(); + +private: + const string& m_CommChannelPluginName; + CommChannelPlugin* m_CommChannelPlugin; + Event m_ShutdownEvent; + bool m_Running; + bool m_StayAlive; + bool m_CCLateInit; + int m_TcpIpPort; + long m_TcpIpBufferSize; +}; + +#endif + +// End of the file \ No newline at end of file