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