|
1 // Copyright (c) 2008-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 // Dummy network flow |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #if !defined(__DUMMYPR_NETWORK_FLOW_H__) |
|
24 #define __DUMMYPR_NETWORK_FLOW_H__ |
|
25 |
|
26 #include "dummypr_factory.h" |
|
27 #include <comms-infras/ss_protflow.h> |
|
28 #include <comms-infras/ss_subconnflow.h> |
|
29 #include <comms-infras/es_sap.h> |
|
30 #include <comms-infras/nifif.h> |
|
31 |
|
32 #include <comms-infras/ss_nodemessages_dataclient.h> |
|
33 #include <comms-infras/ss_nodemessages_flow.h> |
|
34 |
|
35 namespace ESock |
|
36 { |
|
37 |
|
38 _LIT(KDummyProtocolName, "dummy"); |
|
39 _LIT(KDumberProtocolName, "dumber"); |
|
40 |
|
41 class CDummyNetworkFlow : public CSubConnectionFlowBase, |
|
42 public MSessionData, |
|
43 public MSessionControl, |
|
44 public MFlowBinderControl, |
|
45 public MSessionControlNotify, |
|
46 public MSessionDataNotify |
|
47 /** |
|
48 @internalComponent |
|
49 @released since v9.6 |
|
50 */ |
|
51 { |
|
52 friend class CSocket; |
|
53 public: |
|
54 typedef CDummyNetworkFlowFactory FactoryType; //for factoryobject_cast to work |
|
55 |
|
56 static CDummyNetworkFlow* NewL(CSubConnectionFlowFactoryBase& aFactory, const Messages::TNodeId& aSubConn, CProtocolIntfBase* aProtocolIntf); |
|
57 void SetSSP(CServProviderBase& aSSP); |
|
58 |
|
59 inline CServProviderBase* Provider(); |
|
60 |
|
61 protected: |
|
62 // Lifetime |
|
63 CDummyNetworkFlow(CSubConnectionFlowFactoryBase& aFactory, const Messages::TNodeId& aSubConn, CProtocolIntfBase* aProtocolIntf); |
|
64 virtual ~CDummyNetworkFlow(); |
|
65 void SetSockType(TUint aSockType); |
|
66 TInt LockToConnectionInfo(); |
|
67 |
|
68 // MSessionData |
|
69 virtual TUint Write(const TDesC8& aDesc,TUint aOptions, TSockAddr* anAddr); |
|
70 virtual TInt Write(RMBufChain& aData, TUint aOptions, TSockAddr* anAddr); |
|
71 virtual void GetData(TDes8& aDesc, TUint aOptions, TSockAddr* anAddr); |
|
72 virtual TInt GetData(RMBufChain& aData, TUint aLength, TUint aOptions, TSockAddr* anAddr); |
|
73 |
|
74 // MSessionControl |
|
75 virtual void Start(); |
|
76 virtual void LocalName(TSockAddr& anAddr) const; |
|
77 virtual void SetLocalName(TSockAddr& anAddr); |
|
78 virtual void RemName(TSockAddr& anAddr) const; |
|
79 virtual TInt SetRemName(TSockAddr& anAddr); |
|
80 virtual TInt GetOption(TUint aLevel,TUint aName,TDes8& anOption) const; |
|
81 virtual void Ioctl(TUint aLevel,TUint aName,TDes8* anOption); |
|
82 virtual void CancelIoctl(TUint aLevel,TUint aName); |
|
83 virtual TInt SetOption(TUint aLevel, TUint aName,const TDesC8 &anOption); |
|
84 virtual void ActiveOpen(); |
|
85 virtual void ActiveOpen(const TDesC8& aConnectionData); |
|
86 virtual TInt PassiveOpen(TUint aQueueSize); |
|
87 virtual TInt PassiveOpen(TUint aQueueSize,const TDesC8& aConnectionData); |
|
88 virtual void Shutdown(MSessionControl::TCloseType aOption); |
|
89 virtual void Shutdown(MSessionControl::TCloseType aOption, const TDesC8& aDisconnectionData); |
|
90 virtual void AutoBind(); |
|
91 virtual TInt SecurityCheck(MProvdSecurityChecker* aSecurityChecker); |
|
92 |
|
93 // MFlowBinderControl |
|
94 //session binders for CSocket |
|
95 virtual MSessionControl* GetControlL(TInt aSessionType,MSessionControlNotify& aSessionControlNotify); |
|
96 virtual MSessionData* BindL(MSessionDataNotify& aNotify); |
|
97 virtual void Unbind(); |
|
98 virtual CSubConnectionFlowBase& CloneFlowL(); |
|
99 virtual CSubConnectionFlowBase* Flow(); |
|
100 |
|
101 private: |
|
102 // MSessionControlNotify |
|
103 void ConnectComplete(); |
|
104 void ConnectComplete(const TDesC8& aConnectData); |
|
105 void ConnectComplete(CSubConnectionFlowBase& anSSP); |
|
106 void ConnectComplete(CSubConnectionFlowBase& anSSP,const TDesC8& aConnectData); |
|
107 void CanClose(MSessionControlNotify::TDelete aDelete=MSessionControlNotify::EDelete); |
|
108 void CanClose(const TDesC8& aDisconnectData,MSessionControlNotify::TDelete aDelete=MSessionControlNotify::EDelete); |
|
109 TInt Error(TInt anError,TUint anOperationMask); |
|
110 void Disconnect( ); |
|
111 void Disconnect(TDesC8& aDisconnectData); |
|
112 void IoctlComplete(TDesC8* aBuf); |
|
113 void DisconnectFromListener(CSubConnectionFlowBase& aSSP); |
|
114 void SetLocalNameComplete(); |
|
115 |
|
116 |
|
117 // MSessionDataNotify |
|
118 void NewData(TUint aCount); |
|
119 void CanSend(); |
|
120 |
|
121 protected: |
|
122 // CSubConnectionFlowBase |
|
123 virtual MFlowBinderControl* DoGetBinderControlL(); |
|
124 |
|
125 // Messages::ANode |
|
126 virtual void ReceivedL( |
|
127 const Messages::TRuntimeCtxId& aSender, |
|
128 const Messages::TNodeId& aRecipient, |
|
129 Messages::TSignatureBase& aMessage |
|
130 ); |
|
131 |
|
132 // Local methods |
|
133 void SubConnectionError( |
|
134 const Messages::TEBase::TError& errorMsg, |
|
135 TUint anOperationMask = (MSocketNotify::EErrorSend | MSocketNotify::EErrorConnect)); |
|
136 void BindToL(TCFDataClient::TBindTo& aBindTo); |
|
137 void Rejoin(const TCFFlow::TRejoin& aRejoinMessage); |
|
138 void StartFlow(); |
|
139 void StopFlow(TCFDataClient::TStop& aMessage); |
|
140 void ProcessDCIdleState(); |
|
141 void CompleteStart(TInt aError); |
|
142 void Destroy(); |
|
143 void PostNoBearer(); |
|
144 |
|
145 // Inline methods |
|
146 TBool NoBearerGuard() const { return iNoBearerRunning; } |
|
147 void SetNoBearerGuard() { iNoBearerRunning = ETrue; } |
|
148 void ClearNoBearerGuard() { iNoBearerRunning = EFalse; } |
|
149 void ClearUseBearerErrors() { iUseBearerErrors = EFalse; } |
|
150 TBool IsStopped() { return iIsStopped; } |
|
151 TBool IsHostResolver() const { return EFalse; } |
|
152 void SetIfInfo(const TSoIfConnectionInfo& aInfo) { iIfInfo = aInfo; } |
|
153 TBool IsBoundToSession() const {return iSessionControlNotify || iSessionDataNotify; } |
|
154 TBool ActivityRunning() {return NoBearerGuard();} |
|
155 |
|
156 |
|
157 private: |
|
158 // Flow binders |
|
159 MFlowBinderControl* iLowerFlow; |
|
160 MLowerControl* iLowerControl; //just to keep the lower flow up |
|
161 |
|
162 // Lower session binding |
|
163 MSessionControl* iFlowShim; |
|
164 MSessionData* iFlowShimData; |
|
165 |
|
166 // Upper session binding |
|
167 MSessionControlNotify* iSessionControlNotify; |
|
168 MSessionDataNotify* iSessionDataNotify; |
|
169 |
|
170 Messages::RRequestOriginator iStartRequest; |
|
171 |
|
172 // Local properties |
|
173 TSoIfConnectionInfo iIfInfo; |
|
174 TUint iUseBearerErrors:1; // error the socket on Error() upcalls from bearer rather than StopFlow() calls from SCPR |
|
175 TUint iIsStopped:1; // DataClientStop has been received. |
|
176 TUint iIsStarting:1; |
|
177 TBool iNoBearerRunning:1; // NoBearer message has been issued to SCPR |
|
178 TUint iStartActivityId:16; // If iIsStarting is set, iStartActivityId contains activity id that opened the TCFDataClient::TStarted channel |
|
179 TBool iIsStarted:1; |
|
180 |
|
181 enum TDCIdleState |
|
182 { |
|
183 EClientsPresent = 0, // presumption is we're always created for a client (ie HR or socket) |
|
184 EIdle = 1, |
|
185 EIdleSent = 2 |
|
186 }; |
|
187 TDCIdleState iDCIdle:2; |
|
188 }; |
|
189 |
|
190 } |
|
191 |
|
192 |
|
193 #endif // __DUMMYPR_NETWORK_FLOW_H__ |
|
194 |