|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * This file contains the headers of DataGatewaySOAPServerThread, DataGatewayClientThread and DataGateway |
|
16 * classes. |
|
17 */ |
|
18 |
|
19 #ifndef DATAGATEWAY_H |
|
20 #define DATAGATEWAY_H |
|
21 |
|
22 #pragma warning ( disable : 4786 ) |
|
23 |
|
24 #include <windows.h> |
|
25 #include <process.h> |
|
26 |
|
27 #include "util.h" |
|
28 #include "common.h" |
|
29 #include "plugin.h" |
|
30 #include "safequeue.h" |
|
31 #include "HtiDispatcher.h" |
|
32 #include "thread.h" |
|
33 |
|
34 const int g_DataGatewayDefaultTcpIpPort = 2000; |
|
35 const int g_DataGatewayDefaultTcpIpBufferSize = 8 * 1024; |
|
36 |
|
37 // Maximum time to wait |
|
38 extern long g_MaximumShutdownWaitTime; |
|
39 |
|
40 extern DWORD g_ErrorCode; |
|
41 |
|
42 //********************************************************************************** |
|
43 // Class DataGatewaySOAPServerThread |
|
44 // |
|
45 // This thread acts as a SOAP server, it listens to SOAP requests and forwards them |
|
46 // to HtiDispatcher which then forwards them to correct SOAPHandlers |
|
47 //********************************************************************************** |
|
48 |
|
49 class DataGatewaySOAPServerThread : public Thread<DataGatewaySOAPServerThread> |
|
50 { |
|
51 public: |
|
52 DataGatewaySOAPServerThread(HtiDispatcher* htiDispatcher, int port); |
|
53 void Run(); |
|
54 void Stop(); |
|
55 bool IsRunning(); |
|
56 |
|
57 private: |
|
58 //SafeQueue<Data*>* m_Queue; |
|
59 HtiDispatcher* m_HtiDispatcher; |
|
60 int m_TcpPort; |
|
61 |
|
62 bool m_Running; |
|
63 }; |
|
64 |
|
65 //********************************************************************************** |
|
66 // Class DataGatewayClientThread |
|
67 // |
|
68 // This thread serves DataGateway's clients |
|
69 // Gets Data objects from incoming queue and forwards them to CommChannelPlugin. |
|
70 // The Data objects are actually SOAP requests which were received by DataGatewaySOAPServerThread handled by SOAPHandler and transferred to HtiMessages and eventually Data objects |
|
71 // The thread also reads incoming data from CommChannelPlugin and forwards them to outgoing queue which |
|
72 // HtiDispatcher then reads and forwards to correct SOAPHandler |
|
73 //********************************************************************************** |
|
74 |
|
75 class DataGatewayClientThread : public Thread<DataGatewayClientThread> |
|
76 { |
|
77 public: |
|
78 DataGatewayClientThread(int port, long bufsize, const string& commchannel); |
|
79 DataGatewayClientThread(int port, long bufsize, CommChannelPlugin** f); |
|
80 ~DataGatewayClientThread(); |
|
81 void Run(); |
|
82 void Stop(); |
|
83 |
|
84 private: |
|
85 //incoming queue from PC side, outgoing to CommChannelPlugin side |
|
86 SafeQueue<Data*> m_ReaderQueue; |
|
87 //outgoing queue to PC side, incoming from CommChannelPlugin side |
|
88 SafeQueue<Data*> m_WriterQueue; |
|
89 |
|
90 DataGatewaySOAPServerThread m_SoapListener; |
|
91 HtiDispatcher m_HtiDispatcher; |
|
92 |
|
93 CommChannelPlugin* m_CommChannelPlugin; |
|
94 const string& m_CommChannelPluginName; |
|
95 bool m_Running; |
|
96 bool m_CCLateInit; |
|
97 long m_TcpIpBufferSize; |
|
98 }; |
|
99 |
|
100 //********************************************************************************** |
|
101 // Class DataGateway |
|
102 // |
|
103 // Main class/thread of HtiGateway |
|
104 //********************************************************************************** |
|
105 |
|
106 class DataGateway : public Thread<DataGateway> |
|
107 { |
|
108 public: |
|
109 DataGateway(int port = g_DataGatewayDefaultTcpIpPort, |
|
110 long bufsize = g_DataGatewayDefaultTcpIpBufferSize, |
|
111 const string& commchannel = "", |
|
112 bool stayalive = false, |
|
113 bool cclateinit = false); |
|
114 void Run(); |
|
115 void Stop(); |
|
116 bool IsRunning(); |
|
117 |
|
118 private: |
|
119 const string& m_CommChannelPluginName; |
|
120 CommChannelPlugin* m_CommChannelPlugin; |
|
121 Event m_ShutdownEvent; |
|
122 bool m_Running; |
|
123 bool m_StayAlive; |
|
124 bool m_CCLateInit; |
|
125 int m_TcpIpPort; |
|
126 long m_TcpIpBufferSize; |
|
127 }; |
|
128 |
|
129 #endif |
|
130 |
|
131 // End of the file |