|
1 /* |
|
2 * Copyright (c) 2007 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: Implementation of customization components |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "ScreenSaverServer.h" |
|
21 #include "ScreenSaverClientServer.h" |
|
22 #include "ScreenSaverSession.h" |
|
23 |
|
24 #include "debug.h" |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 // ---------------------------------------------------------------------------------------- |
|
31 // Server startup code |
|
32 // ---------------------------------------------------------------------------------------- |
|
33 static void RunServerL() |
|
34 { |
|
35 // naming the server thread after the server helps to debug panics |
|
36 __UHEAP_MARK; |
|
37 |
|
38 User::LeaveIfError(User::RenameThread(KDMSSServerName)); |
|
39 |
|
40 // create and install the active scheduler |
|
41 |
|
42 CActiveScheduler* s=new(ELeave) CActiveScheduler; |
|
43 CleanupStack::PushL(s); |
|
44 CActiveScheduler::Install(s); |
|
45 __UHEAP_MARK; |
|
46 |
|
47 // create the server (leave it on the cleanup stack) |
|
48 CServer2 *t = CScreenSaverServer::NewLC(); |
|
49 // Initialisation complete, now signal the client |
|
50 |
|
51 RProcess::Rendezvous(KErrNone); |
|
52 |
|
53 // Ready to run |
|
54 RDEBUG("CScreenSaverServer is running"); |
|
55 CActiveScheduler::Start(); |
|
56 |
|
57 |
|
58 // Cleanup the server and scheduler |
|
59 CleanupStack::PopAndDestroy(t); |
|
60 __UHEAP_MARKEND; |
|
61 |
|
62 CleanupStack::PopAndDestroy(s); |
|
63 __UHEAP_MARKEND; |
|
64 } |
|
65 |
|
66 // Server process entry-point |
|
67 TInt E32Main() |
|
68 { |
|
69 __UHEAP_MARK; |
|
70 RDEBUG("CScreenSaverServer: E32Main"); |
|
71 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
72 TInt r=KErrNoMemory; |
|
73 if (cleanup) |
|
74 { |
|
75 TRAP(r,RunServerL()); |
|
76 RDEBUG_2("CScreenSaverServer closed with code: %d", r); |
|
77 delete cleanup; |
|
78 } |
|
79 __UHEAP_MARKEND; |
|
80 return r; |
|
81 } |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CShutDown::CShutdown() |
|
88 // ----------------------------------------------------------------------------- |
|
89 |
|
90 inline CShutdown::CShutdown() |
|
91 :CTimer(-1) |
|
92 { |
|
93 CActiveScheduler::Add(this); |
|
94 } |
|
95 |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CShutDown::ConstructL() |
|
99 // ----------------------------------------------------------------------------- |
|
100 |
|
101 inline void CShutdown::ConstructL() |
|
102 { |
|
103 CTimer::ConstructL(); |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CShutDown::Start() |
|
108 // ----------------------------------------------------------------------------- |
|
109 |
|
110 inline void CShutdown::Start() |
|
111 { |
|
112 |
|
113 RDEBUG( "creenSaverServer: starting shutdown timeout" ); |
|
114 |
|
115 After(KScreenSaverServerShutdownDelay); |
|
116 //SetActive(); |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // CShutDown::RunL() |
|
121 // ----------------------------------------------------------------------------- |
|
122 |
|
123 void CShutdown::RunL() |
|
124 { |
|
125 RDEBUG( "creenSaverServer timeout ... closing" ); |
|
126 CActiveScheduler::Stop(); |
|
127 } |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 CServer2* CScreenSaverServer::NewLC() |
|
133 { |
|
134 RDEBUG("CScreenSaverServer::NewLC - start"); |
|
135 |
|
136 CScreenSaverServer* self=new(ELeave) CScreenSaverServer; |
|
137 CleanupStack::PushL(self); |
|
138 self->ConstructL(); |
|
139 RDEBUG("CScreenSaverServer::NewLC - end"); |
|
140 return self; |
|
141 } |
|
142 |
|
143 |
|
144 |
|
145 void CScreenSaverServer::ConstructL() |
|
146 { |
|
147 RDEBUG("CScreenSaverServer::ConstructL start"); |
|
148 |
|
149 StartL(KDMSSServerName); |
|
150 iShutdown.ConstructL(); |
|
151 iShutdown.Start(); |
|
152 |
|
153 RDEBUG("CScreenSaverServer::ConstructL end"); |
|
154 } |
|
155 |
|
156 |
|
157 CScreenSaverServer::CScreenSaverServer() :CServer2(0) |
|
158 { |
|
159 RDEBUG("CScreenSaverServer::CScreenSaverServer()"); |
|
160 } |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CApplicationManagementServer::AddSession() |
|
163 // ----------------------------------------------------------------------------- |
|
164 |
|
165 void CScreenSaverServer::AddSession() |
|
166 { |
|
167 // A new session is being created |
|
168 RDEBUG( "CScreenSaverServer::AddSession" ); |
|
169 ++iSessionCount; |
|
170 |
|
171 // Cancel the shutdown timer if it was running |
|
172 iShutdown.Cancel(); |
|
173 } |
|
174 |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CApplicationManagementServer::DropSession() |
|
178 // ----------------------------------------------------------------------------- |
|
179 |
|
180 void CScreenSaverServer::DropSession() |
|
181 { |
|
182 // A session is being destroyed |
|
183 RDEBUG( "CScreenSaverServer::DropSession" ); |
|
184 |
|
185 // Start the shutdown timer if it is the last session |
|
186 if ( --iSessionCount == 0 ) |
|
187 { |
|
188 iShutdown.Start(); |
|
189 } |
|
190 } |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 CScreenSaverServer::~CScreenSaverServer() |
|
196 { |
|
197 RDEBUG("CScreenSaverServer::CScreenSaverServer()"); |
|
198 } |
|
199 |
|
200 |
|
201 |
|
202 CSession2* CScreenSaverServer::NewSessionL(const TVersion&,const RMessage2&) const |
|
203 { |
|
204 RDEBUG("CScreenSaverServer::NewSessionL"); |
|
205 return new (ELeave) CScreenSaverSession(); |
|
206 } |
|
207 |
|
208 |
|
209 void CScreenSaverServer::GetAvailableScreenSaversL(RImplInfoPtrArray& aScreenSaverList) |
|
210 { |
|
211 RDEBUG("CScreenSaverServer::GetAvailableScreenSavers()"); |
|
212 CScreensaverPluginInterfaceDefinition::ListImplementationsL( aScreenSaverList ); |
|
213 REComSession::FinalClose(); |
|
214 } |