1 /* |
|
2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Connection method manager server. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef CMMSERVER_H_ |
|
21 #define CMMSERVER_H_ |
|
22 |
|
23 #include <e32base.h> |
|
24 |
|
25 #include "cmmserverdefs.h" |
|
26 #include "cmmanagerimpl.h" |
|
27 |
|
28 class CCmmDelayedShutdown; |
|
29 |
|
30 |
|
31 /** |
|
32 * The main server class |
|
33 */ |
|
34 NONSHARABLE_CLASS( CCmmServer ) : public CPolicyServer |
|
35 { |
|
36 public: |
|
37 |
|
38 /** |
|
39 * Two phased construction. |
|
40 */ |
|
41 static CCmmServer* NewL(); |
|
42 |
|
43 /** |
|
44 * Two phased construction. |
|
45 */ |
|
46 static CCmmServer* NewLC(); |
|
47 |
|
48 /** |
|
49 * Destroy the object and release all memory objects |
|
50 */ |
|
51 ~CCmmServer(); |
|
52 |
|
53 /** |
|
54 * Increments the count of active sessions for this server. |
|
55 */ |
|
56 void IncrementSessions(); |
|
57 |
|
58 /** |
|
59 * Decrements the count of the active sessions for this server. |
|
60 * If no more sessions are in use the server terminates. |
|
61 */ |
|
62 void DecrementSessions(); |
|
63 |
|
64 /** |
|
65 * Produces object containers (needed by subsessions) with unique ids within the server. |
|
66 * @return A object container. |
|
67 */ |
|
68 CObjectCon* NewContainerL(); |
|
69 |
|
70 /** |
|
71 * Removes from index and deletes the object container. |
|
72 * @param aContainer The container to be deleted. |
|
73 * @return A object container. |
|
74 */ |
|
75 void RemoveContainer( CObjectCon* aContainer ); |
|
76 |
|
77 CCmManagerImpl* CmManager(); |
|
78 |
|
79 /** |
|
80 * Check for restrictions for adding an embedded destination from destination |
|
81 * instances of all clients. |
|
82 * @param aDestinationId The ID of the destination where a destination is |
|
83 * beeing embedded. |
|
84 * @param aEmbeddedDestinationId The ID of the destination that is beeing |
|
85 * embedded. |
|
86 */ |
|
87 TBool EmbeddedDestinationConflictsFromAllSessions( |
|
88 const TUint32 aDestinationId, |
|
89 const TUint32 aEmbeddedDestinationId ); |
|
90 |
|
91 /** |
|
92 * Notify each session about a destination/connection method that has been |
|
93 * updated to, or deleted from, database. |
|
94 */ |
|
95 void RefreshHandlesForAllSessions( const TUint32 aId ); |
|
96 |
|
97 /** |
|
98 * Custom security checking for IPCs marked with TSpecialCase::ECustomCheck. |
|
99 * @param aMsg The IPC message from the client. |
|
100 * @return The result of the security check (TCustomResult::EPass/TCustomResult::EFail). |
|
101 */ |
|
102 TCustomResult CustomSecurityCheckL( |
|
103 const RMessage2& aMsg, |
|
104 TInt& aAction, |
|
105 TSecurityInfo& aMissing ); |
|
106 |
|
107 /** |
|
108 * Checks the client's capabilities in the middle of request handling. Some |
|
109 * checks cannot be done with CustomSecurityCheckL() at the start phase of |
|
110 * the operation. |
|
111 * @param aMsg The IPC message from the client. |
|
112 * @return Returns ETrue if client has the needed capabilities. Otherwise |
|
113 * returns EFalse. |
|
114 */ |
|
115 CPolicyServer::TCustomResult CapabilityCheckWithProtection( const RMessage2& aMessage ); |
|
116 |
|
117 protected: // From CActive |
|
118 /** |
|
119 * Process any errors |
|
120 * |
|
121 * @param aError the leave code reported |
|
122 */ |
|
123 TInt RunError( TInt aError ); |
|
124 |
|
125 private: |
|
126 |
|
127 /** |
|
128 * Perform the first phase of two phase construction |
|
129 * |
|
130 * @param Priority for this thread |
|
131 */ |
|
132 CCmmServer( TInt aPriority ); |
|
133 |
|
134 /** |
|
135 * Perform the second phase construction |
|
136 */ |
|
137 void ConstructL() ; |
|
138 |
|
139 private: // From CServer |
|
140 |
|
141 /** |
|
142 * Create a time server session, and return a pointer to the |
|
143 * created object |
|
144 * |
|
145 * @param Version |
|
146 * |
|
147 * @result Pointer to the new session |
|
148 */ |
|
149 CSession2* NewSessionL( const TVersion& aVersion, const RMessage2& aMessage ) const; |
|
150 |
|
151 private: |
|
152 /** The number of client-server sessions */ |
|
153 TInt iSessionCount; |
|
154 |
|
155 static const TUint iCmmRangeCount; |
|
156 static const TInt iCmmRanges[]; |
|
157 static const TUint8 iCmmElementIndex[]; |
|
158 |
|
159 static const CPolicyServer::TPolicyElement iCmmElements[]; |
|
160 static const CPolicyServer::TPolicy iCmmPolicy; |
|
161 |
|
162 CCmManagerImpl* iCmManager; |
|
163 |
|
164 // Object container index |
|
165 CObjectConIx* iContainerIndex; |
|
166 |
|
167 // Pointer to the shutdown timer object |
|
168 CCmmDelayedShutdown* iShutdown; |
|
169 }; |
|
170 |
|
171 /** |
|
172 * CCmmDelayedShutdown |
|
173 * Shutdown timer that closes Connection Method Manager server after a period. |
|
174 */ |
|
175 NONSHARABLE_CLASS( CCmmDelayedShutdown ) : public CActive |
|
176 { |
|
177 public: |
|
178 CCmmDelayedShutdown( CCmmServer* aServer ); |
|
179 void ConstructL(); |
|
180 ~CCmmDelayedShutdown(); |
|
181 |
|
182 public: |
|
183 /** |
|
184 * Starts shutdown timer. |
|
185 * @return KErrNone if OK, otherwise a system wide error code. |
|
186 */ |
|
187 void Start(); |
|
188 |
|
189 private: |
|
190 /** |
|
191 * From CActive Cancels the shutdown timer. |
|
192 */ |
|
193 void DoCancel(); |
|
194 |
|
195 /** |
|
196 * From CActive Shuts the server down. |
|
197 */ |
|
198 void RunL(); |
|
199 |
|
200 private: // Data |
|
201 RTimer iTimer; |
|
202 CCmmServer* iServer; |
|
203 }; |
|
204 |
|
205 |
|
206 #endif // CMMSERVER_H_ |
|
207 |
|
208 // End of file |
|