|
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 __CSOCKETCONTROLLER_H__ |
|
17 #define __CSOCKETCONTROLLER_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <in_sock.h> |
|
21 #include "msocketcontroller.h" |
|
22 |
|
23 class CSocket; |
|
24 class MInputStream; |
|
25 class MOutputStream; |
|
26 class CSocketReader; |
|
27 class CSocketWriter; |
|
28 class MSocketControllerStore; |
|
29 class MConnectionPrefsProvider; |
|
30 |
|
31 |
|
32 class CSocketController: public CBase, |
|
33 public MSocketController |
|
34 /** |
|
35 The CSocketController class owns a connected socket. It provides input and |
|
36 output stream objects that use that socket via the CSocketReader and |
|
37 CSocketWriter attributes. |
|
38 |
|
39 A CSocketController object will self-delete once the socket it owns has been |
|
40 closed. The socket can be closed either by the remote client, the input stream |
|
41 observer or the output stream observer. |
|
42 @internalComponent |
|
43 */ |
|
44 { |
|
45 public: // methods |
|
46 |
|
47 static CSocketController* NewL(CSocket* aSocket, MConnectionPrefsProvider& aConnectionPrefsProvider,TBool aPriority); |
|
48 |
|
49 virtual ~CSocketController(); |
|
50 |
|
51 void NotifyInStore(MSocketControllerStore& aStore); |
|
52 |
|
53 MInputStream& InputStream() const; |
|
54 |
|
55 MOutputStream& OutputStream() const; |
|
56 |
|
57 TBool HostAndPortMatches(const TDesC8& aHost, TUint16 aPort); |
|
58 |
|
59 inline TInetAddr& RemoteAddress(); |
|
60 |
|
61 void AssignRemoteHostInfoL(const TDesC& aHost, TUint16 aPort, const TInetAddr& aAddr); |
|
62 |
|
63 private: // methods from MSocketController |
|
64 |
|
65 virtual void StreamClosed(TInt aError, MSocketController::TStreamType aStreamType); |
|
66 |
|
67 virtual void StreamSuspend(MSocketController::TStreamType aStreamType); |
|
68 |
|
69 virtual void StreamResume(MSocketController::TStreamType aStreamType); |
|
70 |
|
71 virtual void ConnectionInfo(TDes8& aRemoteHost, TUint16& aRemotePort, TUint16& aLocalPort); |
|
72 |
|
73 private: // methods |
|
74 |
|
75 CSocketController(CSocket* aSocket, MConnectionPrefsProvider& aConnectionPrefsProvider, TBool aPriority); |
|
76 |
|
77 void ConstructL( TInt aRecvBufferSize ); |
|
78 |
|
79 private: |
|
80 TUint16 iPort; |
|
81 |
|
82 HBufC8* iHost; |
|
83 |
|
84 /** The socket controller store. This is not owned. |
|
85 */ |
|
86 MSocketControllerStore* iStore; |
|
87 |
|
88 /** The connected socket. The ownership of this object is given by the iOwnSocket |
|
89 flag. |
|
90 */ |
|
91 CSocket* iSocket; |
|
92 |
|
93 /** The socket reader. |
|
94 */ |
|
95 CSocketReader* iSocketReader; |
|
96 |
|
97 /** The socket writer. |
|
98 */ |
|
99 CSocketWriter* iSocketWriter; |
|
100 |
|
101 TBool iPriority; |
|
102 |
|
103 /** The connection preferences provider |
|
104 */ |
|
105 MConnectionPrefsProvider& iConnectionPrefsProvider; |
|
106 |
|
107 TInetAddr iRemoteAddress; |
|
108 }; |
|
109 |
|
110 inline TInetAddr& CSocketController::RemoteAddress() |
|
111 { |
|
112 return iRemoteAddress; |
|
113 } |
|
114 |
|
115 #endif // __CSOCKETCONTROLLER_H__ |