32
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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 |
* Class definition for Flexible timer server side sessions. Session
|
|
16 |
* instances handle the commmunication with clients and implement a
|
|
17 |
* callback interface for the CFlexTimerEngine to fire timers
|
|
18 |
*
|
|
19 |
*/
|
|
20 |
/*
|
|
21 |
* %version: 1 %
|
|
22 |
*/
|
|
23 |
// Protection against nested includes
|
|
24 |
#ifndef FLEXTIMERSESSION_H
|
|
25 |
#define FLEXTIMERSESSION_H
|
|
26 |
|
|
27 |
// System includes
|
|
28 |
#include <e32base.h>
|
|
29 |
|
|
30 |
// User includes
|
|
31 |
#include "mflextimerservicecb.h"
|
|
32 |
|
|
33 |
// Forward declarations
|
|
34 |
class MFlexTimerService;
|
|
35 |
|
|
36 |
// Class declaration
|
|
37 |
/**
|
|
38 |
* Flexible timer server side session
|
|
39 |
* CFlexTimerSession implements sessions in CFlexTimerServer. A sessions
|
|
40 |
* parses client messages and adds/cancels timers to CFlexTimerEngine. The
|
|
41 |
* expiration of the timer completes client side message.
|
|
42 |
*/
|
|
43 |
class CFlexTimerSession : public CSession2, public MFlexTimerServiceCB
|
|
44 |
{
|
|
45 |
|
|
46 |
public:
|
|
47 |
|
|
48 |
/**
|
|
49 |
* Constructor
|
|
50 |
*
|
|
51 |
* @param aFlexTimerService A pointer to engine interface providing
|
|
52 |
* timeout service
|
|
53 |
*/
|
|
54 |
CFlexTimerSession( MFlexTimerService* aFlexTimerService );
|
|
55 |
|
|
56 |
/**
|
|
57 |
* Destructor
|
|
58 |
*/
|
|
59 |
virtual ~CFlexTimerSession();
|
|
60 |
|
|
61 |
/**
|
|
62 |
* From: CSession2
|
|
63 |
* Message handler servicing client requests. Interprets message type and
|
|
64 |
* passes it to correct function for processing.
|
|
65 |
*
|
|
66 |
* @param aMessage Message from client
|
|
67 |
*/
|
|
68 |
void ServiceL( const RMessage2& aMessage );
|
|
69 |
|
|
70 |
/**
|
|
71 |
* From CSession2
|
|
72 |
* Called by a server when it receives a disconnect message for the
|
|
73 |
* session.
|
|
74 |
*
|
|
75 |
* @param aMessage The disconnect message
|
|
76 |
*/
|
|
77 |
void Disconnect( const RMessage2 &aMessage );
|
|
78 |
|
|
79 |
/**
|
|
80 |
* From: MFlexTimerServiceCB
|
|
81 |
* Timeout callback function called by timeout engine when a timer
|
|
82 |
* associated to this session expires.
|
|
83 |
*
|
|
84 |
* @see MFlexTimerServiceCB
|
|
85 |
*/
|
|
86 |
virtual void Timeout() const;
|
|
87 |
|
|
88 |
/**
|
|
89 |
* From: MFlexTimerServiceCB
|
|
90 |
* Callback function called by CFlexTimerEngine, when a timer associated
|
|
91 |
* to this session is aborted. Most probable cause for this is At()-timer
|
|
92 |
* aborting due to the system time change
|
|
93 |
*
|
|
94 |
* @param aReason Error code to be passed for client (KErrAbort in case
|
|
95 |
* of system time change)
|
|
96 |
*
|
|
97 |
* @see MFlexTimerServiceCB
|
|
98 |
*/
|
|
99 |
virtual void Abort( TInt aReason ) const;
|
|
100 |
|
|
101 |
private:
|
|
102 |
|
|
103 |
/**
|
|
104 |
* Handles client messages that are issued using At()-function in
|
|
105 |
* RFlexTimer
|
|
106 |
*
|
|
107 |
* @param aMessage Message from client
|
|
108 |
*
|
|
109 |
* @see RFlexTimer
|
|
110 |
*/
|
|
111 |
void NewAtTimer( const RMessage2& aMessage );
|
|
112 |
|
|
113 |
/**
|
|
114 |
* Handles client messages that are issued using AtUTC()-function in
|
|
115 |
* RFlexTimer
|
|
116 |
*
|
|
117 |
* @param aMessage Message from client
|
|
118 |
*
|
|
119 |
* @see RFlexTimer
|
|
120 |
*/
|
|
121 |
void NewAtUtcTimer( const RMessage2& aMessage );
|
|
122 |
|
|
123 |
/**
|
|
124 |
* Handles client messages that a issued using After()-function in
|
|
125 |
* RFlexTimer
|
|
126 |
*
|
|
127 |
* @param aMessage Message from client
|
|
128 |
*
|
|
129 |
* @see RFlexTimer
|
|
130 |
*/
|
|
131 |
void NewAfterTimer( const RMessage2& aMessage );
|
|
132 |
|
|
133 |
/**
|
|
134 |
* Handles client messages that a issued using AfterTicks()-function in
|
|
135 |
* RFlexTimer
|
|
136 |
*
|
|
137 |
* @param aMessage Message from client
|
|
138 |
*
|
|
139 |
* @see RFlexTimer
|
|
140 |
*/
|
|
141 |
void NewAfterTicksTimer( const RMessage2& aMessage );
|
|
142 |
|
|
143 |
/**
|
|
144 |
* Handles timer cancellation initiated by client via RFlexTimer::Cancel
|
|
145 |
*
|
|
146 |
* @param aMessage Message from client
|
|
147 |
*
|
|
148 |
* @see RFlexTimer
|
|
149 |
*/
|
|
150 |
void CancelTimer( const RMessage2& aMessage );
|
|
151 |
|
|
152 |
/**
|
|
153 |
* Configuration message handler, stores configuration parameters for
|
|
154 |
* this session
|
|
155 |
*
|
|
156 |
* @param aMessage Message from client
|
|
157 |
*
|
|
158 |
* @see RFlexTimer
|
|
159 |
*/
|
|
160 |
void ConfigureParameters( const RMessage2& aMessage );
|
|
161 |
|
|
162 |
/**
|
|
163 |
* Inline function for calculating the period from current time to
|
|
164 |
* the timestamp given in message parameters. This is used for
|
|
165 |
* converting the timestamp given in At()- and AtUtc() -functions
|
|
166 |
* to an interval given to DoAddTimer function.
|
|
167 |
*
|
|
168 |
* @param aRefTime Reference time used as a basis for interval
|
|
169 |
* calculation (interval = timestamp - aRefTime)
|
|
170 |
* @param aMessage Message containing timestamp in Int0 and Int1
|
|
171 |
* parameters (Int0 contains LSW)
|
|
172 |
* @param aInterval On return, contains the interval in microseconds
|
|
173 |
*/
|
|
174 |
inline void GetIntervalToMsgTime( const RMessage2& aMessage,
|
|
175 |
TTime& aRefTime,
|
|
176 |
TTimeIntervalMicroSeconds& aInterval );
|
|
177 |
|
|
178 |
/**
|
|
179 |
* Function for adding timer with desired window to engine, called in
|
|
180 |
* AtXxx() and AfterXxx() -functions
|
|
181 |
*
|
|
182 |
* @param aMessage Message from client. Stored if adding a timer is
|
|
183 |
* successful, completed if adding fails
|
|
184 |
* @param aInterval Microseconds until to requested end time
|
|
185 |
* @param aRequestAbort ETrue if timer should be cancelled on system
|
|
186 |
* time change, EFalse otherwise
|
|
187 |
*/
|
|
188 |
void DoAddTimer( const RMessage2& aMessage,
|
|
189 |
TTimeIntervalMicroSeconds& aInterval,
|
|
190 |
TBool aRequestAbort );
|
|
191 |
|
|
192 |
private:
|
|
193 |
|
|
194 |
/**
|
|
195 |
* Pointer to engine interface through which new timers can be added
|
|
196 |
* and cancelled.
|
|
197 |
*/
|
|
198 |
MFlexTimerService* iService;
|
|
199 |
|
|
200 |
/**
|
|
201 |
* Timeout window size in microseconds (64-bit). Timeout window is
|
|
202 |
* calculated backwards from the absolute timestamp given in AtXxx()
|
|
203 |
* and AfterXxx() -functions
|
|
204 |
*/
|
|
205 |
TTimeIntervalMicroSeconds iTimerWinSize;
|
|
206 |
|
|
207 |
/**
|
|
208 |
* ETrue if client has not set timeout window, EFalse otherwise
|
|
209 |
*/
|
|
210 |
TBool iUseDefaultWin;
|
|
211 |
|
|
212 |
/**
|
|
213 |
* Handle to pending timeout message
|
|
214 |
*/
|
|
215 |
RMessagePtr2 iPendingTimeoutMsg;
|
|
216 |
};
|
|
217 |
|
|
218 |
#include "flextimersession.inl"
|
|
219 |
|
|
220 |
#endif /* FLEXTIMERSESSION_H */
|