|
1 /* |
|
2 * Copyright (c) 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: Methods to parse the server alert messages for data sync and device |
|
15 * Management frameworks. Launches respective application |
|
16 * in appropriate conditions |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <eikenv.h> // Eikon environment |
|
24 #include <AknQueryDialog.h> |
|
25 #include <StringLoader.h> // Localisation stringloader |
|
26 #include <SyncMLClientDS.h> |
|
27 #include <SyncMLClientDM.h> |
|
28 #include <SyncMLClient.h> |
|
29 #include <rconnmon.h> |
|
30 #include <centralrepository.h> |
|
31 #include <SyncMLNotifierDomainCRKeys.h> |
|
32 #include <SyncMLNotifier.rsg> // Own resources |
|
33 #include "SyncMLAppLaunchNotifier.h" // Class declaration |
|
34 #include "SyncMLTimedMessageQuery.h" |
|
35 #include "SyncMLTimedQueryDialog.h" |
|
36 #include "SyncMLNotifDebug.h" |
|
37 #include <aknnotewrappers.h> |
|
38 #include <DevManInternalCRKeys.h> |
|
39 #include "nsmlconstantdefs.h" |
|
40 #include "CPreSyncPlugin.h" |
|
41 #include "SyncMLPreSyncPluginInterface.h" |
|
42 |
|
43 // CONSTANTS |
|
44 _LIT( KSmlNPanicCategory, "SyncMLNotifier"); |
|
45 |
|
46 // medium type uids |
|
47 //const TUid KUidNSmlMediumTypeInternet = { 0x101F99F0 }; |
|
48 const TUid KUidNSmlMediumTypeBluetooth = { 0x101F99F1 }; |
|
49 const TUid KUidNSmlMediumTypeUSB = { 0x101F99F2 }; |
|
50 const TUid KUidNSmlMediumTypeIrDA = { 0x101F99F3 }; |
|
51 |
|
52 |
|
53 enum TASpBearerType |
|
54 { |
|
55 EAspBearerInternet = 0, |
|
56 EAspBearerUsb = 1, |
|
57 EAspBearerBlueTooth = 2, |
|
58 EAspBearerIrda = 3, |
|
59 EAspBearerWsp = 4, |
|
60 EAspBearerSmlUsb = 5, |
|
61 EAspBearerLast = 6 |
|
62 }; |
|
63 |
|
64 // ============================ MEMBER FUNCTIONS =============================== |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CSyncMLAppLaunchNotifier::CSyncMLAppLaunchNotifier |
|
68 // C++ default constructor can NOT contain any code, that |
|
69 // might leave. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CSyncMLAppLaunchNotifier::CSyncMLAppLaunchNotifier() : |
|
73 iAlwaysAsk( EFalse ) |
|
74 { |
|
75 iBearerType = KErrNotFound; |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CSyncMLDSNotifier::NewL |
|
80 // Two-phased constructor. |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CSyncMLAppLaunchNotifier* CSyncMLAppLaunchNotifier::NewL() |
|
84 { |
|
85 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::NewL()")); |
|
86 CSyncMLAppLaunchNotifier* self = new (ELeave) CSyncMLAppLaunchNotifier(); |
|
87 CleanupStack::PushL( self ); |
|
88 self->ConstructL(); |
|
89 CleanupStack::Pop( self ); |
|
90 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::NewL() completed")); |
|
91 return self; |
|
92 } |
|
93 |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // Destructor |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 CSyncMLAppLaunchNotifier::~CSyncMLAppLaunchNotifier() |
|
100 { |
|
101 delete iDMSyncService; |
|
102 delete iDSSyncService; |
|
103 Cancel(); // Free own resources |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CSyncMLAppLaunchNotifier::RetrieveSyncParams |
|
108 // Leaves if the job identifier is not found. |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CSyncMLAppLaunchNotifier::RetrieveSyncParamsL( |
|
112 TSyncServiceParam& aParam, |
|
113 TDes& aServerName, |
|
114 TSmlServerAlertedAction& aUserInteraction ) |
|
115 { |
|
116 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RetrieveSyncParamsL()")); |
|
117 TSmlJobId currentJobId; |
|
118 TSmlUsageType usageType; |
|
119 |
|
120 // sync session |
|
121 RSyncMLSession syncSession; |
|
122 syncSession.OpenL(); |
|
123 CleanupClosePushL( syncSession ); |
|
124 syncSession.CurrentJobL( currentJobId, usageType ); |
|
125 |
|
126 if ( currentJobId == iJobId && |
|
127 usageType == ESmlDataSync ) |
|
128 { |
|
129 RSyncMLDataSyncProfile syncProfile; |
|
130 syncProfile.OpenL( syncSession, iProfileId, ESmlOpenRead ); |
|
131 CleanupClosePushL( syncProfile ); |
|
132 |
|
133 aParam.iProfileId = iProfileId; |
|
134 aParam.iJobId = iJobId; |
|
135 aServerName = syncProfile.DisplayName(); |
|
136 aUserInteraction = syncProfile.SanUserInteraction(); |
|
137 |
|
138 // Check if always ask is selected as accesspoint |
|
139 RSyncMLConnection connection; |
|
140 TRAPD( iapError, connection.OpenL( syncProfile, KUidNSmlMediumTypeInternet.iUid ) ); |
|
141 CleanupClosePushL( connection ); |
|
142 |
|
143 if ( !iapError ) |
|
144 { |
|
145 const TDesC8& iap = connection.GetPropertyL( KNSmlIAPId ); |
|
146 if ( iap.Compare( KNSmlAlwaysAsk() ) == 0 ) |
|
147 { |
|
148 iAlwaysAsk = ETrue; |
|
149 } |
|
150 |
|
151 TInt id = connection.Identifier(); |
|
152 if (id == KUidNSmlMediumTypeInternet.iUid) |
|
153 { |
|
154 iBearerType = EAspBearerInternet; |
|
155 } |
|
156 else if (id == KUidNSmlMediumTypeBluetooth.iUid) |
|
157 { |
|
158 iBearerType = EAspBearerBlueTooth; |
|
159 } |
|
160 else if (id == KUidNSmlMediumTypeUSB.iUid) |
|
161 { |
|
162 iBearerType = EAspBearerUsb; |
|
163 } |
|
164 else if (id == KUidNSmlMediumTypeIrDA.iUid) |
|
165 { |
|
166 iBearerType = EAspBearerIrda; |
|
167 } |
|
168 else |
|
169 { |
|
170 iBearerType = KErrNotFound; |
|
171 } |
|
172 } |
|
173 |
|
174 connection.Close(); |
|
175 CleanupStack::Pop( &connection ); |
|
176 |
|
177 syncProfile.Close(); |
|
178 CleanupStack::Pop( &syncProfile ); |
|
179 } |
|
180 else |
|
181 { |
|
182 FTRACE( FPrint( |
|
183 _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RetrieveSyncParamsL() Could not find job %d"), |
|
184 iJobId ) ); |
|
185 User::Leave( KErrNotFound ); |
|
186 } |
|
187 |
|
188 syncSession.Close(); |
|
189 CleanupStack::Pop( &syncSession ); |
|
190 |
|
191 FTRACE( FPrint( |
|
192 _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RetrieveSyncParamsL() completed, aServerName = \"%S\""), |
|
193 &aServerName ) ); |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CSyncMLAppLaunchNotifier::RetrieveMgmtParamsL |
|
198 // Leaves if the job identifier is not found. |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 void CSyncMLAppLaunchNotifier::RetrieveMgmtParamsL( |
|
202 TSyncServiceParam& aParam, |
|
203 TDes& aServerName, |
|
204 TSmlServerAlertedAction& aUserInteraction ) |
|
205 { |
|
206 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RetrieveMgmtParamsL()")); |
|
207 |
|
208 TSmlJobId currentJobId; |
|
209 TSmlUsageType usageType; |
|
210 |
|
211 RSyncMLSession syncSession; |
|
212 |
|
213 syncSession.OpenL(); |
|
214 CleanupClosePushL( syncSession ); |
|
215 |
|
216 syncSession.CurrentJobL( currentJobId, usageType ); |
|
217 |
|
218 if ( currentJobId == iJobId && |
|
219 usageType == ESmlDevMan ) |
|
220 { |
|
221 RSyncMLDevManProfile syncProfile; |
|
222 syncProfile.OpenL( syncSession, iProfileId, ESmlOpenRead ); |
|
223 CleanupClosePushL( syncProfile ); |
|
224 |
|
225 aParam.iProfileId = iProfileId; |
|
226 aParam.iJobId = iJobId; |
|
227 aServerName = syncProfile.DisplayName(); |
|
228 aUserInteraction = syncProfile.SanUserInteraction(); |
|
229 |
|
230 // Check if always ask is selected as accesspoint |
|
231 RSyncMLConnection connection; |
|
232 TRAPD( iapError, connection.OpenL( syncProfile, KUidNSmlMediumTypeInternet.iUid ) ); |
|
233 CleanupClosePushL( connection ); |
|
234 |
|
235 if ( !iapError ) |
|
236 { |
|
237 const TDesC8& iap = connection.GetPropertyL( KNSmlIAPId ); |
|
238 if ( iap.Compare( KNSmlAlwaysAsk() ) == 0 ) |
|
239 { |
|
240 iAlwaysAsk = ETrue; |
|
241 } |
|
242 } |
|
243 |
|
244 connection.Close(); |
|
245 CleanupStack::Pop( &connection ); |
|
246 |
|
247 syncProfile.Close(); |
|
248 CleanupStack::Pop( &syncProfile ); |
|
249 } |
|
250 else |
|
251 { |
|
252 FTRACE( FPrint( |
|
253 _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RetrieveMgmtParamsL() Could not find job %d"), |
|
254 iJobId ) ); |
|
255 User::Leave( KErrNotFound ); |
|
256 } |
|
257 |
|
258 syncSession.Close(); |
|
259 CleanupStack::Pop( &syncSession ); |
|
260 |
|
261 FTRACE( FPrint( |
|
262 _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RetrieveMgmtParamsL() completed, aServerName = \"%S\""), |
|
263 &aServerName ) ); |
|
264 } |
|
265 |
|
266 // ----------------------------------------------------------------------------- |
|
267 // CSyncMLAppLaunchNotifier::IsSilent |
|
268 // Only automatic acception from the profile is checked, since notifier has no |
|
269 // information about the preferences included in the server alert. |
|
270 // ----------------------------------------------------------------------------- |
|
271 // |
|
272 TBool CSyncMLAppLaunchNotifier::IsSilent( |
|
273 TSmlServerAlertedAction& aUserInteraction ) |
|
274 { |
|
275 TBool retval = EFalse; |
|
276 if ( aUserInteraction == ESmlEnableSync ) |
|
277 { |
|
278 retval = ETrue; |
|
279 } |
|
280 return retval; |
|
281 } |
|
282 |
|
283 // ----------------------------------------------------------------------------- |
|
284 // CSyncMLAppLaunchNotifier::RegisterL |
|
285 // ----------------------------------------------------------------------------- |
|
286 // |
|
287 CSyncMLAppLaunchNotifier::TNotifierInfo CSyncMLAppLaunchNotifier::RegisterL() |
|
288 { |
|
289 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RegisterL()")); |
|
290 iInfo.iUid = KSyncMLAppLaunchNotifierUid; |
|
291 iInfo.iChannel = KSmlAppLaunchChannel; |
|
292 iInfo.iPriority = ENotifierPriorityVHigh; |
|
293 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RegisterL() completed")); |
|
294 return iInfo; |
|
295 } |
|
296 |
|
297 // ----------------------------------------------------------------------------- |
|
298 // CSyncMLAppLaunchNotifier::Cancel |
|
299 // Release all own resources (member variables) |
|
300 // ----------------------------------------------------------------------------- |
|
301 // |
|
302 void CSyncMLAppLaunchNotifier::Cancel() |
|
303 { |
|
304 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::Cancel()")); |
|
305 |
|
306 CSyncMLNotifierBase::Cancel(); |
|
307 |
|
308 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::Cancel() completed")); |
|
309 } |
|
310 |
|
311 // ----------------------------------------------------------------------------- |
|
312 // CSyncMLAppLaunchNotifier::GetParamsL |
|
313 // Initialize parameters and check if device is already |
|
314 // in registry. Jump to RunL as soon as possible. |
|
315 // ----------------------------------------------------------------------------- |
|
316 // |
|
317 void CSyncMLAppLaunchNotifier::GetParamsL( const TDesC8& aBuffer, |
|
318 TInt aReplySlot, |
|
319 const RMessagePtr2& aMessage ) |
|
320 { |
|
321 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::GetParamsL()")); |
|
322 |
|
323 if( iReplySlot != NULL || iNeedToCompleteMessage ) |
|
324 { |
|
325 User::Leave( KErrInUse ); |
|
326 } |
|
327 |
|
328 iMessage = aMessage; |
|
329 iNeedToCompleteMessage = ETrue; |
|
330 iReplySlot = aReplySlot; |
|
331 iAlwaysAsk = EFalse; |
|
332 |
|
333 TSyncMLAppLaunchNotifParams param; |
|
334 TPckgC<TSyncMLAppLaunchNotifParams> pckg( param ); |
|
335 pckg.Set(aBuffer); |
|
336 |
|
337 iSmlProtocol = pckg().iSessionType; |
|
338 iJobId = pckg().iJobId; |
|
339 iProfileId = pckg().iProfileId; |
|
340 TInt SanSupport( KErrNone ); |
|
341 CRepository* centrep = NULL; |
|
342 TRAPD( err, centrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys) ); |
|
343 User::LeaveIfError( err ); |
|
344 centrep->Get( KDevManSANUIBitVariation, SanSupport ); |
|
345 delete centrep; |
|
346 if( SanSupport == EON ) |
|
347 { |
|
348 iUimode = pckg().iUimode; |
|
349 } |
|
350 // Call SetActive() so RunL() will be called by the active scheduler |
|
351 // |
|
352 SetActive(); |
|
353 iStatus = KRequestPending; |
|
354 TRequestStatus* stat = &iStatus; |
|
355 User::RequestComplete( stat, KErrNone ); |
|
356 |
|
357 FTRACE( FPrint( |
|
358 _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::GetParamsL() completed, iSmlProtocol = %d, iJobId = %d, iProfileId = %d"), |
|
359 iSmlProtocol, iJobId, iProfileId ) ); |
|
360 } |
|
361 |
|
362 // ----------------------------------------------------------------------------- |
|
363 // CAspSyncHandler::ReadRepositoryL |
|
364 // |
|
365 // ----------------------------------------------------------------------------- |
|
366 // |
|
367 void CSyncMLAppLaunchNotifier::ReadRepositoryL(TInt aKey, TInt& aValue) |
|
368 { |
|
369 CRepository* rep = CRepository::NewLC(KCRUidNSmlDSApp); |
|
370 TInt err = rep->Get(aKey, aValue); |
|
371 User::LeaveIfError(err); |
|
372 |
|
373 CleanupStack::PopAndDestroy(rep); |
|
374 } |
|
375 |
|
376 void CSyncMLAppLaunchNotifier::ShowRoamingMessageL(TInt keypress, TUint profileId) |
|
377 { |
|
378 TBool roaming = EFalse; |
|
379 |
|
380 if( (keypress == EAknSoftkeyYes || keypress == EAknSoftkeyOk) && (iSmlProtocol == ESyncMLSyncSession) ) |
|
381 { |
|
382 TBool bCanSync = ETrue; |
|
383 |
|
384 TInt aValue = 0; |
|
385 ReadRepositoryL(KNSmlDSRoamingFeature, aValue); |
|
386 IsRoamingL(roaming); |
|
387 if(( roaming ) && (aValue == EAspRoamingSettingFeatureEnabled)) |
|
388 { |
|
389 if (iBearerType == EAspBearerInternet) |
|
390 { |
|
391 CPreSyncPluginInterface* syncPluginInterface = CPreSyncPluginInterface::NewL(); |
|
392 CPreSyncPlugin* syncPlugin = |
|
393 syncPluginInterface->InstantiateRoamingPluginLC(profileId); |
|
394 |
|
395 // Turn lights on and deactivate apps -key |
|
396 TurnLightsOn(); |
|
397 SuppressAppSwitching( ETrue ); |
|
398 |
|
399 if(syncPlugin->IsSupported()) |
|
400 { |
|
401 bCanSync = syncPlugin->CanSyncL(); |
|
402 } |
|
403 |
|
404 SuppressAppSwitching( EFalse ); |
|
405 |
|
406 CleanupStack::PopAndDestroy(syncPlugin); |
|
407 //syncPluginInterface->UnloadPlugIns(); |
|
408 delete syncPluginInterface; |
|
409 |
|
410 if(!bCanSync) |
|
411 { |
|
412 iNeedToCompleteMessage=EFalse; |
|
413 iReplySlot = NULL; |
|
414 iMessage.Complete( KErrCancel ); |
|
415 return; |
|
416 } |
|
417 |
|
418 } |
|
419 } |
|
420 } |
|
421 } |
|
422 // ----------------------------------------------------------------------------- |
|
423 // CSyncMLAppLaunchNotifier::RunL |
|
424 // Ask user response and return it to caller. |
|
425 // ----------------------------------------------------------------------------- |
|
426 // |
|
427 void CSyncMLAppLaunchNotifier::RunL() |
|
428 { |
|
429 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL()")); |
|
430 stringholder =NULL; |
|
431 centrep = NULL; |
|
432 TRAPD( err, centrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys) ); |
|
433 if(err) |
|
434 { |
|
435 centrep = NULL; |
|
436 } |
|
437 |
|
438 TLanguage language = User::Language(); |
|
439 // Load the parameters and set the query text according to the session type. |
|
440 switch( iSmlProtocol ) |
|
441 { |
|
442 case ESyncMLSyncSession: |
|
443 { |
|
444 FLOG( _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() Synchronisation session") ); |
|
445 |
|
446 TBuf<KSyncMLMaxProfileNameLength> serverName; |
|
447 RetrieveSyncParamsL( param, serverName, uiAction ); |
|
448 stringholder = StringLoader::LoadL( R_SML_INIT_DS_SERVER_PROMPT, |
|
449 serverName ); |
|
450 } |
|
451 break; |
|
452 case ESyncMLMgmtSession: |
|
453 { |
|
454 TBool status = HandleDMSessionL(); |
|
455 if( !status ) |
|
456 return; |
|
457 } |
|
458 break; |
|
459 default: // Unknown value |
|
460 { |
|
461 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() unknown protocol value")); |
|
462 User::Leave( KErrArgument ); // Leave handling completes the message |
|
463 return; |
|
464 } |
|
465 } |
|
466 |
|
467 CleanupStack::PushL( stringholder ); |
|
468 |
|
469 TInt keypress( 0 ); |
|
470 TBool silent = EFalse; |
|
471 TInt SanSupport( KErrNone ),Timeout( KErrNone),CustomNotes(KErrNone);; |
|
472 if(centrep) |
|
473 {centrep->Get( KDevManSANUIBitVariation, SanSupport ); |
|
474 centrep->Get( KDevManServerAlertTimeout, Timeout ); |
|
475 centrep->Get( KDevManUINotesCustomization, CustomNotes); |
|
476 } |
|
477 else |
|
478 { |
|
479 SanSupport = KErrNone; |
|
480 Timeout = KDefaultTimeoutforNotes; |
|
481 CustomNotes = KErrNone ; |
|
482 } |
|
483 Timeout = Timeout * 60 ;// converting to mins |
|
484 delete centrep; |
|
485 if(( SanSupport == EON )&& ( iSmlProtocol == ESyncMLMgmtSession)) |
|
486 { |
|
487 if( iUimode > ESANUserInteractive && iUimode < ESANNotSpecified ) |
|
488 { |
|
489 iUimode = ESANNotSpecified; |
|
490 } |
|
491 switch( iUimode ) |
|
492 { |
|
493 case ESANNotSpecified://not specified |
|
494 case ESANUserInteractive://user interactive session |
|
495 silent = EFalse; |
|
496 break; |
|
497 case ESANSilent://Background |
|
498 case ESANUserInformative://Informative session |
|
499 silent = ETrue;//IsSilent( uiAction ); |
|
500 break; |
|
501 } |
|
502 } |
|
503 else |
|
504 { |
|
505 silent = IsSilent( uiAction ); |
|
506 } |
|
507 if ( iAlwaysAsk && iSmlProtocol == ESyncMLMgmtSession ) //check with synergy |
|
508 { |
|
509 silent = EFalse; |
|
510 } |
|
511 if ( !silent || iAlwaysAsk ) |
|
512 { |
|
513 // Turn lights on and deactivate apps -key |
|
514 TurnLightsOn(); |
|
515 SuppressAppSwitching( ETrue ); |
|
516 |
|
517 CSyncMLTimedQueryDialog* dlg = |
|
518 CSyncMLTimedQueryDialog::NewL( *stringholder, |
|
519 Timeout ); |
|
520 |
|
521 // Pushed dialog is popped inside RunLD |
|
522 dlg->PrepareLC( R_SML_CONFIRMATION_QUERY ); |
|
523 |
|
524 dlg->ButtonGroupContainer().SetCommandSetL( |
|
525 R_AVKON_SOFTKEYS_YES_NO__YES ); |
|
526 keypress = dlg->RunLD(); |
|
527 dlg = NULL; |
|
528 // Activate apps -key again |
|
529 // |
|
530 SuppressAppSwitching( EFalse ); |
|
531 } |
|
532 |
|
533 CleanupStack::PopAndDestroy( stringholder ); |
|
534 |
|
535 ShowRoamingMessageL(keypress, param.iProfileId); |
|
536 |
|
537 if ( iNeedToCompleteMessage ) // Notifier is not cancelled |
|
538 { |
|
539 HandleCompleteMessageL(keypress, silent, SanSupport, Timeout, CustomNotes); |
|
540 } |
|
541 |
|
542 iNeedToCompleteMessage = EFalse; |
|
543 iReplySlot = NULL; |
|
544 |
|
545 iSmlProtocol = ESyncMLUnknownSession; |
|
546 iJobId = 0; |
|
547 |
|
548 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() completed")); |
|
549 } |
|
550 |
|
551 // ----------------------------------------------------------------------------- |
|
552 // CSyncMLNotifierBase::SyncServiceL |
|
553 // ----------------------------------------------------------------------------- |
|
554 // |
|
555 CSyncService* CSyncMLAppLaunchNotifier::SyncServiceL( TUint aServiceId ) |
|
556 { |
|
557 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::SyncService")); |
|
558 |
|
559 if ( aServiceId == KDevManServiceStart ) |
|
560 { |
|
561 if ( !iDMSyncService ) |
|
562 { |
|
563 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::SyncServiceL() DM NewL")); |
|
564 iDMSyncService = CSyncService::NewL( NULL, KDevManServiceStart ); |
|
565 } |
|
566 return iDMSyncService; |
|
567 } |
|
568 else |
|
569 { |
|
570 if ( !iDSSyncService ) |
|
571 { |
|
572 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::SyncServiceL() DS NewL")); |
|
573 iDSSyncService = CSyncService::NewL( NULL, KDataSyncServiceStart ); |
|
574 } |
|
575 return iDSSyncService; |
|
576 } |
|
577 } |
|
578 //------------------------------------------------------------------------------ |
|
579 //CSyncMLAppLaunchNotifier::IsRoaming(TBool& ret) |
|
580 //Returns true if roaming otherwise returns false |
|
581 |
|
582 //------------------------------------------------------------------------------ |
|
583 |
|
584 void CSyncMLAppLaunchNotifier::IsRoamingL(TBool &ret) |
|
585 { |
|
586 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::IsRoaming() Begin")); |
|
587 RConnectionMonitor monitor; |
|
588 TRequestStatus status; |
|
589 // open RConnectionMonitor object |
|
590 monitor.ConnectL(); |
|
591 CleanupClosePushL( monitor ); |
|
592 TInt netwStatus(0); |
|
593 monitor.GetIntAttribute( EBearerIdGPRS, // See bearer ids from TConnMonBearerId |
|
594 0, |
|
595 KNetworkRegistration, |
|
596 netwStatus, |
|
597 status ); |
|
598 User::WaitForRequest( status ); |
|
599 if ( status.Int() == KErrNone ) |
|
600 { |
|
601 switch(netwStatus) |
|
602 { |
|
603 case ENetworkRegistrationRoaming : |
|
604 { |
|
605 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::IsRoaming() ENetworkRegistrationRoaming")); |
|
606 ret=true; |
|
607 break; |
|
608 } |
|
609 default: |
|
610 { |
|
611 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::IsRoaming() Roaming status ")); |
|
612 FTRACE( FPrint( |
|
613 _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::IsRoamingL() cell is not in roaming, network status is %d"), netwStatus ) ); |
|
614 break; |
|
615 } |
|
616 } |
|
617 CleanupStack::PopAndDestroy(); |
|
618 } |
|
619 else |
|
620 { |
|
621 FTRACE( FPrint( |
|
622 _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::IsRoamingL() RConnectinMonitor status.Int() returned error %d"), status.Int() ) ); |
|
623 } |
|
624 } |
|
625 //------------------------------------------------------------------------------ |
|
626 //CSyncMLAppLaunchNotifier::HandleDMSessionL() |
|
627 //Handles the DM Session |
|
628 //------------------------------------------------------------------------------ |
|
629 |
|
630 TBool CSyncMLAppLaunchNotifier::HandleDMSessionL() |
|
631 { |
|
632 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::HandleDMSessionL begins")); |
|
633 TBool ret(ETrue); |
|
634 TInt dmroamingBlock = 0; |
|
635 TBool roaming = EFalse; |
|
636 TLanguage language = User::Language(); |
|
637 FLOG( _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() Management session") ); |
|
638 CRepository* cRepository=NULL; |
|
639 TRAPD ( error, cRepository = CRepository::NewL ( KCRUidNSmlNotifierDomainKeys ) ); |
|
640 if ( error == KErrNone ) |
|
641 { |
|
642 CleanupStack::PushL( cRepository ); |
|
643 cRepository->Get ( KNSmlDMBlockedInRoaming, dmroamingBlock ); |
|
644 if(dmroamingBlock==1) |
|
645 { |
|
646 FLOG( _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() roaming feature is enabled") ); |
|
647 TRAPD(rError,IsRoamingL(roaming)); |
|
648 if( (rError==KErrNone) && roaming ) |
|
649 { |
|
650 FLOG( _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() phone is in roaming, DM session is blocked ") ); |
|
651 CleanupStack::PopAndDestroy( cRepository );//cRepository |
|
652 iNeedToCompleteMessage=EFalse; |
|
653 iReplySlot = NULL; |
|
654 ret = EFalse; |
|
655 return ret; |
|
656 } |
|
657 else |
|
658 { |
|
659 FTRACE( FPrint( |
|
660 _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() error in getting Network status %d"), rError ) ); |
|
661 FTRACE( FPrint( |
|
662 _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() error in getting Network status %d"),roaming ) ); |
|
663 } |
|
664 } |
|
665 else |
|
666 { |
|
667 FLOG( _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() DM blocking feature disabled ") ); |
|
668 } |
|
669 CleanupStack::PopAndDestroy( cRepository );//cRepository |
|
670 } |
|
671 else |
|
672 { |
|
673 FTRACE( FPrint( |
|
674 _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() cenrep creation error code %d"), |
|
675 error ) ); |
|
676 } |
|
677 TBuf<KSyncMLMaxProfileNameLength> serverName; |
|
678 RetrieveMgmtParamsL( param, DMSyncServerName, uiAction ); |
|
679 TInt CustomNotes(KErrNone), SanSupport( KErrNone ); |
|
680 CRepository* centrep = NULL; |
|
681 TRAPD(err1, centrep = CRepository::NewL ( KCRUidDeviceManagementInternalKeys ) ); |
|
682 if((centrep) && (err1 == KErrNone)) |
|
683 { |
|
684 centrep->Get( KDevManUINotesCustomization, CustomNotes); |
|
685 centrep->Get( KDevManSANUIBitVariation, SanSupport ); |
|
686 } |
|
687 else |
|
688 { |
|
689 CustomNotes = 0; |
|
690 SanSupport = 0; |
|
691 } |
|
692 delete centrep; |
|
693 |
|
694 if(CustomNotes && SanSupport && IsLanguageSupportedL()) |
|
695 { |
|
696 stringholder = StringLoader::LoadL( R_QTN_DM_QUERY_ACCEPT_POSTSALE); //This note will be shown in chinese variant itself |
|
697 } |
|
698 else |
|
699 { |
|
700 stringholder = StringLoader::LoadL( R_SML_INIT_DM_SERVER_PROMPT,DMSyncServerName ); |
|
701 } |
|
702 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::HandleDMSessionL ends")); |
|
703 return ret; |
|
704 } |
|
705 |
|
706 //------------------------------------------------------------------------------ |
|
707 //CSyncMLAppLaunchNotifier::HandleCompleteMessageL(TInt &keypress, TBool &silent, TInt &SanSupport, TInt &Timeout, TInt &CustomNotes) |
|
708 // Handle the complete message |
|
709 //------------------------------------------------------------------------------ |
|
710 |
|
711 void CSyncMLAppLaunchNotifier::HandleCompleteMessageL(TInt &keypress, TBool &silent, TInt &SanSupport, TInt &Timeout, TInt &CustomNotes) |
|
712 { |
|
713 TLanguage language = User::Language(); |
|
714 if( keypress == EAknSoftkeyYes || keypress == EAknSoftkeyOk || silent ) // User has accepted the dialog |
|
715 { |
|
716 TInt retval = 1; // Default for ESyncMLSyncSession or silent |
|
717 if ( iSmlProtocol == ESyncMLMgmtSession && !silent ) |
|
718 { |
|
719 CRepository* cRepository=NULL; |
|
720 TRAPD ( error, cRepository = CRepository::NewL ( KCRUidNSmlNotifierDomainKeys ) ); |
|
721 if ( error == KErrNone ) |
|
722 { |
|
723 CleanupStack::PushL( cRepository ); |
|
724 TInt dmChargingNote(1); |
|
725 cRepository->Get ( KNSmlDMChargingNote, dmChargingNote ); |
|
726 if(dmChargingNote==1) |
|
727 { |
|
728 stringholder = StringLoader::LoadLC( R_FOTA_CONF_QUERY_CONNECTION_IS_NEEDED ); |
|
729 CSyncMLTimedQueryDialog* dlg = CSyncMLTimedQueryDialog::NewL( *stringholder, Timeout ); |
|
730 dlg->PrepareLC( R_SML_CONFIRMATION_QUERY ); |
|
731 dlg->ButtonGroupContainer().SetCommandSetL( R_AVKON_SOFTKEYS_YES_NO ); |
|
732 keypress = dlg->RunLD(); |
|
733 if( keypress == EAknSoftkeyYes || keypress == EAknSoftkeyOk ) |
|
734 retval = 1; |
|
735 else retval = 0; |
|
736 dlg = NULL; |
|
737 CleanupStack::PopAndDestroy( stringholder ); |
|
738 } |
|
739 CleanupStack::PopAndDestroy( cRepository );//cRepository |
|
740 } |
|
741 } |
|
742 if( iSmlProtocol == ESyncMLMgmtSession && SanSupport == EON && silent && iUimode == ESANUserInformative ) |
|
743 { |
|
744 // Turn lights on and deactivate apps -key |
|
745 TurnLightsOn(); |
|
746 if(CustomNotes && IsLanguageSupportedL()) |
|
747 { |
|
748 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::informative session inside if ")); |
|
749 stringholder = StringLoader::LoadLC(R_QTN_DM_INFO_NOTE_POSTSALE); //This note will be shown in chinese variant only |
|
750 } |
|
751 else |
|
752 { |
|
753 stringholder = StringLoader::LoadLC(R_QTN_DM_INFO_NOTE_UPDATING , DMSyncServerName ); |
|
754 } |
|
755 CAknInformationNote* informationNote = new (ELeave) CAknInformationNote (); |
|
756 informationNote->ExecuteLD ( stringholder->Des() ); |
|
757 informationNote = NULL; |
|
758 CleanupStack::PopAndDestroy( stringholder ); |
|
759 } |
|
760 |
|
761 if ( retval ) |
|
762 { |
|
763 const TUid KUidFakeUID = { 0 }; |
|
764 TSyncMLAppLaunchNotifRetVal pckg; |
|
765 pckg.iSecureId = KUidFakeUID; |
|
766 |
|
767 switch( iSmlProtocol ) |
|
768 { |
|
769 case ESyncMLSyncSession: |
|
770 param.iServiceId = KDataSyncServiceStart; |
|
771 break; |
|
772 case ESyncMLMgmtSession: |
|
773 param.iServiceId = KDevManServiceStart; |
|
774 if( SanSupport == EON ) |
|
775 { |
|
776 param.iSilent = iUimode; |
|
777 } |
|
778 pckg.iSecureId = SyncServiceL( param.iServiceId )->StartSyncL( param ); |
|
779 break; |
|
780 default: |
|
781 // This branch should never be reached, since the option |
|
782 // is handled in the previous switch statement. |
|
783 User::Panic( KSmlNPanicCategory, KErrCorrupt ); |
|
784 break; |
|
785 } |
|
786 |
|
787 iMessage.WriteL( iReplySlot, TPckgBuf<TSyncMLAppLaunchNotifRetVal>(pckg) ); |
|
788 iMessage.Complete( KErrNone ); |
|
789 } |
|
790 else |
|
791 { |
|
792 // Complete the message with result code indicating that |
|
793 // the user cancelled the query. |
|
794 iMessage.Complete( KErrCancel ); |
|
795 } |
|
796 } |
|
797 else |
|
798 { |
|
799 // Complete the message with result code indicating that |
|
800 // the user cancelled the query. |
|
801 iMessage.Complete( KErrCancel ); |
|
802 } |
|
803 } |
|
804 |
|
805 // ----------------------------------------------------------------------------- |
|
806 // CSyncMLAppLaunchNotifier::IsLanguageSupportedL |
|
807 // Returns True if the specified language is supported. |
|
808 // ----------------------------------------------------------------------------- |
|
809 // |
|
810 TBool CSyncMLAppLaunchNotifier::IsLanguageSupportedL() |
|
811 { |
|
812 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::IsLanguageSupportedL begins")); |
|
813 TBool retVal(EFalse); |
|
814 TLanguage language = User::Language(); |
|
815 if(language == ELangEnglish || language == ELangInternationalEnglish || |
|
816 language == ELangTaiwanChinese ||language == ELangHongKongChinese || language == ELangPrcChinese) |
|
817 retVal = ETrue; |
|
818 FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::IsLanguageSupportedL ends")); |
|
819 return retVal; |
|
820 } |
|
821 // End of File |