|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Handles the refresh sub-session commands. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CSATSREFRESHSUBSESSION_H |
|
20 #define CSATSREFRESHSUBSESSION_H |
|
21 |
|
22 #include "CSatSSubSession.h" |
|
23 #include "MSatRefreshSubSession.h" |
|
24 #include "TSatEventMediator.h" |
|
25 |
|
26 class CSatSSession; |
|
27 class MSatCommand; |
|
28 |
|
29 /** |
|
30 * Handles the refresh commands. |
|
31 * |
|
32 * @lib SatServer |
|
33 * @since 2.6 |
|
34 */ |
|
35 class CSatSRefreshSubSession : public CSatSSubSession, |
|
36 public MSatRefreshSubSession |
|
37 { |
|
38 public: // Constructors and destructor |
|
39 |
|
40 /** |
|
41 * Two-phased constructor. |
|
42 * @param aSession Session |
|
43 * @param aEventMediator Event handler |
|
44 */ |
|
45 static CSatSRefreshSubSession* NewL( |
|
46 CSatSSession& aSession, |
|
47 TSatEventMediator& aEventMediator ); |
|
48 |
|
49 /** |
|
50 * Destructor. |
|
51 */ |
|
52 virtual ~CSatSRefreshSubSession(); |
|
53 |
|
54 public: // Functions from base classes |
|
55 |
|
56 /** |
|
57 * From CSatSSubSession |
|
58 * @param aMessage Message from the client. |
|
59 */ |
|
60 void HandleCommandL( const RMessage2& aMessage ); |
|
61 |
|
62 /** |
|
63 * From MSatRefreshSubSession. |
|
64 * @param aRefresh Refresh data. |
|
65 */ |
|
66 void QueryClient( const RSat::TRefreshV2& aRefresh ); |
|
67 |
|
68 /** |
|
69 * From MSatRefreshSubSession. |
|
70 * @param aRefresh Refresh data. |
|
71 */ |
|
72 void NotifyClient( const RSat::TRefreshV2& aRefresh ); |
|
73 |
|
74 /** |
|
75 * From MSatRefreshSubSession. |
|
76 */ |
|
77 void NotifyClientCancel(); |
|
78 |
|
79 private: // New functions |
|
80 |
|
81 /** |
|
82 * Handles the NotifyRefresh command from SatClient. |
|
83 * @param aMessage Message from the client. |
|
84 */ |
|
85 void NotifyRefreshAllowed( const RMessage2& aMessage ); |
|
86 |
|
87 /** |
|
88 * Cancels the allow refresh. |
|
89 * @param aMessage Message from the client. |
|
90 */ |
|
91 void CancelNotifyAllowRefresh( const RMessage2& aMessage ); |
|
92 |
|
93 /** |
|
94 * Handles the RefreshAllowed command from SatClient. |
|
95 * @param aMessage Message from the client. |
|
96 */ |
|
97 void RefreshAllowed( const RMessage2& aMessage ); |
|
98 |
|
99 /** |
|
100 * Handles the refresh notification. |
|
101 * @param aMessage Message from the client. |
|
102 */ |
|
103 void NotifyRefresh( const RMessage2& aMessage ); |
|
104 |
|
105 /** |
|
106 * Cancels the notify refresh. |
|
107 * @param aMessage Message from the client. |
|
108 */ |
|
109 void CancelNotifyRefresh( const RMessage2& aMessage ); |
|
110 |
|
111 /** |
|
112 * Sends the client's completion to SatServer. |
|
113 * @param aMessage Message from the client. |
|
114 */ |
|
115 void CompleteRefresh( const RMessage2& aMessage ); |
|
116 |
|
117 /** |
|
118 * Checks whether current client is interested about this refresh. |
|
119 * @param aRefresh Refresh data. |
|
120 */ |
|
121 TBool VerifyObservedFiles( const RSat::TRefreshV2& aRefresh ) const; |
|
122 |
|
123 /** |
|
124 * Timer call back for clients refresh query response timeout. |
|
125 * @param aRefreshSubSession Reference to this class. |
|
126 */ |
|
127 static TInt TimerQueryCallback( TAny* aRefreshSubSession ); |
|
128 |
|
129 /** |
|
130 * Timeout handler for the client's response of refresh query. |
|
131 */ |
|
132 void QueryTimeout(); |
|
133 |
|
134 /** |
|
135 * Timer call back for clients refresh notify response timeout. |
|
136 * @param aRefreshSubSession Reference to this class. |
|
137 */ |
|
138 static TInt TimerNotifyCallback( TAny* aRefreshSubSession ); |
|
139 |
|
140 /** |
|
141 * Timeout handler for the client's response of refresh notify. |
|
142 */ |
|
143 void NotifyTimeout(); |
|
144 |
|
145 private: |
|
146 |
|
147 /** |
|
148 * C++ default constructor. |
|
149 * @param aSession |
|
150 * @param aEventMediator Event handler |
|
151 */ |
|
152 CSatSRefreshSubSession( |
|
153 CSatSSession& aSession, |
|
154 TSatEventMediator& aEventMediator ); |
|
155 |
|
156 /** |
|
157 * By default Symbian 2nd phase constructor is private. |
|
158 */ |
|
159 void ConstructL(); |
|
160 |
|
161 private: // Data |
|
162 |
|
163 // Message for allow refresh. |
|
164 RMessage2 iRefreshAllowMessage; |
|
165 |
|
166 // Indicates if allow refresh has not been complited. |
|
167 TBool iRefreshAllowPending; |
|
168 |
|
169 // Messge for refresh. |
|
170 RMessage2 iNotifyRefreshMessage; |
|
171 |
|
172 // Indicates if refresh has not been completed. |
|
173 TBool iNotifyRefreshPending; |
|
174 |
|
175 // Event mediator. |
|
176 TSatEventMediator& iEventMediator; |
|
177 |
|
178 // Timer for securing user query. |
|
179 CPeriodic* iQueryTimer; |
|
180 |
|
181 // Timer for securing refresh complete. |
|
182 CPeriodic* iNotifyTimer; |
|
183 |
|
184 // A client has been queried to allow refresh and we are waiting |
|
185 // for response. Enables discarding of timed out responses. |
|
186 TBool iClientQueryPending; |
|
187 |
|
188 // A client has been notified about refresh and we are waiting |
|
189 // for response. Enables discarding of timed out responses. |
|
190 TBool iClientNotifyPending; |
|
191 |
|
192 // A client has allowed refresh and is waiting for Refesh notification. |
|
193 // Flag is used when notificating Refresh cancel for clients waiting. |
|
194 TBool iClientWaitingRefresh; |
|
195 |
|
196 }; |
|
197 |
|
198 #endif // CSATSREFRESHSUBSESSION_H |