1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 // |
7 // |
8 // Initial Contributors: |
8 // Initial Contributors: |
9 // Nokia Corporation - initial contribution. |
9 // Nokia Corporation - initial contribution. |
10 // |
10 // |
11 // Contributors: |
11 // Contributors: |
12 // |
12 // |
13 // Description: |
13 // Description: |
14 // |
14 // apaserverapp.h |
15 |
15 // |
16 #ifndef APASERVERAPP_H |
16 |
17 #define APASERVERAPP_H |
17 #ifndef APASERVERAPP_H__ |
18 |
18 #define APASERVERAPP_H__ |
19 #include <e32base.h> |
19 |
20 |
20 #include <e32base.h> // class RSessionBase |
21 |
21 |
22 // |
22 |
23 // Server application client support |
|
24 // |
|
25 |
|
26 |
|
27 |
|
28 class RApaAppServiceBase : public RSessionBase |
|
29 /** Server app connection and lifetime monitoring functionality. |
23 /** Server app connection and lifetime monitoring functionality. |
30 |
24 |
31 This is the base class for all server application service client |
25 This is the base class for all server application service client |
32 support implementations. |
26 support implementations. |
33 |
27 |
38 the interface to the server application implementations of the services. |
32 the interface to the server application implementations of the services. |
39 |
33 |
40 @publishedPartner |
34 @publishedPartner |
41 @released |
35 @released |
42 @see REikAppServiceBase */ |
36 @see REikAppServiceBase */ |
43 { |
37 class RApaAppServiceBase : public RSessionBase |
44 public: |
38 { |
45 |
39 public: |
46 /** Constants defining the base IPC command ids usable by the system GUI and services. */ |
40 /** Constants defining the base IPC command ids usable by the system GUI and services. */ |
47 enum TApaAppServiceBaseCmdConstants |
41 enum TApaAppServiceBaseCmdConstants |
48 { |
42 { |
49 /** System GUI server app command IDs must start from this base. */ |
43 /** System GUI server app command IDs must start from this base. */ |
50 KSystemGuiCmdBase = 0x100, |
44 KSystemGuiCmdBase = 0x100, |
51 /** Service specific command IDs must start from this base. */ |
45 /** Service specific command IDs must start from this base. */ |
52 KServiceCmdBase = 0x200 |
46 KServiceCmdBase = 0x200 |
53 }; |
47 }; |
54 |
|
55 public: |
48 public: |
56 IMPORT_C void ConnectExistingAppL(const RApaAppServiceBase& aClient); |
49 IMPORT_C void ConnectExistingAppL(const RApaAppServiceBase& aClient); |
57 IMPORT_C void ConnectExistingAppL(const RApaAppServiceBase& aClient, const TSecurityPolicy& aSecurityPolicy); |
50 IMPORT_C void ConnectExistingAppL(const RApaAppServiceBase& aClient, const TSecurityPolicy& aSecurityPolicy); |
58 IMPORT_C void ConnectExistingByNameL(const TDesC& aName); |
51 IMPORT_C void ConnectExistingByNameL(const TDesC& aName); |
59 IMPORT_C void ConnectExistingByNameL(const TDesC& aServerName, const TSecurityPolicy& aSecurityPolicy); |
52 IMPORT_C void ConnectExistingByNameL(const TDesC& aServerName, const TSecurityPolicy& aSecurityPolicy); |
62 |
55 |
63 IMPORT_C void NotifyServerExit(TRequestStatus& aStatus) const; |
56 IMPORT_C void NotifyServerExit(TRequestStatus& aStatus) const; |
64 IMPORT_C void CancelNotifyServerExit() const; |
57 IMPORT_C void CancelNotifyServerExit() const; |
65 |
58 |
66 IMPORT_C TPtrC ServerName() const; |
59 IMPORT_C TPtrC ServerName() const; |
67 |
|
68 protected: |
60 protected: |
69 IMPORT_C RApaAppServiceBase(); |
61 IMPORT_C RApaAppServiceBase(); |
70 |
|
71 private: |
62 private: |
72 IMPORT_C virtual void RApaAppServiceBase_Reserved1(); |
63 IMPORT_C virtual void RApaAppServiceBase_Reserved1(); |
73 IMPORT_C virtual void RApaAppServiceBase_Reserved2(); |
64 IMPORT_C virtual void RApaAppServiceBase_Reserved2(); |
74 |
65 |
75 /** Returns the UID of the service that this session provides an interface for. |
66 /** Returns the UID of the service that this session provides an interface for. |
76 Client side service implementations must implement this function to return |
67 Client side service implementations must implement this function to return |
77 the UID for the service that they implement. |
68 the UID for the service that they implement. |
78 @return The UID of the service implemented by the derived class.*/ |
69 @return The UID of the service implemented by the derived class.*/ |
79 virtual TUid ServiceUid() const = 0; |
70 virtual TUid ServiceUid() const = 0; |
80 |
|
81 private: |
71 private: |
82 void ConnectL(); |
72 void ConnectL(); |
83 void ConnectL(const TSecurityPolicy& aSecurityPolicy); |
73 void ConnectL(const TSecurityPolicy& aSecurityPolicy); |
84 |
|
85 private: |
74 private: |
86 IMPORT_C virtual void ExtensionInterface(TUid aInterfaceId, TAny*& aImplementaion); |
75 IMPORT_C virtual void ExtensionInterface(TUid aInterfaceId, TAny*& aImplementaion); |
87 |
|
88 private: |
76 private: |
89 HBufC* iServerName; // owned |
77 HBufC* iServerName; // owned |
90 TInt iApaReserved1; |
78 TInt iApaReserved1; |
91 TInt iApaReserved2; |
79 TInt iApaReserved2; |
92 }; |
80 }; |
93 |
81 |
94 |
82 |
95 class MApaServerAppExitObserver |
|
96 /** Interface for a class that wants to receive exit notification from |
83 /** Interface for a class that wants to receive exit notification from |
97 a server application. |
84 a server application. |
98 |
85 |
99 @publishedPartner |
86 @publishedPartner |
100 @released |
87 @released |
101 @see CApaServerAppExitMonitor*/ |
88 @see CApaServerAppExitMonitor*/ |
|
89 class MApaServerAppExitObserver |
102 { |
90 { |
103 public: |
91 public: |
104 /** Receives server exit notification. |
92 /** Receives server exit notification. |
105 Implementers of this interface must override this function to |
93 Implementers of this interface must override this function to |
106 receive notification of server app exit reasons. |
94 receive notification of server app exit reasons. |
116 private: |
104 private: |
117 TInt iMApaServerAppExitObserver_Reserved1; |
105 TInt iMApaServerAppExitObserver_Reserved1; |
118 }; |
106 }; |
119 |
107 |
120 |
108 |
121 class CApaServerAppExitMonitor : public CActive |
|
122 /** Helper class that monitors the lifetime of a server app |
109 /** Helper class that monitors the lifetime of a server app |
123 through a connected RApaAppServiceBase and reports server app exits |
110 through a connected RApaAppServiceBase and reports server app exits |
124 to a MApaServerAppExitObserver derived class. |
111 to a MApaServerAppExitObserver derived class. |
125 |
112 |
126 @publishedPartner |
113 @publishedPartner |
127 @released |
114 @released |
128 @see RApaAppServiceBase |
115 @see RApaAppServiceBase |
129 @see MApaServerAppExitObserver */ |
116 @see MApaServerAppExitObserver */ |
|
117 NONSHARABLE_CLASS(CApaServerAppExitMonitor) : public CActive |
130 { |
118 { |
131 public: |
119 public: |
132 IMPORT_C static CApaServerAppExitMonitor* NewL(RApaAppServiceBase& aClient, MApaServerAppExitObserver& aObserver, TInt aPriority); |
120 IMPORT_C static CApaServerAppExitMonitor* NewL(RApaAppServiceBase& aClient, MApaServerAppExitObserver& aObserver, TInt aPriority); |
133 IMPORT_C static CApaServerAppExitMonitor* NewLC(RApaAppServiceBase& aClient, MApaServerAppExitObserver& aObserver, TInt aPriority); |
121 IMPORT_C static CApaServerAppExitMonitor* NewLC(RApaAppServiceBase& aClient, MApaServerAppExitObserver& aObserver, TInt aPriority); |
134 IMPORT_C ~CApaServerAppExitMonitor(); |
122 IMPORT_C ~CApaServerAppExitMonitor(); |
135 |
|
136 private: |
123 private: |
137 CApaServerAppExitMonitor(RApaAppServiceBase& aClient, MApaServerAppExitObserver& aObserver, TInt aPriority); |
124 CApaServerAppExitMonitor(RApaAppServiceBase& aClient, MApaServerAppExitObserver& aObserver, TInt aPriority); |
138 |
|
139 private: // from CActive |
125 private: // from CActive |
140 void RunL(); |
126 void RunL(); |
141 void DoCancel(); |
127 void DoCancel(); |
142 TInt RunError(TInt aError); |
128 TInt RunError(TInt aError); |
143 |
|
144 private: |
129 private: |
145 RApaAppServiceBase& iClient; |
130 RApaAppServiceBase& iClient; |
146 MApaServerAppExitObserver& iObserver; |
131 MApaServerAppExitObserver& iObserver; |
147 }; |
132 }; |
148 |
133 |
149 |
134 |
150 // |
135 // |
151 // Server application server support |
136 // Server application server support |
152 // |
137 // |
153 |
138 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
154 /** Panic codes that the server application framework can generate. |
139 /** Panic codes that the server application framework can generate. |
155 @internalComponent */ |
140 @internalComponent */ |
156 enum TApaAppServerPanic |
141 enum TApaAppServerPanic |
157 { |
142 { |
158 /** The IPC message ID used by the client is not recognised. */ |
143 /** The IPC message ID used by the client is not recognised. */ |
160 /** The client already has an active notification of server exit. */ |
145 /** The client already has an active notification of server exit. */ |
161 EApaAppServerPanicNotifyExitActive, |
146 EApaAppServerPanicNotifyExitActive, |
162 /** The client has tried to connect an already connected session. */ |
147 /** The client has tried to connect an already connected session. */ |
163 EApaAppServerPanicClientAlreadyConnected |
148 EApaAppServerPanicClientAlreadyConnected |
164 }; |
149 }; |
165 |
150 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS |
166 |
151 |
167 class CApaAppServiceBase : public CSession2 |
|
168 /** Base class for all service implementations. |
152 /** Base class for all service implementations. |
169 Provides the basic IPC and security framework that server applications |
153 Provides the basic IPC and security framework that server applications |
170 can use to receive messages from their clients. |
154 can use to receive messages from their clients. |
171 In a typical service implementation, a service support class |
155 In a typical service implementation, a service support class |
172 will be derived from this class, and the service implementation |
156 will be derived from this class, and the service implementation |
177 |
161 |
178 @publishedPartner |
162 @publishedPartner |
179 @released |
163 @released |
180 @see CApaAppServer |
164 @see CApaAppServer |
181 @see CPolicyServer */ |
165 @see CPolicyServer */ |
|
166 class CApaAppServiceBase : public CSession2 |
182 { |
167 { |
183 public: |
168 public: |
184 IMPORT_C CApaAppServiceBase(); |
169 IMPORT_C CApaAppServiceBase(); |
185 IMPORT_C ~CApaAppServiceBase(); |
170 IMPORT_C ~CApaAppServiceBase(); |
186 |
171 |
187 IMPORT_C virtual CPolicyServer::TCustomResult SecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing); |
172 IMPORT_C virtual CPolicyServer::TCustomResult SecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing); |
188 |
|
189 public: // internal |
173 public: // internal |
190 void SendAppServerExitNotification(TInt aExitReason); |
174 void SendAppServerExitNotification(TInt aExitReason); |
191 |
|
192 protected: // from CSession2 |
175 protected: // from CSession2 |
193 IMPORT_C void CreateL(); |
176 IMPORT_C void CreateL(); |
194 IMPORT_C void ServiceL(const RMessage2& aMessage); |
177 IMPORT_C void ServiceL(const RMessage2& aMessage); |
195 IMPORT_C void ServiceError(const RMessage2& aMessage,TInt aError); |
178 IMPORT_C void ServiceError(const RMessage2& aMessage,TInt aError); |
196 IMPORT_C virtual TInt CountResources(); |
179 IMPORT_C virtual TInt CountResources(); |
197 IMPORT_C virtual void Disconnect(const RMessage2& aMessage); |
180 IMPORT_C virtual void Disconnect(const RMessage2& aMessage); |
198 |
|
199 private: // Server exit notification handlers |
181 private: // Server exit notification handlers |
200 void NotifyServerExit(const RMessage2& aMessage); |
182 void NotifyServerExit(const RMessage2& aMessage); |
201 void CancelNotifyServerExit(const RMessage2& aMessage) const; |
183 void CancelNotifyServerExit(const RMessage2& aMessage) const; |
202 |
|
203 private: |
184 private: |
204 IMPORT_C virtual void ExtensionInterface(TUid aInterfaceId, TAny*& aImplementaion); |
185 IMPORT_C virtual void ExtensionInterface(TUid aInterfaceId, TAny*& aImplementaion); |
205 IMPORT_C virtual void CApaAppServiceBase_Reserved1(); |
186 IMPORT_C virtual void CApaAppServiceBase_Reserved1(); |
206 IMPORT_C virtual void CApaAppServiceBase_Reserved2(); |
187 IMPORT_C virtual void CApaAppServiceBase_Reserved2(); |
207 |
|
208 private: |
188 private: |
209 RMessagePtr2 iNotifyExitMsg; |
189 RMessagePtr2 iNotifyExitMsg; |
210 TInt iExitReason; |
190 TInt iExitReason; |
211 TInt iApaReserved2; |
191 TInt iApaReserved2; |
212 }; |
192 }; |
213 |
193 |
214 class CApaAppServer : public CPolicyServer |
194 |
215 /** Base class for all server application's servers. |
195 /** Base class for all server application's servers. |
216 Server applications must derive from this class to implement their |
196 Server applications must derive from this class to implement their |
217 servers. These must be instantiated in an override of |
197 servers. These must be instantiated in an override of |
218 CApaApplication::NewAppServerL(). |
198 CApaApplication::NewAppServerL(). |
219 The main task of this class is to create service implementations |
199 The main task of this class is to create service implementations |
221 |
201 |
222 @publishedPartner |
202 @publishedPartner |
223 @released |
203 @released |
224 @see CEikAppServer |
204 @see CEikAppServer |
225 @see CPolicyServer */ |
205 @see CPolicyServer */ |
|
206 class CApaAppServer : public CPolicyServer |
226 { |
207 { |
227 public: |
208 public: |
228 IMPORT_C ~CApaAppServer(); |
209 IMPORT_C ~CApaAppServer(); |
229 IMPORT_C virtual void ConstructL(const TDesC& aFixedServerName); |
210 IMPORT_C virtual void ConstructL(const TDesC& aFixedServerName); |
230 |
|
231 IMPORT_C void NotifyServerExit(TInt aReason); |
211 IMPORT_C void NotifyServerExit(TInt aReason); |
232 |
|
233 IMPORT_C virtual CApaAppServiceBase* CreateServiceL(TUid aServiceType) const; |
212 IMPORT_C virtual CApaAppServiceBase* CreateServiceL(TUid aServiceType) const; |
234 IMPORT_C virtual TCustomResult CreateServiceSecurityCheckL(TUid aServiceType, const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing); |
213 IMPORT_C virtual TCustomResult CreateServiceSecurityCheckL(TUid aServiceType, const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing); |
235 |
|
236 protected: |
214 protected: |
237 IMPORT_C CApaAppServer(); |
215 IMPORT_C CApaAppServer(); |
238 |
216 protected: // from CPolicyServer |
239 // From CPolicyServer |
|
240 IMPORT_C TCustomResult CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing); |
217 IMPORT_C TCustomResult CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing); |
241 // From CServer2 |
218 protected: // from CServer2 |
242 IMPORT_C virtual void DoConnect(const RMessage2& aMessage); |
219 IMPORT_C virtual void DoConnect(const RMessage2& aMessage); |
243 |
220 private: // from CServer2 |
244 private: |
|
245 IMPORT_C CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; |
221 IMPORT_C CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; |
246 |
|
247 private: |
222 private: |
248 TUid ConnectMessageServiceUid(const RMessage2& aMsg) const; |
223 TUid ConnectMessageServiceUid(const RMessage2& aMsg) const; |
249 |
|
250 private: |
224 private: |
251 IMPORT_C virtual void ExtensionInterface(TUid aInterfaceId, TAny*& aImplementaion); |
225 IMPORT_C virtual void ExtensionInterface(TUid aInterfaceId, TAny*& aImplementaion); |
252 // Extensions |
226 // Extensions |
253 IMPORT_C virtual void CApaAppServer_Reserved1(); |
227 IMPORT_C virtual void CApaAppServer_Reserved1(); |
254 IMPORT_C virtual void CApaAppServer_Reserved2(); |
228 IMPORT_C virtual void CApaAppServer_Reserved2(); |
255 |
|
256 private: |
229 private: |
257 TInt iApaReserved1; |
230 TInt iApaReserved1; |
258 TInt iApaReserved2; |
231 TInt iApaReserved2; |
259 }; |
232 }; |
260 |
233 |
261 |
234 |
262 #endif |
235 #endif // APASERVERAPP_H__ |