|
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 "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: Server shutdown implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // ======== |
|
21 // INCLUDES |
|
22 // ======== |
|
23 |
|
24 #include "ShutdownServer.h" |
|
25 |
|
26 // ====================== |
|
27 // METHOD IMPLEMENTATIONS |
|
28 // ====================== |
|
29 |
|
30 // ========================================================================== |
|
31 // FUNCTION: NewL |
|
32 // ========================================================================== |
|
33 CShutdownServer* CShutdownServer::NewL() |
|
34 { |
|
35 CShutdownServer* self = new (ELeave) CShutdownServer; |
|
36 CleanupStack::PushL(self); |
|
37 self->ConstructL(); |
|
38 CleanupStack::Pop(self); |
|
39 return self; |
|
40 } // end NewL |
|
41 |
|
42 // ========================================================================== |
|
43 // FUNCTION: Constructor |
|
44 // ========================================================================== |
|
45 CShutdownServer::CShutdownServer() |
|
46 :CTimer(-1) |
|
47 { |
|
48 __LOG_CONSTRUCT( "msg", "CShutdownServer" ) |
|
49 CActiveScheduler::Add(this); |
|
50 } // end constructor |
|
51 |
|
52 // ========================================================================== |
|
53 // FUNCTION: Destructor |
|
54 // ========================================================================== |
|
55 CShutdownServer::~CShutdownServer() |
|
56 { |
|
57 __LOG_DESTRUCT |
|
58 } // end destructor |
|
59 |
|
60 // ========================================================================== |
|
61 // FUNCTION: ConstructL |
|
62 // ========================================================================== |
|
63 void CShutdownServer::ConstructL() |
|
64 { |
|
65 CTimer::ConstructL(); |
|
66 } // end ConstructL |
|
67 |
|
68 // ========================================================================== |
|
69 // FUNCTION: Start |
|
70 // ========================================================================== |
|
71 void CShutdownServer::Start( TTimeIntervalMicroSeconds32 aShutdownDelay ) |
|
72 { |
|
73 __LOG_ENTER( "Start" ) |
|
74 |
|
75 After( aShutdownDelay ); |
|
76 |
|
77 __LOG_EXIT |
|
78 } // end Start |
|
79 |
|
80 // ========================================================================== |
|
81 // FUNCTION: Stop |
|
82 // ========================================================================== |
|
83 void CShutdownServer::Stop() |
|
84 { |
|
85 __LOG_ENTER( "Stop" ) |
|
86 |
|
87 Cancel(); |
|
88 iShutdown = EFalse; |
|
89 |
|
90 __LOG_EXIT |
|
91 } // end Stop |
|
92 |
|
93 // ========================================================================== |
|
94 // FUNCTION: ShutDownNow |
|
95 // ========================================================================== |
|
96 void CShutdownServer::ShutDownNow() |
|
97 { |
|
98 __LOG_ENTER( "ShutDownNow" ) |
|
99 |
|
100 // Stop the active scheduler, which shuts down the server. |
|
101 CActiveScheduler::Stop(); |
|
102 |
|
103 __LOG_EXIT |
|
104 } // end ShutDownNow |
|
105 |
|
106 // ========================================================================== |
|
107 // FUNCTION: RunL |
|
108 // ========================================================================== |
|
109 void CShutdownServer::RunL() |
|
110 { |
|
111 __LOG_ENTER( "RunL" ) |
|
112 if( iBackgroundOperationsInProgress ) |
|
113 { |
|
114 // Wait until background operations are completed. |
|
115 __LOG_WRITE_INFO( "Background operations in progress" ); |
|
116 iShutdown = ETrue; |
|
117 } |
|
118 else |
|
119 { |
|
120 ShutDownNow(); |
|
121 } // end if |
|
122 __LOG_EXIT |
|
123 } // end RunL |
|
124 |
|
125 // ========================================================================== |
|
126 // FUNCTION: BackgroundOperationsInProgress |
|
127 // ========================================================================== |
|
128 void CShutdownServer::BackgroundOperationsInProgress() |
|
129 { |
|
130 __LOG_ENTER( "BackgroundOperationsInProgress" ) |
|
131 |
|
132 iBackgroundOperationsInProgress = ETrue; |
|
133 |
|
134 __LOG_EXIT |
|
135 } // end BackgroundOperationsInProgress |
|
136 |
|
137 // ========================================================================== |
|
138 // FUNCTION: BackgroundOperationsCompleted |
|
139 // ========================================================================== |
|
140 void CShutdownServer::BackgroundOperationsCompleted() |
|
141 { |
|
142 __LOG_ENTER( "BackgroundOperationsCompleted" ) |
|
143 |
|
144 if( iShutdown ) |
|
145 { |
|
146 ShutDownNow(); |
|
147 } |
|
148 else |
|
149 { |
|
150 iBackgroundOperationsInProgress = EFalse; |
|
151 } // end if |
|
152 |
|
153 __LOG_EXIT |
|
154 } // end BackgroundOperationsCompleted |