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 |
|
33 |
|
34 enum TSyncmlHbNotifierKeys |
|
35 { |
|
36 |
|
37 EHbSOSNotifierKeyStatus = 11, // status set will complete the client subscribe |
|
38 EHbSOSNotifierKeyStatusReturn = 12, // Return the content of actual status value accepted from UI |
|
39 |
|
40 EHbDMSyncNotifierKeyStatus = 13, |
|
41 EHbDMSyncNotifierKeyStatusReturn = 14 |
|
42 }; |
|
43 |
|
44 TUid sosserverpsuid = |
|
45 { |
|
46 0x101F99FB |
|
47 }; |
|
48 |
|
49 |
30 // -------------------------------------------------------------------------- |
50 // -------------------------------------------------------------------------- |
31 // EXPORT_C TInt ThreadFunction( TAny* ) |
51 // EXPORT_C TInt ThreadFunction( TAny* ) |
32 // -------------------------------------------------------------------------- |
52 // -------------------------------------------------------------------------- |
33 // |
53 // |
34 TInt ThreadFunction( TAny* aStarted ) |
54 TInt ThreadFunction( TAny* aStarted ) |
444 // -------------------------------------------------------------------------- |
464 // -------------------------------------------------------------------------- |
445 // CNSmlThreadEngine::VerifyJobFromNotifierL() |
465 // CNSmlThreadEngine::VerifyJobFromNotifierL() |
446 // Launches notifier and waits for |
466 // Launches notifier and waits for |
447 // -------------------------------------------------------------------------- |
467 // -------------------------------------------------------------------------- |
448 // |
468 // |
449 TInt CNSmlThreadEngine::VerifyJobFromNotifierL() |
469 TInt CNSmlThreadEngine::VerifyJobFromNotifierL(TBool aServerInitiated) |
450 { |
470 { |
451 _DBG_FILE("CNSmlThreadEngine::VerifyJobFromNotifierL() : Begin"); |
471 LOGSTRING("CNSmlThreadEngine::VerifyJobFromNotifierL()"); |
452 iNotifierObserver = new (ELeave) CNSmlNotifierObserver(iStatus, iThreadParams); |
472 LOGSTRING("CNSmlThreadEngine::VerifyJobFromNotifierL() : Begin"); |
453 SetActive(); |
473 LOGSTRING2("VerifyJobFromNotifierL before iCallerStatus == iStatus in Threadengine %d", iStatus.Int()); |
454 |
474 iNotifierObserver = new (ELeave) CNSmlNotifierObserver(iStatus, |
455 TSyncMLAppLaunchNotifParams params; |
475 iThreadParams); |
456 params.iSessionType = ( iThreadParams.iCurrentJob.UsageType() == ESmlDataSync ) ? ESyncMLSyncSession : ESyncMLMgmtSession; |
476 SetActive(); |
457 params.iJobId = iThreadParams.iCurrentJob.JobId(); |
477 LOGSTRING2("VerifyJobFromNotifierL before iCallerStatus == iStatus in Threadengine %d after setactive", iStatus.Int()); |
458 params.iProfileId = iThreadParams.iCurrentJob.ProfileId(); |
478 TSyncMLAppLaunchNotifParams params; |
459 params.iUimode = iThreadParams.iCurrentJob.iUimode; |
479 params.iSessionType = (iThreadParams.iCurrentJob.UsageType() |
460 iNotifierObserver->ConnectToNotifierL( params ); |
480 == ESmlDataSync) ? ESyncMLSyncSession : ESyncMLMgmtSession; |
461 _DBG_FILE("CNSmlThreadEngine::VerifyJobFromNotifierL() : End"); |
481 params.iJobId = iThreadParams.iCurrentJob.JobId(); |
|
482 params.iProfileId = iThreadParams.iCurrentJob.ProfileId(); |
|
483 params.iUimode = iThreadParams.iCurrentJob.iUimode; |
|
484 iNotifierObserver->ConnectToNotifierL(params); |
|
485 LOGSTRING2("iCallerStatus in iNotifierObserver->ConnectToNotifierL( params ); %d", iStatus.Int()); |
|
486 LOGSTRING("CNSmlThreadEngine::VerifyJobFromNotifierL() : End"); |
462 return KErrNone; |
487 return KErrNone; |
463 } |
488 } |
464 |
489 |
465 // -------------------------------------------------------------------------- |
490 // -------------------------------------------------------------------------- |
466 // CNSmlThreadEngine::DMAgentL() |
491 // CNSmlThreadEngine::DMAgentL() |
755 // -------------------------------------------------------------------------- |
780 // -------------------------------------------------------------------------- |
756 // CNSmlNotifierObserver::CNSmlNotifierObserver(TRequestStatus& aStatus, CNSmlThreadEngine* aEngine, CNSmlThreadParams& aParams) |
781 // CNSmlNotifierObserver::CNSmlNotifierObserver(TRequestStatus& aStatus, CNSmlThreadEngine* aEngine, CNSmlThreadParams& aParams) |
757 // Constructor |
782 // Constructor |
758 // -------------------------------------------------------------------------- |
783 // -------------------------------------------------------------------------- |
759 // |
784 // |
760 CNSmlNotifierObserver::CNSmlNotifierObserver(TRequestStatus& aStatus, CNSmlThreadParams& aParams) |
785 CNSmlNotifierObserver::CNSmlNotifierObserver(TRequestStatus& aStatus, |
761 : CActive(0), iCallerStatus(aStatus), iThreadParams(aParams) |
786 CNSmlThreadParams& aParams) : |
762 { |
787 CActive(0), iCallerStatus(aStatus), iThreadParams(aParams) |
763 CActiveScheduler::Add(this); |
788 { |
764 } |
789 LOGSTRING2("iCallerStatus in RunL %d", iCallerStatus.Int()); |
|
790 // If the current job is DM job then proceed to use Hb Notifiers |
|
791 |
|
792 if(aParams.iCurrentJob.UsageType() == ESmlDevMan) |
|
793 { |
|
794 TRAP_IGNORE(iHbSyncmlNotifierEnabled = IsHbSyncmlNotifierEnabledL()); |
|
795 } |
|
796 |
|
797 CActiveScheduler::Add(this); |
|
798 } |
765 |
799 |
766 // -------------------------------------------------------------------------- |
800 // -------------------------------------------------------------------------- |
767 // CNSmlNotifierObserver::~CNSmlNotifierObserver() |
801 // CNSmlNotifierObserver::~CNSmlNotifierObserver() |
768 // Destructor |
802 // Destructor |
769 // -------------------------------------------------------------------------- |
803 // -------------------------------------------------------------------------- |
770 // |
804 // |
771 CNSmlNotifierObserver::~CNSmlNotifierObserver() |
805 CNSmlNotifierObserver::~CNSmlNotifierObserver() |
772 { |
806 { |
773 |
807 LOGSTRING("~CNSmlNotifierObserver"); |
774 // StartNotifier called to avoid Notifier server panic, if |
808 // StartNotifier called to avoid Notifier server panic, if |
775 // notifier does not exist anymore. |
809 // notifier does not exist anymore. |
776 TBuf8<1> dummy; |
810 TBuf8<1> dummy; |
777 iNotifier.StartNotifier(KNullUid, dummy, dummy); // KNullUid should do also.. |
811 |
778 |
812 if (!iHbSyncmlNotifierEnabled) |
779 iNotifier.CancelNotifier( KUidNotifier ); |
813 { |
780 iNotifier.Close(); |
814 iNotifier.StartNotifier(KNullUid, dummy, dummy); // KNullUid should do also.. |
781 Cancel(); |
815 |
782 } |
816 iNotifier.CancelNotifier(KUidNotifier); |
|
817 iNotifier.Close(); |
|
818 } |
|
819 else |
|
820 { |
|
821 iProperty.Close(); |
|
822 } |
|
823 |
|
824 Cancel(); |
|
825 } |
783 |
826 |
784 // -------------------------------------------------------------------------- |
827 // -------------------------------------------------------------------------- |
785 // CNSmlNotifierObserver::ConnectToNotifierL( const TSyncMLAppLaunchNotifParams& aParam ) |
828 // CNSmlNotifierObserver::ConnectToNotifierL( const TSyncMLAppLaunchNotifParams& aParam ) |
786 // Starts connection with notifier |
829 // Starts connection with notifier |
787 // -------------------------------------------------------------------------- |
830 // -------------------------------------------------------------------------- |
801 |
844 |
802 if ( !KNSmlWaitNotifierForEver ) |
845 if ( !KNSmlWaitNotifierForEver ) |
803 { |
846 { |
804 iNotifierTimeOut.LaunchNotifierTimer( this ); |
847 iNotifierTimeOut.LaunchNotifierTimer( this ); |
805 } |
848 } |
806 |
849 |
807 TInt err = iNotifier.Connect(); |
850 TInt err = KErrNone; |
808 if ( err == KErrNone ) |
851 |
809 { |
852 if (!iHbSyncmlNotifierEnabled) //Syncml notifier |
810 iNotifier.StartNotifierAndGetResponse( iStatus, KUidNotifier, data, iResBuf ); |
853 err = iNotifier.Connect(); |
|
854 |
|
855 if (err == KErrNone) |
|
856 { |
|
857 if (!iHbSyncmlNotifierEnabled) |
|
858 { |
|
859 iNotifier.StartNotifierAndGetResponse(iStatus, KUidNotifier, |
|
860 data, iResBuf); |
|
861 LOGSTRING2( "CNSmlNotifierObserver::ConnectToNotifierL %d after connect, StartNotifierAndGetResponse and after setactive" , iStatus.Int()); |
|
862 } |
|
863 else |
|
864 { |
|
865 HbNotifierObserverL(aParam); |
|
866 } |
811 } |
867 } |
812 else |
868 else |
813 { |
869 { |
|
870 LOGSTRING("Stop job error connecting to notifier"); |
814 // Stop job. Error connecting to notifier. |
871 // Stop job. Error connecting to notifier. |
815 TRequestStatus* sStatus = &iStatus; |
872 TRequestStatus* sStatus = &iStatus; |
816 User::RequestComplete( sStatus, err ); |
873 User::RequestComplete( sStatus, err ); |
817 } |
874 } |
818 _DBG_FILE("CNSmlNotifierObserver::ConnectToNotifierL:End"); |
875 _DBG_FILE("CNSmlNotifierObserver::ConnectToNotifierL:End"); |
819 } |
876 } |
820 |
877 |
821 // -------------------------------------------------------------------------- |
878 // -------------------------------------------------------------------------- |
|
879 // CNSmlNotifierObserver::IsHbNotifierEnabled() |
|
880 // Launch Hb Notifier Process |
|
881 // -------------------------------------------------------------------------- |
|
882 // |
|
883 TBool CNSmlNotifierObserver::IsHbSyncmlNotifierEnabledL() |
|
884 { |
|
885 CRepository * rep = |
|
886 CRepository::NewLC(KCRUidDeviceManagementInternalKeys); |
|
887 |
|
888 TInt notifierenabled = KErrNone; |
|
889 |
|
890 TInt err = rep->Get(KDevManEnableHbNotifier, notifierenabled); |
|
891 |
|
892 CleanupStack::PopAndDestroy(rep); |
|
893 |
|
894 if (err == KErrNone && notifierenabled) |
|
895 { |
|
896 return ETrue; |
|
897 } |
|
898 else |
|
899 { |
|
900 return EFalse; |
|
901 } |
|
902 |
|
903 } |
|
904 |
|
905 // -------------------------------------------------------------------------- |
|
906 // CNSmlNotifierObserver::HbNotifierObserverL() |
|
907 // Launch Hb Notifier Process |
|
908 // -------------------------------------------------------------------------- |
|
909 // |
|
910 void CNSmlNotifierObserver::HbNotifierObserverL(const TSyncMLAppLaunchNotifParams& aParam) |
|
911 { |
|
912 |
|
913 LOGSTRING2("iCallerStatus before HbNotifierObserverL creation %d", iCallerStatus.Int()); |
|
914 |
|
915 _LIT(KHbNotifier,"com.nokia.hb.devicemanagementdialog/1.0"); |
|
916 |
|
917 _LIT(KNotifierId, "aasyncmlfw"); |
|
918 _LIT(KProfileId, "profileid"); |
|
919 _LIT(KUImode, "uimode"); |
|
920 _LIT(KServerdisplayname, "serverdisplayname"); |
|
921 |
|
922 CHbSymbianVariantMap* varMap = CHbSymbianVariantMap::NewL(); |
|
923 CleanupStack::PushL(varMap); |
|
924 |
|
925 HBufC* notifierid = HBufC::NewL(10); |
|
926 CleanupStack::PushL(notifierid); |
|
927 *notifierid =KNotifierId; |
|
928 |
|
929 |
|
930 HBufC* profileid = HBufC::NewL(10); |
|
931 CleanupStack::PushL(profileid); |
|
932 *profileid = KProfileId; |
|
933 |
|
934 HBufC* uimode = HBufC::NewL(10); |
|
935 CleanupStack::PushL(uimode); |
|
936 *uimode = KUImode; |
|
937 |
|
938 HBufC* serverdisplay = HBufC::NewL(20); |
|
939 CleanupStack::PushL(serverdisplay); |
|
940 *serverdisplay = KServerdisplayname; |
|
941 |
|
942 TBuf<256> servername; |
|
943 |
|
944 CNSmlDMSettings* settings = CNSmlDMSettings::NewLC(); |
|
945 CNSmlDMProfile* prof = settings->ProfileL( |
|
946 aParam.iProfileId); |
|
947 CleanupStack::PushL(prof); |
|
948 |
|
949 servername = prof->StrValue(EDMProfileDisplayName); |
|
950 |
|
951 CleanupStack::PopAndDestroy(2); |
|
952 |
|
953 TInt id =1000000; |
|
954 |
|
955 CHbSymbianVariant* notifieridvar = CHbSymbianVariant::NewL(&id, |
|
956 CHbSymbianVariant::EInt); |
|
957 |
|
958 |
|
959 CHbSymbianVariant* infoprofileid = CHbSymbianVariant::NewL(&aParam.iProfileId, |
|
960 CHbSymbianVariant::EInt); |
|
961 |
|
962 //CleanupStack::PushL(infoprofileid); |
|
963 |
|
964 CHbSymbianVariant* infouimode = CHbSymbianVariant::NewL(&aParam.iUimode, |
|
965 CHbSymbianVariant::EInt); |
|
966 |
|
967 CHbSymbianVariant* serverdisplayname = CHbSymbianVariant::NewL(&servername, |
|
968 CHbSymbianVariant::EDes); |
|
969 //CleanupStack::PushL(infouimode); |
|
970 |
|
971 varMap->Add(*notifierid, notifieridvar); |
|
972 varMap->Add(*profileid, infoprofileid); // takes ownership |
|
973 varMap->Add(*uimode, infouimode); |
|
974 varMap->Add(*serverdisplay, serverdisplayname); |
|
975 |
|
976 /*subscribe key value*/ |
|
977 TInt err = RProperty::Define(sosserverpsuid, EHbSOSNotifierKeyStatus, RProperty::EInt); |
|
978 |
|
979 err = RProperty::Define(sosserverpsuid, EHbSOSNotifierKeyStatusReturn, RProperty::EInt); |
|
980 |
|
981 err = iProperty.Attach(sosserverpsuid, EHbSOSNotifierKeyStatus); |
|
982 |
|
983 iProperty.Subscribe(iStatus); |
|
984 |
|
985 |
|
986 |
|
987 iDevDialog = CHbDeviceDialogSymbian::NewL(); |
|
988 iDevDialog->Show(KHbNotifier, *varMap); |
|
989 |
|
990 CleanupStack::PopAndDestroy(5); |
|
991 |
|
992 |
|
993 |
|
994 LOGSTRING2("CNSmlNotifierObserver hb notifier %d before subscribe", iStatus.Int()); |
|
995 |
|
996 |
|
997 |
|
998 LOGSTRING2("CNSmlNotifierObserver hb notifier %d after subscribe", iStatus.Int()); |
|
999 |
|
1000 LOGSTRING2("iCallerStatus before HbNotifierObserverL creation %d", iCallerStatus.Int()); |
|
1001 } |
|
1002 |
|
1003 // -------------------------------------------------------------------------- |
822 // CNSmlNotifierObserver::NotifierTimeOut() |
1004 // CNSmlNotifierObserver::NotifierTimeOut() |
823 // Starts notifier time out timer |
1005 // Starts notifier time out timer |
824 // -------------------------------------------------------------------------- |
1006 // -------------------------------------------------------------------------- |
825 // |
1007 // |
826 void CNSmlNotifierObserver::NotifierTimeOut() |
1008 void CNSmlNotifierObserver::NotifierTimeOut() |
827 { |
1009 { |
828 iTimeOut = ETrue; |
1010 LOGSTRING("CNSmlNotifierObserver NotifierTimeOut "); |
829 |
1011 iTimeOut = ETrue; |
830 // StartNotifier called to avoid Notifier server panic, if |
1012 |
831 // notifier does not exist anymore. |
1013 // StartNotifier called to avoid Notifier server panic, if |
832 TBuf8<1> dummy; |
1014 // notifier does not exist anymore. |
833 iNotifier.StartNotifier(KNullUid, dummy, dummy); // KNullUid should do also.. |
1015 if(!iHbSyncmlNotifierEnabled) |
834 iNotifier.CancelNotifier( KUidNotifier ); |
1016 { |
835 } |
1017 TBuf8<1> dummy; |
|
1018 iNotifier.StartNotifier(KNullUid, dummy, dummy); // KNullUid should do also.. |
|
1019 iNotifier.CancelNotifier( KUidNotifier ); |
|
1020 } |
|
1021 else |
|
1022 { |
|
1023 iProperty.Close(); |
|
1024 } |
|
1025 } |
836 |
1026 |
837 // -------------------------------------------------------------------------- |
1027 // -------------------------------------------------------------------------- |
838 // CNSmlNotifierObserver::DoCancel() |
1028 // CNSmlNotifierObserver::DoCancel() |
839 // From base class |
1029 // From base class |
840 // -------------------------------------------------------------------------- |
1030 // -------------------------------------------------------------------------- |