|
1 /* |
|
2 * Copyright (c) 2008 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: Haptic server interface. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef HWRMHAPTICSSERVER_H |
|
20 #define HWRMHAPTICSSERVER_H |
|
21 |
|
22 #include "hwrmhapticsclientserver.h" |
|
23 |
|
24 class CHWRMHapticsPluginManager; |
|
25 class CHWRMHapticsReservationHandler; |
|
26 class CHWRMHapticsCommonData; |
|
27 class CHWRMHapticsShutdown; |
|
28 |
|
29 /** |
|
30 * Haptics server implementation. |
|
31 */ |
|
32 class CHWRMHapticsServer : public CPolicyServer |
|
33 { |
|
34 public: |
|
35 |
|
36 /** |
|
37 * Creates a new server. |
|
38 * |
|
39 * @param aPriority Priority of the server. |
|
40 * @return A pointer to the created object. |
|
41 */ |
|
42 static CHWRMHapticsServer* NewL( TInt aPriority ); |
|
43 |
|
44 /** |
|
45 * Creates a new server. Newly created instance is left onto |
|
46 * the cleanup stack. |
|
47 * |
|
48 * @param aPriority Priority of the server. |
|
49 * @return A pointer to the created object. |
|
50 */ |
|
51 static CHWRMHapticsServer* NewLC( TInt aPriority ); |
|
52 |
|
53 /** |
|
54 * Destructor. |
|
55 */ |
|
56 virtual ~CHWRMHapticsServer(); |
|
57 |
|
58 /** |
|
59 * Get pointer to plugin handler. Returns NULL if plugin manager |
|
60 * is not initialized yet. |
|
61 * |
|
62 * @return Pointer to correct plugin handler, or NULL if not created. |
|
63 */ |
|
64 CHWRMHapticsPluginManager* PluginManager() const; |
|
65 |
|
66 /** |
|
67 * Get pointer to reservation handler. Returns NULL if handler is |
|
68 * not initialized yet. |
|
69 * |
|
70 * @return Pointer to correct reservation handler, or NULL if not created. |
|
71 */ |
|
72 CHWRMHapticsReservationHandler* ReservationHandler() const; |
|
73 |
|
74 /** |
|
75 * Get pointer to Haptics common data. |
|
76 * |
|
77 * @return Pointer to haptics common data or NULL if resource |
|
78 not supported. |
|
79 */ |
|
80 CHWRMHapticsCommonData* HapticsCommonData() const; |
|
81 |
|
82 /** |
|
83 * Initializes Haptics service. Haptics is not initialized in |
|
84 * ConstructL in order to speed up the startup. |
|
85 */ |
|
86 void InitHaptics(); |
|
87 |
|
88 /** |
|
89 * Increases the amount of sessions connected to |
|
90 * this server (iSessionCount). |
|
91 */ |
|
92 void AddSession(); |
|
93 |
|
94 /** |
|
95 * Decreases the amount of sessions connected to |
|
96 * this server (iSessionCount). If the session count becomes |
|
97 * zero, starts the shutdown timer for shutting down this server. |
|
98 */ |
|
99 void DropSession(); |
|
100 |
|
101 private: |
|
102 |
|
103 /** |
|
104 * C++ constructor. |
|
105 * |
|
106 * @param aPriority The priority for this server. |
|
107 */ |
|
108 CHWRMHapticsServer( TInt aPriority ); |
|
109 /** |
|
110 * Symbian 2nd phase constructor. |
|
111 */ |
|
112 void ConstructL(); |
|
113 |
|
114 /** |
|
115 * Creates a new session when client connects. |
|
116 * |
|
117 * @param aVersion Version, which should match with the version of |
|
118 this server. |
|
119 * @param aMessage 'connect' message from the client |
|
120 * @return Pointer to created session or leaves with codes |
|
121 * KErrNotSupported if versions does not match |
|
122 * KErrNoMemory if creation of new session fails. |
|
123 */ |
|
124 CSession2* NewSessionL( const TVersion& aVersion, |
|
125 const RMessage2& aMessage ) const; |
|
126 |
|
127 private: |
|
128 |
|
129 /** |
|
130 * Plugin manager for this server. |
|
131 * Owned. |
|
132 */ |
|
133 CHWRMHapticsPluginManager* iHapticsPluginManager; |
|
134 |
|
135 /** |
|
136 * Reservation handler for this server. |
|
137 * Owned. |
|
138 */ |
|
139 CHWRMHapticsReservationHandler* iHapticsReservationHandler; |
|
140 |
|
141 /** |
|
142 * Common data of this server. |
|
143 * Owned. |
|
144 */ |
|
145 CHWRMHapticsCommonData* iHapticsCommonData; |
|
146 |
|
147 /** |
|
148 * Whether or not haptics has been initialized on the server. |
|
149 */ |
|
150 TBool iHapticsInitiated; |
|
151 |
|
152 /** |
|
153 * The amount of sessions currently in the server. |
|
154 */ |
|
155 TInt iSessionCount; |
|
156 |
|
157 /** |
|
158 * Shutdown timer instance. |
|
159 * Owned. |
|
160 */ |
|
161 CHWRMHapticsShutdown* iShutdown; |
|
162 }; |
|
163 |
|
164 #endif // HWRMHAPTICSSERVER_H |
|
165 |
|
166 // End of File |