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