syncmlfw/common/sosserver/src/nsmlsosthread.cpp
changeset 51 2e64dc50f295
parent 40 588ad05716be
child 55 1c556dee8eb1
equal deleted inserted replaced
50:a36219ae6585 51:2e64dc50f295
    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>
    30 #include <e32property.h>
    31 #include <DevManInternalCRKeys.h>
    31 #include <DevManInternalCRKeys.h>
       
    32 #include <nsmldmconst.h>
    32 
    33 
    33 
    34 
    34 enum TSyncmlHbNotifierKeys 
    35 enum TSyncmlHbNotifierKeys 
    35 		{
    36 		{
    36 
    37 
   118 	    if ( threadEngine->IsActive() )
   119 	    if ( threadEngine->IsActive() )
   119 	        {
   120 	        {
   120 	        CActiveScheduler::Start();                
   121 	        CActiveScheduler::Start();                
   121 	        }	    
   122 	        }	    
   122 	    }	
   123 	    }	
   123 	
   124 	LOGSTRING("P&S is deleted");  
       
   125 	RProperty::Delete(KPSUidNSmlSOSServerKey,KNSmlDMSilentJob);
   124 	delete scheduler;
   126 	delete scheduler;
   125 	
   127 	
   126 	if ( endStatus == KErrNone )
   128 	if ( endStatus == KErrNone )
   127 		{
   129 		{
   128 		endStatus = threadEngine->FinishedStatus();	
   130 		endStatus = threadEngine->FinishedStatus();	
   816 //        iNotifier.CancelNotifier(KUidNotifier);
   818 //        iNotifier.CancelNotifier(KUidNotifier);
   817 //        iNotifier.Close();
   819 //        iNotifier.Close();
   818         }
   820         }
   819     else
   821     else
   820         {
   822         {
   821         iProperty.Close();
   823         if(iDmDevdialog.Handle() )
       
   824              iDmDevdialog.Close();
   822         }
   825         }
   823 
   826 
   824     Cancel();
   827     Cancel();
   825     }
   828     }
   826 
   829 
   832 void CNSmlNotifierObserver::ConnectToNotifierL( const TSyncMLAppLaunchNotifParams& aParam )
   835 void CNSmlNotifierObserver::ConnectToNotifierL( const TSyncMLAppLaunchNotifParams& aParam )
   833 	{
   836 	{
   834 	_DBG_FILE( "CNSmlNotifierObserver::ConnectToNotifierL:Begin" );
   837 	_DBG_FILE( "CNSmlNotifierObserver::ConnectToNotifierL:Begin" );
   835 	iTimeOut = EFalse;
   838 	iTimeOut = EFalse;
   836 	
   839 	
   837 	if ( !IsActive() )
   840 	/*if ( !IsActive() )
   838 		{
   841 		{
   839 		SetActive();
   842 		SetActive();
   840 		}
   843 		}*/
   841 		
   844 		
   842 	   
   845 	   
   843     TSyncMLAppLaunchNotifParamsPckg data( aParam );
   846     TSyncMLAppLaunchNotifParamsPckg data( aParam );
   844     
   847     
   845     if ( !KNSmlWaitNotifierForEver )
   848     if ( !KNSmlWaitNotifierForEver )
   860 //                    data, iResBuf);
   863 //                    data, iResBuf);
   861             LOGSTRING2( "CNSmlNotifierObserver::ConnectToNotifierL %d after connect, StartNotifierAndGetResponse and after setactive" , iStatus.Int());
   864             LOGSTRING2( "CNSmlNotifierObserver::ConnectToNotifierL %d after connect, StartNotifierAndGetResponse and after setactive" , iStatus.Int());
   862             }
   865             }
   863         else
   866         else
   864             {
   867             {
       
   868        iStatus = KRequestPending;
   865             HbNotifierObserverL(aParam);
   869             HbNotifierObserverL(aParam);
   866             }
   870             }
       
   871         if ( !IsActive() )
       
   872                 {
       
   873                 SetActive();
       
   874                 }
   867         }
   875         }
   868     else
   876     else
   869         {
   877         {
   870         LOGSTRING("Stop job error connecting to notifier");
   878         LOGSTRING("Stop job error connecting to notifier");
   871         // Stop job. Error connecting to notifier.
   879         // Stop job. Error connecting to notifier.
   909 //
   917 //
   910 void CNSmlNotifierObserver::HbNotifierObserverL(const TSyncMLAppLaunchNotifParams& aParam)
   918 void CNSmlNotifierObserver::HbNotifierObserverL(const TSyncMLAppLaunchNotifParams& aParam)
   911     {
   919     {
   912 
   920 
   913     LOGSTRING2("iCallerStatus before HbNotifierObserverL creation %d", iCallerStatus.Int());
   921     LOGSTRING2("iCallerStatus before HbNotifierObserverL creation %d", iCallerStatus.Int());
   914     
   922    TInt err = iDmDevdialog.OpenL();
   915     _LIT(KHbNotifier,"com.nokia.hb.devicemanagementdialog/1.0");
   923    User::LeaveIfError(err);
   916     
   924   iDmDevdialog.LaunchPkgZero(aParam.iProfileId,aParam.iJobId,aParam.iUimode,iResBuf,iStatus);
   917     _LIT(KNotifierId, "aasyncmlfw");
   925      
   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());
   926     LOGSTRING2("CNSmlNotifierObserver hb notifier %d after subscribe", iStatus.Int());
   999 
   927 
  1000     LOGSTRING2("iCallerStatus before HbNotifierObserverL creation %d", iCallerStatus.Int());
   928     LOGSTRING2("iCallerStatus before HbNotifierObserverL creation %d", iCallerStatus.Int());
  1001     }
   929     }
  1002 
   930 
  1039 // --------------------------------------------------------------------------
   967 // --------------------------------------------------------------------------
  1040 //	
   968 //	
  1041 void CNSmlNotifierObserver::RunL()
   969 void CNSmlNotifierObserver::RunL()
  1042     {
   970     {
  1043 
   971 
  1044     if (iDevDialog && iHbSyncmlNotifierEnabled)
   972 
  1045         {
       
  1046 
       
  1047         
       
  1048     TInt status = KErrNone;
       
  1049   
       
  1050           TInt err  =  RProperty::Get(sosserverpsuid,EHbSOSNotifierKeyStatusReturn , status);
       
  1051 
       
  1052         LOGSTRING2("status is %d", status);
       
  1053 
       
  1054          LOGSTRING2("err of ps key is %d", err);
       
  1055 
       
  1056        if(status == KErrCancel)
       
  1057 		iStatus = KErrCancel;
       
  1058 
       
  1059         iDevDialog->Cancel();
       
  1060         delete iDevDialog;
       
  1061         }
       
  1062 
   973 
  1063     LOGSTRING("CNSmlNotifierObserver RunL start");
   974     LOGSTRING("CNSmlNotifierObserver RunL start");
  1064 
   975 
  1065     TInt ret = iStatus.Int();
   976     TInt ret = iStatus.Int();
  1066     if ( ret == KErrCancel && iTimeOut )
   977     if ( ret == KErrCancel && iTimeOut )
  1069     	}
   980     	}
  1070     else
   981     else
  1071     if ( ret == KErrNone )
   982     if ( ret == KErrNone )
  1072     	{	   
   983     	{	   
  1073         
   984         
  1074 	  	TInt sid = iResBuf().iSecureId.iUid; // read secure id from notifier.
   985 	  	TInt sid = iResBuf(); // read secure id from notifier.
  1075 	   	
   986 	   	
  1076 	    // Check the response and error code. If there is a fail, dump the job.        
   987 	    // Check the response and error code. If there is a fail, dump the job.        
  1077 	    // Also compare sid to creator id saved for current job to secure that listener owns the job.
   988 	    // Also compare sid to creator id saved for current job to secure that listener owns the job.
  1078 	    if ( ret != KErrNone || sid != iThreadParams.iCurrentJob.CreatorId() )
   989 	    if ( ret != KErrNone || sid != iThreadParams.iCurrentJob.CreatorId() )
  1079 	        {
   990 	        {