|
1 // Copyright (c) 2000-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 // server.h |
|
15 // Transient server example - server classes |
|
16 // |
|
17 // |
|
18 |
|
19 #ifndef __SENDPROXYSERVER_H__ |
|
20 #define __SENDPROXYSERVER_H__ |
|
21 |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <e32std.h> |
|
25 |
|
26 #include "SendProxyClientServer.h" |
|
27 |
|
28 #include <mclient.h> |
|
29 // Required for RMsvServerSession |
|
30 |
|
31 |
|
32 enum TSendProxyServerPanic |
|
33 { |
|
34 EPanicBadDescriptor, |
|
35 EPanicIllegalFunction, |
|
36 EPanicAlreadyReceiving |
|
37 }; |
|
38 |
|
39 void PanicClient(const RMessagePtr2& aMessage,TSendProxyServerPanic TSendProxyServerPanic); |
|
40 |
|
41 class CShutdown : public CTimer |
|
42 { |
|
43 enum {KSendProxyShutdownDelay=0x200000}; // approx 2s |
|
44 public: |
|
45 inline CShutdown(); |
|
46 inline void ConstructL(); |
|
47 inline void Start(); |
|
48 private: |
|
49 void RunL(); |
|
50 }; |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 // |
|
56 // Used to get acces to send recieve. |
|
57 // It is better to encapsulate this than use inheritence into the step. |
|
58 // |
|
59 |
|
60 class RMsvServerSessionTest: public RMsvServerSession |
|
61 { |
|
62 public : |
|
63 TInt SendReceive( TInt aFunction,const TIpcArgs& aArgs ) const; |
|
64 TInt SendReceive( TInt aFunction ) const; |
|
65 // All we want is to access. Since RSessionBase::SendReceive is protected so is RMsvServerSession::SendReceive |
|
66 // So as long as we derive from RSessionBase base we should be get access to SendReceive. |
|
67 |
|
68 void SendReceive( TInt aFunction,const TIpcArgs& aArgs,TRequestStatus& aRequestStatus ) const; |
|
69 void SendReceive( TInt aFunction,TRequestStatus& aRequestStatus) const; |
|
70 |
|
71 void SendReceiveAsync( TInt aFunction,const TIpcArgs& aArgs,TRequestStatus& aRequestStatus ) const; |
|
72 void SendReceiveAsync( TInt aFunction,TRequestStatus& aRequestStatus) const; |
|
73 |
|
74 TInt CreateSession(const TDesC& aServer,const TVersion& aVersion,TInt aAsyncMessageSlots); |
|
75 |
|
76 }; |
|
77 |
|
78 |
|
79 class CSendProxyServer : public CServer2 |
|
80 { |
|
81 public: |
|
82 static CServer2* NewLC(); |
|
83 void AddSession(); |
|
84 void DropSession(); |
|
85 |
|
86 private: |
|
87 CSendProxyServer(); |
|
88 void ConstructL(); |
|
89 CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; |
|
90 private: |
|
91 TInt iSessionCount; |
|
92 CShutdown iShutdown; |
|
93 |
|
94 }; |
|
95 |
|
96 |
|
97 |
|
98 // Just used to get acces to the array .iArgs. |
|
99 // This may be an inadequency of the API we can get buffers according to args |
|
100 // but not the RInts. |
|
101 // |
|
102 class RMessage2Derv : public RMessage2 |
|
103 { |
|
104 public: |
|
105 IMPORT_C TInt GetiArgs(TInt aPos) const; |
|
106 }; |
|
107 |
|
108 |
|
109 |
|
110 class CSendProxyServerSession : public CSession2 |
|
111 { |
|
112 public: |
|
113 CSendProxyServerSession(); |
|
114 void CreateL(); |
|
115 |
|
116 private: |
|
117 ~CSendProxyServerSession(); |
|
118 inline CSendProxyServer& Server(); |
|
119 void ServiceL(const RMessage2& aMessage); |
|
120 void ServiceError(const RMessage2& aMessage,TInt aError); |
|
121 inline TBool ReceivePending() const; |
|
122 |
|
123 |
|
124 private : |
|
125 void SetupTIpcArgL( const RMessage2Derv& aMessage, TInt aPos, TIpcArgs& atipcArgs); |
|
126 void SetupTIpcArgsL( const RMessage2Derv& aMessage, TIpcArgs& atipcArgs); |
|
127 |
|
128 void SetupReturnTIpcArgL(const RMessage2Derv& aMessage, TInt aPos); |
|
129 void SetupReturnTIpcArgsL(const RMessage2Derv& aMessage); |
|
130 |
|
131 void ReadCapabilities(TInt32& aServerCaps); |
|
132 |
|
133 void ClearBuffer(TInt aPos); |
|
134 void ClearBuffers(); |
|
135 TInt DoCommandL(const RMessage2Derv& aMessage ); |
|
136 |
|
137 private: |
|
138 RMessagePtr2 iReceiveMsg; |
|
139 TInt iReceiveLen; |
|
140 RMsvServerSessionTest iMsvServerSession; |
|
141 TInt iSessionCount; |
|
142 |
|
143 TSendProxyMessages iCommand; // Which type of send we are expected to perform. |
|
144 TInt iFlags; // from TIpcArgs, we use these flags to set up buffers if we require. |
|
145 RBuf8 iBuffer8[KMaxMessageArguments]; |
|
146 TPtr8* iTPtr8[KMaxMessageArguments]; |
|
147 |
|
148 RBuf16 iBuffer16[KMaxMessageArguments]; |
|
149 TPtr16* iTPtr16[KMaxMessageArguments]; |
|
150 |
|
151 }; |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 //TInt StartMsvServer(); |
|
159 |
|
160 |
|
161 #endif // __SENDPROXYSERVER_H__ |
|
162 |