|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __CTCPTRANSPORTLAYER_H__ |
|
17 #define __CTCPTRANSPORTLAYER_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <in_sock.h> |
|
21 #include <http/framework/logging.h> |
|
22 |
|
23 #include "chttptransportlayer.h" |
|
24 #include "msocketcontrollerfactory.h" |
|
25 #include "msocketconnectorstore.h" |
|
26 #include "msocketcontrollerstore.h" |
|
27 #include "mcommsinfoprovider.h" |
|
28 |
|
29 class CSocket; |
|
30 class CSocketListener; |
|
31 class CSocketConnector; |
|
32 class CSocketController; |
|
33 class MConnectionPrefsProvider; |
|
34 |
|
35 const TUint KUidTcpTransportLayer = 0x101f55ed; |
|
36 |
|
37 class CTcpTransportLayer : public CHttpTransportLayer, |
|
38 public MSocketControllerFactory, |
|
39 public MSocketConnectorStore, |
|
40 public MSocketControllerStore, |
|
41 public MCommsInfoProvider |
|
42 /** |
|
43 The CTcpTransportLayer class provides an implementation of the ECOM |
|
44 interface CHttpdTransportHandler. This implementation uses a TCP/IP transport |
|
45 to provide input and output streams to connected remote hosts. |
|
46 |
|
47 The CTcpTransportLayer class also provides the MSocketFactory API. This |
|
48 API together with the MSocketListenObserver and MSocketConnectObserver APIs |
|
49 are used to supply input and output streams to remote hosts. |
|
50 @internalComponent |
|
51 @see CHttpTransportLayer |
|
52 @see MSocketListenObserver |
|
53 @see MSocketConnectObserver |
|
54 */ |
|
55 { |
|
56 public: // methods |
|
57 |
|
58 static CTcpTransportLayer* NewL(TAny* aTransportConstructionParams); |
|
59 |
|
60 virtual ~CTcpTransportLayer(); |
|
61 |
|
62 private: // methods from CHttpTransportLayer |
|
63 |
|
64 virtual void CHttpTransportLayer_Reserved(); |
|
65 |
|
66 private: // methods from MSocketFactory |
|
67 |
|
68 virtual void ListenL(MSocketListenObserver& aObserver, TUint16 aPort); |
|
69 |
|
70 virtual void StopListen(); |
|
71 |
|
72 virtual MSocketConnector& ConnectL(MSocketConnectObserver& aObserver, const TDesC8& aRemoteHost, TUint16 aRemotePort); |
|
73 |
|
74 virtual void MSocketFactory_Reserved(); |
|
75 |
|
76 private: // methods from MSocketControllerFactory |
|
77 |
|
78 virtual CSocketController* CreateSocketControllerLC(CSocket* aConnectedSocket); |
|
79 virtual CSocketController* CreateSocketControllerLC(CSocket* aConnectedSocket, const TDesC& aRemoteHost, TUint16 aRemotePort, const TInetAddr& aRemoteAddr); |
|
80 virtual void AddToStoreL(CSocketController* aSocketController); |
|
81 |
|
82 private: // methods from MSocketConnectorStore |
|
83 |
|
84 virtual void ConnectionCompleted(CSocketConnector& aOrphanedSocketConnector); |
|
85 |
|
86 private: // methods from MSocketControllerStore |
|
87 |
|
88 virtual void SocketControllerShutdown(CSocketController& aOrphanedSocketController); |
|
89 |
|
90 private: // methods from MCommsInfoProvider |
|
91 |
|
92 virtual RSocketServ& SocketServer(); |
|
93 |
|
94 virtual TProtocolDesc& ProtocolDescription(); |
|
95 |
|
96 virtual RConnection& Connection(); |
|
97 |
|
98 virtual void SecurityPreferences(TBool& aDialogPrompt, MSecurityPolicy*& aSecurityPolicy); |
|
99 |
|
100 virtual TBool OwnsConnection(); |
|
101 |
|
102 virtual TInt SessionId(); |
|
103 |
|
104 virtual TBool HasConnection(); |
|
105 |
|
106 void StartDefaultCommsConnectionL (); |
|
107 |
|
108 private: // methods |
|
109 |
|
110 CTcpTransportLayer(MConnectionPrefsProvider& aTransLayerObserver); |
|
111 |
|
112 void ConstructL(THttpTransportConstructionParams* aTransportConstructionParams); |
|
113 |
|
114 inline MSocketControllerFactory& SocketControllerFactory(); |
|
115 |
|
116 inline MSocketConnectorStore& SocketConnectorStore(); |
|
117 |
|
118 inline MSocketControllerStore& SocketControllerStore(); |
|
119 |
|
120 inline MCommsInfoProvider& CommsInfoProvider(); |
|
121 |
|
122 private: // attributes |
|
123 |
|
124 /** The connection preferences provider |
|
125 */ |
|
126 MConnectionPrefsProvider& iConnectionPrefsProvider; |
|
127 |
|
128 /** The socket server session. |
|
129 */ |
|
130 RSocketServ iSocketServer; |
|
131 |
|
132 /** The protocol description. |
|
133 */ |
|
134 TProtocolDesc iProtocolDescription; |
|
135 |
|
136 /** Pointer to the socket connection required for multi-homing |
|
137 */ |
|
138 RConnection* iConnection; |
|
139 |
|
140 /** Flag to indicate whether the comms connection is owned |
|
141 */ |
|
142 TBool iOwnsConnection; |
|
143 |
|
144 /** Flag to indicate whether the socket connection is owned |
|
145 */ |
|
146 TBool iOwnsSocketConnection; |
|
147 |
|
148 /** The socket listener object |
|
149 */ |
|
150 CSocketListener* iSocketListener; |
|
151 |
|
152 /** The socket connector store |
|
153 */ |
|
154 RPointerArray<CSocketConnector> iConnectorStore; |
|
155 |
|
156 /** The socket controller store |
|
157 */ |
|
158 RPointerArray<CSocketController> iControllerStore; |
|
159 |
|
160 TBool iPriority; |
|
161 |
|
162 /** Logger handle |
|
163 */ |
|
164 __FLOG_DECLARATION_MEMBER2 |
|
165 |
|
166 }; |
|
167 |
|
168 #include "ctcptransportlayer.inl" |
|
169 |
|
170 #endif // __CTCPTRANSPORTLAYER_H__ |