|
1 /* |
|
2 * Copyright (c) 2004 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: Client group remote notify handler. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <E32std.h> |
|
21 #include "CCnUiClientGroupUiNotifyHandler.h" |
|
22 #include "MCnUiUiFacade.h" |
|
23 #include "CnUiCommon.hrh" |
|
24 |
|
25 |
|
26 // ================= MEMBER FUNCTIONS ======================= |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CCnUiClientGroupUiNotifyHandler::NewL |
|
30 // Two-phased constructor. |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CCnUiClientGroupUiNotifyHandler* CCnUiClientGroupUiNotifyHandler::NewL( |
|
34 TIMPSConnectionClient aClient ) |
|
35 { |
|
36 CCnUiClientGroupUiNotifyHandler* self = |
|
37 new ( ELeave ) CCnUiClientGroupUiNotifyHandler( aClient ); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 |
|
45 // Destructor |
|
46 CCnUiClientGroupUiNotifyHandler::~CCnUiClientGroupUiNotifyHandler() |
|
47 { |
|
48 CancelCurrentQuery(); |
|
49 delete iGroupChannel; |
|
50 delete iBrandedResourceFileName; |
|
51 } |
|
52 |
|
53 |
|
54 // C++ default constructor can NOT contain any code, that |
|
55 // might leave. |
|
56 // |
|
57 CCnUiClientGroupUiNotifyHandler::CCnUiClientGroupUiNotifyHandler( TIMPSConnectionClient aClient ) |
|
58 : iClient( aClient ) |
|
59 { |
|
60 } |
|
61 |
|
62 |
|
63 // EPOC default constructor can leave. |
|
64 void CCnUiClientGroupUiNotifyHandler::ConstructL() |
|
65 { |
|
66 iGroupChannel = CCnUiGroupChannel::NewL( iClient, ECnUiRemoteUiNotificationsChannel ); |
|
67 iGroupChannel->ListenL( this ); |
|
68 } |
|
69 |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CCnUiClientGroupUiNotifyHandler::Handled() |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 TBool CCnUiClientGroupUiNotifyHandler::Handled( TInt aRemoteUiMessage ) |
|
76 { |
|
77 switch ( aRemoteUiMessage ) |
|
78 { |
|
79 case ECGQActiveConnectionScheduledClose: |
|
80 { |
|
81 return iActiveConnectionScheduledClose; |
|
82 } |
|
83 |
|
84 case ECGQActiveConnectionSuppressForScheduledConnection: |
|
85 { |
|
86 return iActiveConnectionSuppressForScheduledConnection; |
|
87 } |
|
88 |
|
89 default: |
|
90 { |
|
91 break; |
|
92 } |
|
93 } |
|
94 |
|
95 return EFalse; |
|
96 } |
|
97 |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CCnUiClientGroupUiNotifyHandler::SetHandled() |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 void CCnUiClientGroupUiNotifyHandler::SetHandled( TInt aRemoteUiMessage, TBool aHandled ) |
|
104 { |
|
105 switch ( aRemoteUiMessage ) |
|
106 { |
|
107 case ECGQActiveConnectionScheduledClose: |
|
108 { |
|
109 iActiveConnectionScheduledClose = aHandled; |
|
110 break; |
|
111 } |
|
112 |
|
113 case ECGQActiveConnectionSuppressForScheduledConnection: |
|
114 { |
|
115 iActiveConnectionSuppressForScheduledConnection = aHandled; |
|
116 break; |
|
117 } |
|
118 |
|
119 default: |
|
120 { |
|
121 break; |
|
122 } |
|
123 } |
|
124 |
|
125 if ( aHandled ) |
|
126 { |
|
127 //some service started |
|
128 //launch the notification if notify request is already issued |
|
129 TInt channelMsg = KErrNotFound; |
|
130 if ( iGroupChannel->Read( channelMsg ) == KErrNone ) |
|
131 { |
|
132 HandleChannelMsg( iGroupChannel->GroupID(), |
|
133 iGroupChannel->ChannelId(), |
|
134 channelMsg ); |
|
135 } |
|
136 } |
|
137 } |
|
138 |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CCnUiClientGroupUiNotifyHandler::HandlePresenceEventL() |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CCnUiClientGroupUiNotifyHandler::HandlePresenceEventL( TIMPSPresenceServiceEvent aEvent ) |
|
145 { |
|
146 if ( ( aEvent == EIMPSPresenceServiceOffline ) || |
|
147 ( aEvent == EIMPSPresenceServiceForceLogOut ) ) |
|
148 { |
|
149 //current connection is lost ==> dismiss possibly shown queries |
|
150 //AA side will eventually after timeout figure out the result |
|
151 CancelCurrentQuery(); |
|
152 } |
|
153 } |
|
154 |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CCnUiClientGroupUiNotifyHandler::HandleChannelMsg() |
|
158 // MCnUiGroupChannelListener |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 void CCnUiClientGroupUiNotifyHandler::HandleChannelMsg( TInt /*aGroupId*/, |
|
162 TGCChannelID /*aChannelId*/, |
|
163 TInt aChannelMsg ) |
|
164 { |
|
165 TRAPD( err, DoHandleChannelMsgL( aChannelMsg ) ); |
|
166 MCnUiUiFacade* tempUi = NULL; |
|
167 TRAP( err, tempUi = CreateUiFacadeL() ); |
|
168 if ( err ) |
|
169 { |
|
170 // if we don't get facade we just don't show anything |
|
171 return; |
|
172 } |
|
173 |
|
174 delete iUi; |
|
175 iUi = tempUi; |
|
176 |
|
177 if ( iBrandedResourceFileName ) |
|
178 { |
|
179 TRAP( err, iUi->SwitchResourceFileL( *iBrandedResourceFileName ) ); |
|
180 if ( err != KErrNone ) |
|
181 { |
|
182 CActiveScheduler::Current()->Error( err ); |
|
183 } |
|
184 } |
|
185 |
|
186 iUi->HandleIfError( err ); |
|
187 |
|
188 delete iUi; |
|
189 iUi = NULL; |
|
190 } |
|
191 |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CCnUiClientGroupUiNotifyHandler::HandleQueryResult() |
|
195 // From MCnUiConnQueryObserver |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 void CCnUiClientGroupUiNotifyHandler::HandleQueryResult( TBool aQueryAccepted ) |
|
199 { |
|
200 TRAPD( err, ReportQueryResultL( aQueryAccepted ) ); |
|
201 |
|
202 MCnUiUiFacade* tempUi = NULL; |
|
203 TRAP( err, tempUi = CreateUiFacadeL() ); |
|
204 if ( err ) |
|
205 { |
|
206 // if we don't get facade we just don't show anything |
|
207 return; |
|
208 } |
|
209 |
|
210 delete iUi; |
|
211 iUi = tempUi; |
|
212 |
|
213 if ( iBrandedResourceFileName ) |
|
214 { |
|
215 TRAP( err, iUi->SwitchResourceFileL( *iBrandedResourceFileName ) ); |
|
216 if ( err != KErrNone ) |
|
217 { |
|
218 CActiveScheduler::Current()->Error( err ); |
|
219 } |
|
220 } |
|
221 |
|
222 iUi->HandleIfError( err ); |
|
223 |
|
224 delete iUi; |
|
225 iUi = NULL; |
|
226 } |
|
227 |
|
228 |
|
229 // ----------------------------------------------------------------------------- |
|
230 // CCnUiClientGroupUiNotifyHandler::ReportQueryResultL() |
|
231 // ----------------------------------------------------------------------------- |
|
232 // |
|
233 void CCnUiClientGroupUiNotifyHandler::ReportQueryResultL( TBool aQueryAccepted ) |
|
234 { |
|
235 if ( aQueryAccepted ) |
|
236 { |
|
237 iGroupChannel->WriteL( ERemoteQueryAccepted ); |
|
238 } |
|
239 else |
|
240 { |
|
241 iGroupChannel->WriteL( ERemoteQueryDeclined ); |
|
242 } |
|
243 } |
|
244 |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // CCnUiClientGroupUiNotifyHandler::CancelCurrentQuery() |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 void CCnUiClientGroupUiNotifyHandler::CancelCurrentQuery() |
|
251 { |
|
252 delete iCurrentQuery; |
|
253 iCurrentQuery = NULL; |
|
254 } |
|
255 |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // CCnUiClientGroupUiNotifyHandler::DoHandleChannelMsgL() |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 void CCnUiClientGroupUiNotifyHandler::DoHandleChannelMsgL( TInt aChannelMsg ) |
|
262 { |
|
263 //which ever event happens in channel, clear active query |
|
264 //==> queries are cleared when new query is issued & some client reports selection |
|
265 CancelCurrentQuery(); |
|
266 |
|
267 //if a channel message is a known & handled query id ==> show the query |
|
268 if ( !Handled( aChannelMsg ) ) |
|
269 { |
|
270 return; |
|
271 } |
|
272 |
|
273 MCnUiUiFacade* tempUi = CreateUiFacadeL(); |
|
274 |
|
275 delete iUi; |
|
276 iUi = tempUi; |
|
277 |
|
278 if ( iBrandedResourceFileName ) |
|
279 { |
|
280 iUi->SwitchResourceFileL( *iBrandedResourceFileName ); |
|
281 } |
|
282 |
|
283 //make a proper non waiting query |
|
284 switch ( aChannelMsg ) |
|
285 { |
|
286 case ECGQActiveConnectionScheduledClose: |
|
287 { |
|
288 iCurrentQuery = iUi->QueryL( ECnUiQueryActiveConnectionScheduledClose, |
|
289 *this ); |
|
290 |
|
291 break; |
|
292 } |
|
293 |
|
294 case ECGQActiveConnectionSuppressForScheduledConnection: |
|
295 { |
|
296 HBufC* serverName = NULL; |
|
297 iGroupChannel->ReadL( serverName ); |
|
298 CleanupStack::PushL( serverName ); |
|
299 iCurrentQuery = iUi->QueryL( ECnUiQueryActiveConnectionSuppressForScheduledConnection, |
|
300 *serverName, |
|
301 *this ); |
|
302 CleanupStack::PopAndDestroy( serverName ); //serverName |
|
303 break; |
|
304 } |
|
305 |
|
306 default: |
|
307 { |
|
308 break; |
|
309 } |
|
310 } |
|
311 |
|
312 delete iUi; |
|
313 iUi = NULL; |
|
314 } |
|
315 |
|
316 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // CCnUiClientGroupUiNotifyHandler::UseResourceFileL() |
|
319 // ----------------------------------------------------------------------------- |
|
320 // |
|
321 void CCnUiClientGroupUiNotifyHandler::UseResourceFileL( const TDesC& aNewResourceFile ) |
|
322 { |
|
323 if ( aNewResourceFile.Length() == 0 ) |
|
324 { |
|
325 //empty resource file name ==> use the default resource |
|
326 delete iBrandedResourceFileName; |
|
327 iBrandedResourceFileName = NULL; |
|
328 } |
|
329 else |
|
330 { |
|
331 // use this resourcefile |
|
332 HBufC* tempFile = aNewResourceFile.AllocL(); |
|
333 delete iBrandedResourceFileName; |
|
334 iBrandedResourceFileName = tempFile; |
|
335 } |
|
336 } |
|
337 |
|
338 |
|
339 |
|
340 // end of file |