17 |
17 |
18 #include <e32math.h> |
18 #include <e32math.h> |
19 #include <DevManInternalCRKeys.h> |
19 #include <DevManInternalCRKeys.h> |
20 #include <centralrepository.h> |
20 #include <centralrepository.h> |
21 #include <nsmldebug.h> |
21 #include <nsmldebug.h> |
22 |
22 #include "PnpLogger.h" |
23 #include "nsmlsosthread.h" |
23 #include "nsmlsosthread.h" |
24 #include <DataSyncInternalPSKeys.h> |
24 #include <DataSyncInternalPSKeys.h> |
25 |
25 |
26 #include <PolicyEngineClient.h> |
26 #include <PolicyEngineClient.h> |
27 #include <centralrepository.h> |
27 #include <centralrepository.h> |
28 #include "PMUtilInternalCRKeys.h" |
28 #include "PMUtilInternalCRKeys.h" |
29 #include <featmgr.h> |
29 #include <featmgr.h> |
|
30 #include <e32property.h> |
|
31 #include <DevManInternalCRKeys.h> |
|
32 #include <nsmldmconst.h> |
|
33 |
|
34 |
|
35 enum TSyncmlHbNotifierKeys |
|
36 { |
|
37 |
|
38 EHbSOSNotifierKeyStatus = 11, // status set will complete the client subscribe |
|
39 EHbSOSNotifierKeyStatusReturn = 12, // Return the content of actual status value accepted from UI |
|
40 |
|
41 EHbDMSyncNotifierKeyStatus = 13, |
|
42 EHbDMSyncNotifierKeyStatusReturn = 14 |
|
43 }; |
|
44 |
|
45 TUid sosserverpsuid = |
|
46 { |
|
47 0x101F99FB |
|
48 }; |
|
49 |
|
50 |
30 // -------------------------------------------------------------------------- |
51 // -------------------------------------------------------------------------- |
31 // EXPORT_C TInt ThreadFunction( TAny* ) |
52 // EXPORT_C TInt ThreadFunction( TAny* ) |
32 // -------------------------------------------------------------------------- |
53 // -------------------------------------------------------------------------- |
33 // |
54 // |
34 TInt ThreadFunction( TAny* aStarted ) |
55 TInt ThreadFunction( TAny* aStarted ) |
337 } |
357 } |
338 |
358 |
339 TInt status( KErrNone ); |
359 TInt status( KErrNone ); |
340 if ( iThreadParams.iCurrentJob.UsageType() == ESmlDevMan ) |
360 if ( iThreadParams.iCurrentJob.UsageType() == ESmlDevMan ) |
341 { |
361 { |
342 CRepository* centrep = NULL; |
|
343 TRAPD( err, centrep = CRepository::NewL(KCRUidDeviceManagementInternalKeys)); |
|
344 TInt phoneLock(0); |
|
345 TInt factoryProfileID(0); |
|
346 if (err==KErrNone ) |
|
347 { |
|
348 TInt err = centrep->Get( KLAWMOPhoneLock , phoneLock ); |
|
349 err = centrep->Get( KLAWMOfactoryDmProfileID , factoryProfileID ); |
|
350 delete centrep; |
|
351 centrep = NULL; |
|
352 } |
|
353 if(phoneLock != 30) |
|
354 { |
|
355 _DBG_FILE("CNSmlThreadEngine phonelock != 30"); |
|
356 if(factoryProfileID>0) |
|
357 { |
|
358 |
|
359 TInt profileId = iThreadParams.iCurrentJob.ProfileId(); |
|
360 |
|
361 if(profileId!= factoryProfileID) |
|
362 { |
|
363 _DBG_FILE("CNSmlThreadEngine profid doesnt match with factory"); |
|
364 TRequestStatus* stat = &iStatus; |
|
365 User::RequestComplete( stat, KErrNone ); |
|
366 return; |
|
367 } |
|
368 |
|
369 } |
|
370 else |
|
371 { |
|
372 _DBG_FILE("CNSmlThreadEngine factoryprofileid<0"); |
|
373 TRequestStatus* stat = &iStatus; |
|
374 User::RequestComplete( stat, KErrNone ); |
|
375 return; |
|
376 } |
|
377 } |
|
378 _DBG_FILE("CNSmlThreadEngine startDMSessionL"); |
|
379 TRAP( status, StartDMSessionL() ); |
362 TRAP( status, StartDMSessionL() ); |
380 } |
363 } |
381 else |
364 else |
382 { |
365 { |
383 // Scenario 1: |
366 TRAP( status, StartDSSessionL() ); |
384 // Fix for cancel not happening when cancel key is |
|
385 // pressed . |
|
386 if(!iSyncCancelled) |
|
387 { |
|
388 TRAP( status, StartDSSessionL() ); |
|
389 } |
|
390 else |
|
391 { |
|
392 // Sync is cancelled from the UI before the |
|
393 // the job session has started. |
|
394 // Fix for cancel not happening when cancel key is |
|
395 // pressed . |
|
396 status = KErrCancel; |
|
397 iSyncCancelled = EFalse; |
|
398 } |
|
399 } |
367 } |
400 |
368 |
401 if ( status != KErrNone ) |
369 if ( status != KErrNone ) |
402 { |
370 { |
403 TRequestStatus* sStatus = &iStatus; |
371 TRequestStatus* sStatus = &iStatus; |
511 // -------------------------------------------------------------------------- |
466 // -------------------------------------------------------------------------- |
512 // CNSmlThreadEngine::VerifyJobFromNotifierL() |
467 // CNSmlThreadEngine::VerifyJobFromNotifierL() |
513 // Launches notifier and waits for |
468 // Launches notifier and waits for |
514 // -------------------------------------------------------------------------- |
469 // -------------------------------------------------------------------------- |
515 // |
470 // |
516 TInt CNSmlThreadEngine::VerifyJobFromNotifierL() |
471 TInt CNSmlThreadEngine::VerifyJobFromNotifierL(TBool aServerInitiated) |
517 { |
472 { |
518 _DBG_FILE("CNSmlThreadEngine::VerifyJobFromNotifierL() : Begin"); |
473 LOGSTRING("CNSmlThreadEngine::VerifyJobFromNotifierL()"); |
519 iNotifierObserver = new (ELeave) CNSmlNotifierObserver(iStatus, iThreadParams); |
474 LOGSTRING("CNSmlThreadEngine::VerifyJobFromNotifierL() : Begin"); |
520 SetActive(); |
475 LOGSTRING2("VerifyJobFromNotifierL before iCallerStatus == iStatus in Threadengine %d", iStatus.Int()); |
521 |
476 iNotifierObserver = new (ELeave) CNSmlNotifierObserver(iStatus, |
522 TSyncMLAppLaunchNotifParams params; |
477 iThreadParams); |
523 params.iSessionType = ( iThreadParams.iCurrentJob.UsageType() == ESmlDataSync ) ? ESyncMLSyncSession : ESyncMLMgmtSession; |
478 SetActive(); |
524 params.iJobId = iThreadParams.iCurrentJob.JobId(); |
479 LOGSTRING2("VerifyJobFromNotifierL before iCallerStatus == iStatus in Threadengine %d after setactive", iStatus.Int()); |
525 params.iProfileId = iThreadParams.iCurrentJob.ProfileId(); |
480 TSyncMLAppLaunchNotifParams params; |
526 params.iUimode = iThreadParams.iCurrentJob.iUimode; |
481 params.iSessionType = (iThreadParams.iCurrentJob.UsageType() |
527 iNotifierObserver->ConnectToNotifierL( params ); |
482 == ESmlDataSync) ? ESyncMLSyncSession : ESyncMLMgmtSession; |
528 _DBG_FILE("CNSmlThreadEngine::VerifyJobFromNotifierL() : End"); |
483 params.iJobId = iThreadParams.iCurrentJob.JobId(); |
|
484 params.iProfileId = iThreadParams.iCurrentJob.ProfileId(); |
|
485 params.iUimode = iThreadParams.iCurrentJob.iUimode; |
|
486 iNotifierObserver->ConnectToNotifierL(params); |
|
487 LOGSTRING2("iCallerStatus in iNotifierObserver->ConnectToNotifierL( params ); %d", iStatus.Int()); |
|
488 LOGSTRING("CNSmlThreadEngine::VerifyJobFromNotifierL() : End"); |
529 return KErrNone; |
489 return KErrNone; |
530 } |
490 } |
531 |
491 |
532 // -------------------------------------------------------------------------- |
492 // -------------------------------------------------------------------------- |
533 // CNSmlThreadEngine::DMAgentL() |
493 // CNSmlThreadEngine::DMAgentL() |
822 // -------------------------------------------------------------------------- |
782 // -------------------------------------------------------------------------- |
823 // CNSmlNotifierObserver::CNSmlNotifierObserver(TRequestStatus& aStatus, CNSmlThreadEngine* aEngine, CNSmlThreadParams& aParams) |
783 // CNSmlNotifierObserver::CNSmlNotifierObserver(TRequestStatus& aStatus, CNSmlThreadEngine* aEngine, CNSmlThreadParams& aParams) |
824 // Constructor |
784 // Constructor |
825 // -------------------------------------------------------------------------- |
785 // -------------------------------------------------------------------------- |
826 // |
786 // |
827 CNSmlNotifierObserver::CNSmlNotifierObserver(TRequestStatus& aStatus, CNSmlThreadParams& aParams) |
787 CNSmlNotifierObserver::CNSmlNotifierObserver(TRequestStatus& aStatus, |
828 : CActive(0), iCallerStatus(aStatus), iThreadParams(aParams) |
788 CNSmlThreadParams& aParams) : |
829 { |
789 CActive(0), iCallerStatus(aStatus), iThreadParams(aParams) |
830 CActiveScheduler::Add(this); |
790 { |
831 } |
791 LOGSTRING2("iCallerStatus in RunL %d", iCallerStatus.Int()); |
|
792 // If the current job is DM job then proceed to use Hb Notifiers |
|
793 |
|
794 if(aParams.iCurrentJob.UsageType() == ESmlDevMan) |
|
795 { |
|
796 TRAP_IGNORE(iHbSyncmlNotifierEnabled = IsHbSyncmlNotifierEnabledL()); |
|
797 } |
|
798 |
|
799 CActiveScheduler::Add(this); |
|
800 } |
832 |
801 |
833 // -------------------------------------------------------------------------- |
802 // -------------------------------------------------------------------------- |
834 // CNSmlNotifierObserver::~CNSmlNotifierObserver() |
803 // CNSmlNotifierObserver::~CNSmlNotifierObserver() |
835 // Destructor |
804 // Destructor |
836 // -------------------------------------------------------------------------- |
805 // -------------------------------------------------------------------------- |
837 // |
806 // |
838 CNSmlNotifierObserver::~CNSmlNotifierObserver() |
807 CNSmlNotifierObserver::~CNSmlNotifierObserver() |
839 { |
808 { |
840 |
809 LOGSTRING("~CNSmlNotifierObserver"); |
841 // StartNotifier called to avoid Notifier server panic, if |
810 // StartNotifier called to avoid Notifier server panic, if |
842 // notifier does not exist anymore. |
811 // notifier does not exist anymore. |
843 TBuf8<1> dummy; |
812 TBuf8<1> dummy; |
844 iNotifier.StartNotifier(KNullUid, dummy, dummy); // KNullUid should do also.. |
813 |
845 |
814 if (!iHbSyncmlNotifierEnabled) |
846 iNotifier.CancelNotifier( KUidNotifier ); |
815 { |
847 iNotifier.Close(); |
816 // iNotifier.StartNotifier(KNullUid, dummy, dummy); // KNullUid should do also.. |
848 Cancel(); |
817 |
849 } |
818 // iNotifier.CancelNotifier(KUidNotifier); |
|
819 // iNotifier.Close(); |
|
820 } |
|
821 else |
|
822 { |
|
823 if(iDmDevdialog.Handle() ) |
|
824 iDmDevdialog.Close(); |
|
825 } |
|
826 |
|
827 Cancel(); |
|
828 } |
850 |
829 |
851 // -------------------------------------------------------------------------- |
830 // -------------------------------------------------------------------------- |
852 // CNSmlNotifierObserver::ConnectToNotifierL( const TSyncMLAppLaunchNotifParams& aParam ) |
831 // CNSmlNotifierObserver::ConnectToNotifierL( const TSyncMLAppLaunchNotifParams& aParam ) |
853 // Starts connection with notifier |
832 // Starts connection with notifier |
854 // -------------------------------------------------------------------------- |
833 // -------------------------------------------------------------------------- |
855 // |
834 // |
856 void CNSmlNotifierObserver::ConnectToNotifierL( const TSyncMLAppLaunchNotifParams& aParam ) |
835 void CNSmlNotifierObserver::ConnectToNotifierL( const TSyncMLAppLaunchNotifParams& aParam ) |
857 { |
836 { |
858 _DBG_FILE( "CNSmlNotifierObserver::ConnectToNotifierL:Begin" ); |
837 _DBG_FILE( "CNSmlNotifierObserver::ConnectToNotifierL:Begin" ); |
859 iTimeOut = EFalse; |
838 iTimeOut = EFalse; |
860 |
|
861 if ( !IsActive() ) |
|
862 { |
|
863 SetActive(); |
|
864 } |
|
865 |
|
866 |
|
867 TSyncMLAppLaunchNotifParamsPckg data( aParam ); |
|
868 |
839 |
869 if ( !KNSmlWaitNotifierForEver ) |
840 if ( !KNSmlWaitNotifierForEver ) |
870 { |
841 { |
871 iNotifierTimeOut.LaunchNotifierTimer( this ); |
842 iNotifierTimeOut.LaunchNotifierTimer( this ); |
872 } |
843 } |
873 |
844 |
874 TInt err = iNotifier.Connect(); |
845 if (!iHbSyncmlNotifierEnabled) |
875 if ( err == KErrNone ) |
846 { |
|
847 LOGSTRING2( "CNSmlNotifierObserver::ConnectToNotifierL %d after connect, StartNotifierAndGetResponse and after setactive" , iStatus.Int()); |
|
848 } |
|
849 else |
|
850 { |
|
851 iStatus = KRequestPending; |
|
852 HbNotifierObserverL(aParam); |
|
853 } |
|
854 if ( !IsActive() ) |
|
855 { |
|
856 SetActive(); |
|
857 } |
|
858 _DBG_FILE("CNSmlNotifierObserver::ConnectToNotifierL:End"); |
|
859 } |
|
860 |
|
861 // -------------------------------------------------------------------------- |
|
862 // CNSmlNotifierObserver::IsHbNotifierEnabled() |
|
863 // Launch Hb Notifier Process |
|
864 // -------------------------------------------------------------------------- |
|
865 // |
|
866 TBool CNSmlNotifierObserver::IsHbSyncmlNotifierEnabledL() |
|
867 { |
|
868 CRepository * rep = |
|
869 CRepository::NewLC(KCRUidDeviceManagementInternalKeys); |
|
870 |
|
871 TInt notifierenabled = KErrNone; |
|
872 |
|
873 TInt err = rep->Get(KDevManEnableHbNotifier, notifierenabled); |
|
874 |
|
875 CleanupStack::PopAndDestroy(rep); |
|
876 |
|
877 if (err == KErrNone && notifierenabled) |
876 { |
878 { |
877 iNotifier.StartNotifierAndGetResponse( iStatus, KUidNotifier, data, iResBuf ); |
879 return ETrue; |
878 } |
880 } |
879 else |
881 else |
880 { |
882 { |
881 // Stop job. Error connecting to notifier. |
883 return EFalse; |
882 TRequestStatus* sStatus = &iStatus; |
|
883 User::RequestComplete( sStatus, err ); |
|
884 } |
884 } |
885 _DBG_FILE("CNSmlNotifierObserver::ConnectToNotifierL:End"); |
885 |
886 } |
886 } |
|
887 |
|
888 // -------------------------------------------------------------------------- |
|
889 // CNSmlNotifierObserver::HbNotifierObserverL() |
|
890 // Launch Hb Notifier Process |
|
891 // -------------------------------------------------------------------------- |
|
892 // |
|
893 void CNSmlNotifierObserver::HbNotifierObserverL(const TSyncMLAppLaunchNotifParams& aParam) |
|
894 { |
|
895 |
|
896 LOGSTRING2("iCallerStatus before HbNotifierObserverL creation %d", iCallerStatus.Int()); |
|
897 TInt err = iDmDevdialog.OpenL(); |
|
898 User::LeaveIfError(err); |
|
899 iDmDevdialog.LaunchPkgZero(aParam.iProfileId,aParam.iJobId,aParam.iUimode,iResBuf,iStatus); |
|
900 |
|
901 LOGSTRING2("CNSmlNotifierObserver hb notifier %d after subscribe", iStatus.Int()); |
|
902 |
|
903 LOGSTRING2("iCallerStatus before HbNotifierObserverL creation %d", iCallerStatus.Int()); |
|
904 } |
887 |
905 |
888 // -------------------------------------------------------------------------- |
906 // -------------------------------------------------------------------------- |
889 // CNSmlNotifierObserver::NotifierTimeOut() |
907 // CNSmlNotifierObserver::NotifierTimeOut() |
890 // Starts notifier time out timer |
908 // Starts notifier time out timer |
891 // -------------------------------------------------------------------------- |
909 // -------------------------------------------------------------------------- |
892 // |
910 // |
893 void CNSmlNotifierObserver::NotifierTimeOut() |
911 void CNSmlNotifierObserver::NotifierTimeOut() |
894 { |
912 { |
895 iTimeOut = ETrue; |
913 LOGSTRING("CNSmlNotifierObserver NotifierTimeOut "); |
896 |
914 iTimeOut = ETrue; |
897 // StartNotifier called to avoid Notifier server panic, if |
915 |
898 // notifier does not exist anymore. |
916 // StartNotifier called to avoid Notifier server panic, if |
899 TBuf8<1> dummy; |
917 // notifier does not exist anymore. |
900 iNotifier.StartNotifier(KNullUid, dummy, dummy); // KNullUid should do also.. |
918 if(!iHbSyncmlNotifierEnabled) |
901 iNotifier.CancelNotifier( KUidNotifier ); |
919 { |
902 } |
920 TBuf8<1> dummy; |
|
921 // iNotifier.StartNotifier(KNullUid, dummy, dummy); // KNullUid should do also.. |
|
922 // iNotifier.CancelNotifier( KUidNotifier ); |
|
923 } |
|
924 else |
|
925 { |
|
926 iProperty.Close(); |
|
927 } |
|
928 } |
903 |
929 |
904 // -------------------------------------------------------------------------- |
930 // -------------------------------------------------------------------------- |
905 // CNSmlNotifierObserver::DoCancel() |
931 // CNSmlNotifierObserver::DoCancel() |
906 // From base class |
932 // From base class |
907 // -------------------------------------------------------------------------- |
933 // -------------------------------------------------------------------------- |