|
64
|
1 |
/*
|
|
|
2 |
* Copyright (c) 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 "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 |
* Header definition for EmailServerMonitor
|
|
|
16 |
*
|
|
|
17 |
*/
|
|
|
18 |
|
|
|
19 |
#ifndef EMAILSERVERMONITOR_H
|
|
|
20 |
#define EMAILSERVERMONITOR_H
|
|
|
21 |
|
|
|
22 |
// Include Files
|
|
|
23 |
|
|
|
24 |
#include <e32base.h>
|
|
|
25 |
#include <e32cmn.h> // TUid
|
|
|
26 |
#include <apgcli.h> // RApaLsSession
|
|
|
27 |
|
|
|
28 |
#include "emailservermonitorconst.h"
|
|
|
29 |
|
|
|
30 |
/////////////////////////////////////////////////////////////////////////////
|
|
|
31 |
// FORWARD DECLARATIONS
|
|
|
32 |
class CEmailShutter;
|
|
|
33 |
|
|
|
34 |
/**
|
|
|
35 |
* Class CEmailServerMonitor implements functionality that starts up
|
|
|
36 |
* EmailServer and monitors it. If EmailServer crashes, then
|
|
|
37 |
* CEmailServerMonitor restarts it. CEmailServerMonitor also starts up needed
|
|
|
38 |
* email related 3rd party services after IAD update.
|
|
|
39 |
*/
|
|
|
40 |
NONSHARABLE_CLASS( CEmailServerMonitor ) : public CActive, public MEmailServerMonitorTimerCallback
|
|
|
41 |
{
|
|
|
42 |
|
|
|
43 |
public: // Public construcor and destructor
|
|
|
44 |
/**
|
|
|
45 |
* Two-phased class constructor.
|
|
|
46 |
*/
|
|
|
47 |
static CEmailServerMonitor* NewL();
|
|
|
48 |
|
|
|
49 |
/**
|
|
|
50 |
* Two-phased class constructor.
|
|
|
51 |
*/
|
|
|
52 |
static CEmailServerMonitor* NewLC();
|
|
|
53 |
|
|
|
54 |
/**
|
|
|
55 |
* Destructor of CEmailServerMonitor class.
|
|
|
56 |
*/
|
|
|
57 |
~CEmailServerMonitor();
|
|
|
58 |
|
|
|
59 |
public: // Public member functions
|
|
|
60 |
|
|
|
61 |
/**
|
|
|
62 |
* Start email server monitoring.
|
|
|
63 |
*/
|
|
|
64 |
void Start();
|
|
|
65 |
|
|
|
66 |
/**
|
|
|
67 |
* Set pointer to Shutter object
|
|
|
68 |
*/
|
|
|
69 |
void SetShutter( CEmailShutter* aShutter );
|
|
|
70 |
|
|
|
71 |
/**
|
|
|
72 |
* If Restart External Services flag is set to true, then external
|
|
|
73 |
* services will be restarted after Email Server is up and running
|
|
|
74 |
*/
|
|
|
75 |
void SetRestartExternalServicesFlag( TBool aRestartFlag = ETrue );
|
|
|
76 |
|
|
|
77 |
public: // From base class MEmailServerMonitorTimerCallback
|
|
|
78 |
|
|
|
79 |
void TimerEventL( CEmailServerMonitorTimer* aTriggeredTimer );
|
|
|
80 |
|
|
|
81 |
private: // Private constructors
|
|
|
82 |
/**
|
|
|
83 |
* Default class constructor.
|
|
|
84 |
* Only NewL can be called
|
|
|
85 |
*/
|
|
|
86 |
CEmailServerMonitor();
|
|
|
87 |
|
|
|
88 |
/**
|
|
|
89 |
* Second phase class constructor.
|
|
|
90 |
*/
|
|
|
91 |
void ConstructL();
|
|
|
92 |
|
|
|
93 |
/**
|
|
|
94 |
* Start Email Server and its monitoring
|
|
|
95 |
*
|
|
|
96 |
* @return ETrue if Email Server and its monitoring started succesfully,
|
|
|
97 |
* otherwise EFalse
|
|
|
98 |
*/
|
|
|
99 |
TBool StartEmailServerMonitoring();
|
|
|
100 |
|
|
|
101 |
/**
|
|
|
102 |
* Starts the actual monitoring. Assumes that Email Server is running
|
|
|
103 |
* and Monitor's internal variables are set accordingly.
|
|
|
104 |
*/
|
|
|
105 |
void DoStartMonitoring();
|
|
|
106 |
|
|
|
107 |
/**
|
|
|
108 |
* Start specified application, leaves if failed to start the application
|
|
|
109 |
*
|
|
|
110 |
* @param aAppName Name of the application to be started
|
|
|
111 |
* @param aThreadId On return, the id of the main thread started
|
|
|
112 |
* @param aReqStatusForRendezvous Asynchronous status request passed to
|
|
|
113 |
* RProcess::Rendezvous() when starting app
|
|
|
114 |
*/
|
|
|
115 |
void StartApplicationL(
|
|
|
116 |
const TDesC& aAppName,
|
|
|
117 |
TThreadId& aThreadId,
|
|
|
118 |
TRequestStatus& aReqStatusForRendezvous );
|
|
|
119 |
|
|
|
120 |
/**
|
|
|
121 |
* Handles monitoring event
|
|
|
122 |
*/
|
|
|
123 |
void HandleMonitorEvent();
|
|
|
124 |
|
|
|
125 |
/**
|
|
|
126 |
* Initiates an asynchronous delayed restart
|
|
|
127 |
*/
|
|
|
128 |
void InitiateDelayedRestart();
|
|
|
129 |
|
|
|
130 |
private: // From base class CActive
|
|
|
131 |
|
|
|
132 |
void RunL();
|
|
|
133 |
void DoCancel();
|
|
|
134 |
|
|
|
135 |
private: // Private types
|
|
|
136 |
|
|
|
137 |
enum TEmailServerMonitorState
|
|
|
138 |
{
|
|
|
139 |
EEsmStateIdle,
|
|
|
140 |
EEsmStateInitializing,
|
|
|
141 |
EEsmStateMonitoring,
|
|
|
142 |
EEsmStateRestarting
|
|
|
143 |
};
|
|
|
144 |
|
|
|
145 |
enum TExternalServiceRestartState
|
|
|
146 |
{
|
|
|
147 |
EEsmEsrStateRestartNotNeeded,
|
|
|
148 |
EEsmEsrStateRestartNeeded,
|
|
|
149 |
EEsmEsrStateRestartInitiated,
|
|
|
150 |
EEsmEsrStateFirstServiceRestarted,
|
|
|
151 |
};
|
|
|
152 |
|
|
|
153 |
private: // Member variables
|
|
|
154 |
|
|
|
155 |
// A session with the application architecture server
|
|
|
156 |
RApaLsSession iApaLsSession;
|
|
|
157 |
|
|
|
158 |
// A handle to email server process
|
|
|
159 |
RProcess iProcess;
|
|
|
160 |
|
|
|
161 |
// A timer object used to make delayed restarts
|
|
|
162 |
RTimer iDelayTimer;
|
|
|
163 |
|
|
|
164 |
// Internal state
|
|
|
165 |
TEmailServerMonitorState iState;
|
|
|
166 |
|
|
|
167 |
// Number of server restarts
|
|
|
168 |
TInt iRestarts;
|
|
|
169 |
|
|
|
170 |
// Time of the previous restart, used to reset restart counter if
|
|
|
171 |
// server has been running succesfully long enough
|
|
|
172 |
TTime iLastRestartTime;
|
|
|
173 |
|
|
|
174 |
/**
|
|
|
175 |
* Pointer to Shutter
|
|
|
176 |
* Not owned
|
|
|
177 |
*/
|
|
|
178 |
CEmailShutter* iShutter;
|
|
|
179 |
|
|
|
180 |
/**
|
|
|
181 |
* Should we restart external services after Email Server is up and running
|
|
|
182 |
*/
|
|
|
183 |
TExternalServiceRestartState iExternalServicesRestartState;
|
|
|
184 |
|
|
|
185 |
/**
|
|
|
186 |
* Generic timer used to make delayed restart of the external services
|
|
|
187 |
* Owned
|
|
|
188 |
*/
|
|
|
189 |
CEmailServerMonitorTimer* iExternalServiceRestartTimer;
|
|
|
190 |
|
|
|
191 |
};
|
|
|
192 |
|
|
|
193 |
|
|
|
194 |
#endif // EMAILSERVERMONITOR_H
|