1 /* |
|
2 * Copyright (c) 2006-2009 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: |
|
15 * Common header for the server and the client. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __TINTEGRITYSERVICESSERVER_H__ |
|
21 #define __TINTEGRITYSERVICESSERVER_H__ |
|
22 |
|
23 #include <e32base.h> |
|
24 #include "integrityservices.h" |
|
25 #include "tintegrityservicescommon.h" |
|
26 |
|
27 namespace Usif |
|
28 { |
|
29 |
|
30 enum TIntegrityServicesServerPanic |
|
31 { |
|
32 EPanicIntegrityServicesServerIllegalFunction = 10, |
|
33 }; |
|
34 |
|
35 |
|
36 /** |
|
37 * @test |
|
38 * @internalTechnology |
|
39 */ |
|
40 class CShutdownTimer : public CTimer |
|
41 { |
|
42 private: |
|
43 /** Server timeout shutdown delay (approximately 2 seconds) */ |
|
44 enum {KShutdownDelay=0x200000}; |
|
45 public: |
|
46 static CShutdownTimer* NewL(); |
|
47 /** Constructs shutdown timer */ |
|
48 inline CShutdownTimer(); |
|
49 /** Second-phase construction */ |
|
50 inline void ConstructL(); |
|
51 /** Starts server shutdown when the timer goes off */ |
|
52 inline void Start(); |
|
53 private: |
|
54 void RunL(); |
|
55 }; |
|
56 |
|
57 /** |
|
58 * @test |
|
59 * @internalTechnology |
|
60 */ |
|
61 class CIntegrityServicesServer : public CServer2 |
|
62 { |
|
63 public: |
|
64 /** |
|
65 * This function creates a new CServer2 object and leaves it on |
|
66 * the cleanup stack. |
|
67 */ |
|
68 static CIntegrityServicesServer* NewLC(); |
|
69 |
|
70 /** Increments session count */ |
|
71 void AddSession(); |
|
72 |
|
73 /** |
|
74 * Decrements session count and starts shutdown timer if session count is 0 |
|
75 */ |
|
76 void DropSession(); |
|
77 |
|
78 virtual ~CIntegrityServicesServer(); |
|
79 |
|
80 private: |
|
81 CIntegrityServicesServer(); |
|
82 |
|
83 /** |
|
84 * The second-phase constructor. |
|
85 */ |
|
86 void ConstructL(); |
|
87 |
|
88 private: |
|
89 /** |
|
90 * This function creates a new session object. |
|
91 */ |
|
92 virtual CSession2* NewSessionL(const TVersion& aVersion, |
|
93 const RMessage2& aMessage) const; |
|
94 |
|
95 private: |
|
96 // The number of sessions that are connected to the server. When this |
|
97 // number reaches 0, the server will initialize its shutdown. |
|
98 TInt iSessionCount; |
|
99 CShutdownTimer* iShutdown; |
|
100 }; |
|
101 |
|
102 |
|
103 |
|
104 /** |
|
105 * @test |
|
106 * @internalTechnology |
|
107 */ |
|
108 class CIntegrityServicesSession : public CSession2 |
|
109 { |
|
110 public: |
|
111 static CIntegrityServicesSession* NewL(); |
|
112 static CIntegrityServicesSession* NewLC(); |
|
113 void CreateL(); |
|
114 |
|
115 private: |
|
116 CIntegrityServicesSession(); |
|
117 |
|
118 virtual ~CIntegrityServicesSession(); |
|
119 |
|
120 /** |
|
121 * The second-phase constructor. |
|
122 */ |
|
123 void ConstructL(); |
|
124 |
|
125 /** Returns server reference */ |
|
126 CIntegrityServicesServer& Server(); |
|
127 |
|
128 virtual void ServiceL(const RMessage2& aMessage); |
|
129 |
|
130 virtual void ServiceError(const RMessage2& aMessage, TInt aError); |
|
131 |
|
132 CIntegrityServices* iIntegrityServices; |
|
133 }; |
|
134 |
|
135 } // end namespace Usif |
|
136 #endif // #ifndef __TINTEGRITYSERVICESSERVER_H__ |
|