|
1 // Copyright (c) 1997-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 #if !defined(__SS_SOCK_H__) |
|
17 #define __SS_SOCK_H__ |
|
18 |
|
19 #include <comms-infras/ss_intsock.h> |
|
20 |
|
21 #define SYMBIAN_NETWORKING_UPS |
|
22 |
|
23 #ifdef SYMBIAN_NETWORKING_UPS |
|
24 #include <comms-infras/ss_platsec_apiext.h> // ASockSubSessionPlatsecApiExt |
|
25 #endif //SYMBIAN_NETWORKING_UPS |
|
26 |
|
27 //#include <es_prot.h> |
|
28 #include <es_enum.h> |
|
29 #include <e32base.h> |
|
30 #include <comms-infras/ss_flowbinders.h> |
|
31 #include <comms-infras/ss_nodeinterfaces.h> |
|
32 #include "ss_flowrequest.h" |
|
33 |
|
34 class CWaitForMBufs; |
|
35 class CProtocolBase; |
|
36 class ProtocolManager; |
|
37 class CInternalSocketImpl; |
|
38 |
|
39 namespace ESock |
|
40 { |
|
41 |
|
42 NONSHARABLE_CLASS(CSocketMessage) : public CBase, public AMessage |
|
43 { |
|
44 public: |
|
45 virtual void AcquireMessage ( AMessage* aMessage ); |
|
46 inline void SetMessage ( Den::RSafeMessage& aMessage ); |
|
47 inline void ProcessedMessage (); |
|
48 |
|
49 |
|
50 private: |
|
51 virtual TInt ReadDes(TInt aSrcParamIndex,TDes8 &aDes,TInt anOffset=0); |
|
52 virtual TInt ReadInt(TInt aSrcParamIndex); |
|
53 virtual TInt ReadMBuf(TInt aSrcParamIndex, RMBufChain& aBufChain); |
|
54 virtual void InitMBuf(TInt aParamIndex); |
|
55 virtual TInt WriteDes(TInt aDstParamIndex,const TDesC8& aDes,TInt anOffset=0); |
|
56 virtual TInt WriteMBuf(TInt aDstParamIndex,RMBufChain& aBufChain); |
|
57 |
|
58 virtual void CompleteMessage(TInt anError); |
|
59 |
|
60 virtual TBool IsNull (TInt aParamIndex); |
|
61 |
|
62 #ifdef SYMBIAN_NETWORKING_UPS |
|
63 TInt GetProcessAndThreadId(TProcessId& /*aProcessId*/, TThreadId& /*aThreadId*/) const; |
|
64 inline const Den::RSafeMessage& Message() const; |
|
65 #endif |
|
66 |
|
67 inline Den::RSafeMessage& Message (); |
|
68 private: |
|
69 Den::RSafeMessage iMessage; // Not owned |
|
70 }; |
|
71 |
|
72 NONSHARABLE_CLASS(CSocket) : public CSockSubSession, public ASocket |
|
73 /** |
|
74 Represents client-facing part of socket. |
|
75 Implements ESOCK client socket sub-session specific handling. |
|
76 Deals with RMessage2, player and session properties |
|
77 @see ASocket |
|
78 @internalTechnology |
|
79 */ |
|
80 { |
|
81 friend class ::ProtocolManager; |
|
82 friend class ::Nif; |
|
83 friend class ::CInternalSocketImpl; // need access to TSocketState enum - for esock "internal sockets" |
|
84 typedef CSockSubSession inherited; |
|
85 |
|
86 public: |
|
87 static CSocket* NewLC(TServerProtocolDesc* aServiceInfo, CSockSession* aSession, CPlayer* aPlayer, CProtocolBase* aProt, const TSubSessionUniqueId aSubSessionUniqueId, TInt aSocketType); |
|
88 virtual ~CSocket(); |
|
89 virtual Den::TSubSessInfo Type() const |
|
90 { |
|
91 return TCFSubSessInfo(TCFSubSessInfo::ESocket); |
|
92 } |
|
93 |
|
94 virtual const Messages::RNodeInterface* ServiceProvider() const; |
|
95 |
|
96 // Request service routines. |
|
97 void ConnectL(); |
|
98 void ShutdownL(); |
|
99 TBool CloseSocket(); |
|
100 void ListenL(); |
|
101 |
|
102 void SetSockOptionL(); |
|
103 void GetSockOptionL(); |
|
104 void IoctlL(); |
|
105 void ReferenceL(); |
|
106 |
|
107 virtual void ProcessMessageL(); |
|
108 |
|
109 virtual void InitiateDestruction(); |
|
110 |
|
111 void AdoptFlowRequestMessage(const RMessage2& aFlowRequestMessage) |
|
112 { |
|
113 iFlowRequestMessage.Adopt(static_cast<Den::RSafeMessage&>(const_cast<RMessage2&>(aFlowRequestMessage))); |
|
114 } |
|
115 void CompleteFlowRequestMessage(TInt err); |
|
116 |
|
117 private: |
|
118 CSocket(CSockSession* aSession, CPlayer* aPlayer, const TSubSessionUniqueId aSubSessionUniqueId, TInt aSocketType); |
|
119 |
|
120 |
|
121 virtual void SetClosing(); |
|
122 virtual TBool IsClosing(); |
|
123 |
|
124 virtual void DontCompleteCurrentRequest(); |
|
125 |
|
126 virtual ASocket* InitiateAcceptingSocket(); |
|
127 virtual ASocket* GetAcceptingSocket(); |
|
128 |
|
129 virtual void PanicSocketClient(TESockPanic aPanic); |
|
130 virtual void SetReturn(TInt aReturnValue) const; |
|
131 |
|
132 virtual void GetOwnerInfo(TProcessId& aProcId, TSoOwnerInfo& aInfo, TThreadId& aThreadId); |
|
133 virtual TInt SecurityCheck(); |
|
134 |
|
135 void FinalCompleteAllBlockedMessages(TInt aResult); |
|
136 |
|
137 void ConstructL (CProtocolBase* aProtocol); |
|
138 void InitUserMessageL ( TSocketMessage aMessage ); |
|
139 |
|
140 virtual TDes8* BorrowTemporaryBuffer(TInt aSize); |
|
141 virtual TDes8* BorrowTemporaryBufferL(TInt aSize); |
|
142 private: |
|
143 Den::RSafeMessage iFlowRequestMessage; |
|
144 }; |
|
145 |
|
146 // --------------------------------------------- |
|
147 inline void CSocketMessage::SetMessage ( Den::RSafeMessage& aMessage ) |
|
148 { |
|
149 iMessage.Duplicate(aMessage); |
|
150 } |
|
151 |
|
152 inline void CSocketMessage::ProcessedMessage () |
|
153 { |
|
154 // Resets the handle to reflect the fact that the message has been processed |
|
155 iMessage.ResetHandle(); |
|
156 } |
|
157 inline Den::RSafeMessage& CSocketMessage::Message () |
|
158 { |
|
159 return iMessage; |
|
160 } |
|
161 |
|
162 inline const Den::RSafeMessage& CSocketMessage::Message() const |
|
163 { |
|
164 return iMessage; |
|
165 } |
|
166 |
|
167 } //namespace ESock |
|
168 |
|
169 #endif |
|
170 // __SS_SOCK_H__ |