|
1 /* |
|
2 * Copyright (c) 2006 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 the License "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: This file contains the header file of the |
|
15 * CWidgetRegistryServer class. |
|
16 * |
|
17 * This class implements the CWidgetRegistryServer class. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 #ifndef WIDGETREGISTRYSERVER_H |
|
23 #define WIDGETREGISTRYSERVER_H |
|
24 |
|
25 // INCLUDES |
|
26 #include <WidgetRegistryConstants.h> |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 |
|
30 // ---------------------------------------------------------------------------------------- |
|
31 // Server's policy here |
|
32 // ---------------------------------------------------------------------------------------- |
|
33 |
|
34 //Total number of ranges |
|
35 const TUint widgetRegistryCount = 3; |
|
36 |
|
37 //Definition of the ranges of IPC numbers |
|
38 const TInt widgetRegistryRanges[widgetRegistryCount] = |
|
39 { |
|
40 EOpCodeRegisterWidget, // 0 ; EOpCodeRegisterWidget,EOpCodeDeRegisterWidget |
|
41 EOpCodeDeRegisterWidget + 1, // 2 20 ; EOpCodeGetLprojName |
|
42 EOpCodeNotSupported |
|
43 }; |
|
44 |
|
45 //Policy to implement for each of the above ranges |
|
46 const TUint8 widgetRegistryElementsIndex[widgetRegistryCount] = |
|
47 { |
|
48 0, |
|
49 1, |
|
50 CPolicyServer::ENotSupported //applies to 3rd range (out of range IPC) |
|
51 }; |
|
52 |
|
53 //Specific capability checks |
|
54 const CPolicyServer::TPolicyElement widgetRegistryElements[] = |
|
55 { |
|
56 {_INIT_SECURITY_POLICY_C1(ECapabilityWriteDeviceData), CPolicyServer::EFailClient}, |
|
57 {_INIT_SECURITY_POLICY_C1(ECapabilityReadDeviceData), CPolicyServer::EFailClient} |
|
58 }; |
|
59 |
|
60 //Package all the above together into a policy |
|
61 const CPolicyServer::TPolicy widgetRegistryPolicy = |
|
62 { |
|
63 CPolicyServer::EAlwaysPass, //Allows clients to connect |
|
64 widgetRegistryCount, //number of ranges |
|
65 widgetRegistryRanges, //ranges array |
|
66 widgetRegistryElementsIndex,//elements<->ranges index |
|
67 widgetRegistryElements, //array of elements |
|
68 }; |
|
69 |
|
70 // FORWARD DECLARATIONS |
|
71 |
|
72 /** |
|
73 * |
|
74 * This class defines shut down timer usage for the widget registry server |
|
75 * @since 3.1 |
|
76 */ |
|
77 class CShutdown : public CTimer |
|
78 { |
|
79 |
|
80 public: |
|
81 /** |
|
82 * Constructor |
|
83 */ |
|
84 inline CShutdown():CTimer( -1 ) |
|
85 { |
|
86 CActiveScheduler::Add( this ); |
|
87 } |
|
88 |
|
89 /** |
|
90 * 2-phase constructor |
|
91 */ |
|
92 inline void ConstructL() |
|
93 { |
|
94 CTimer::ConstructL(); |
|
95 } |
|
96 |
|
97 /** |
|
98 * Start timer |
|
99 */ |
|
100 inline void Start() |
|
101 { |
|
102 After( KShutdownDelay ); |
|
103 } |
|
104 ~CShutdown() |
|
105 { |
|
106 } |
|
107 |
|
108 private: |
|
109 /* |
|
110 * From CActive, see base class header. |
|
111 */ |
|
112 void RunL(); |
|
113 |
|
114 }; |
|
115 |
|
116 |
|
117 /** |
|
118 * |
|
119 * This class defines the widget registry server |
|
120 * @since 3.1 |
|
121 */ |
|
122 class CWidgetRegistryServer : public CPolicyServer |
|
123 { |
|
124 public: |
|
125 |
|
126 /** |
|
127 * Returns singleton of factory. |
|
128 */ |
|
129 static CServer2* NewLC(); |
|
130 |
|
131 /** |
|
132 * Initialize and run the server. |
|
133 */ |
|
134 static void RunServerL(); |
|
135 |
|
136 /** |
|
137 * Cancel the shutdown timer, the new session is connected |
|
138 */ |
|
139 void AddSession(); |
|
140 |
|
141 /** |
|
142 * Decrement the session counter and start the shutdown timer if the last client |
|
143 * has disconnected |
|
144 */ |
|
145 void RemoveSession(); |
|
146 |
|
147 /** |
|
148 * Return session count |
|
149 */ |
|
150 TInt SessionCount(){ return iSessionCount; } |
|
151 |
|
152 private: |
|
153 /** |
|
154 * Constructor |
|
155 */ |
|
156 CWidgetRegistryServer(); |
|
157 |
|
158 /** |
|
159 * Destructor. |
|
160 */ |
|
161 ~CWidgetRegistryServer(); |
|
162 |
|
163 /** |
|
164 * 2-phase constructor |
|
165 */ |
|
166 void ConstructL(); |
|
167 |
|
168 /** |
|
169 * From CServer2 |
|
170 */ |
|
171 virtual CSession2* NewSessionL( |
|
172 const TVersion& aVersion, const RMessage2& aMessage ) const; |
|
173 |
|
174 private: // Data members |
|
175 TInt iSessionCount;// number of open sessions |
|
176 CShutdown iShutDown;// shut down timer |
|
177 }; |
|
178 |
|
179 #endif |