applicationmanagement/server/src/ApplicationManagementServer.cpp
branchRCL_3
changeset 40 f2101057ffeb
parent 20 f6aa907032f4
child 55 c4687ff85147
--- a/applicationmanagement/server/src/ApplicationManagementServer.cpp	Wed Jun 09 09:27:55 2010 +0300
+++ b/applicationmanagement/server/src/ApplicationManagementServer.cpp	Mon Jun 21 15:26:00 2010 +0300
@@ -334,6 +334,41 @@
                     KSyncNotifier, EOwnerThread);
             User::LeaveIfError(r);
 
+            TBuf8<256> targetURI;
+
+            TDeploymentComponentState state = aComponent->State();
+
+            if (state == EDCSDownload)
+                {
+                targetURI.Append(KDownloadState);
+                targetURI.Append(aComponent->UserId());
+                }
+            else
+                if (state == EDCSDelivered)
+                    {
+                    targetURI.Append(KDeliveredState);
+                    targetURI.Append(aComponent->UserId());
+
+                    }
+                else
+                    if (state == EDCSActive|| state == EDCSInactive)
+                        {
+                        targetURI.Append(KDeployedState);
+                        targetURI.Append(aComponent->UserId());
+                        }
+
+						//Set Targeturi to cenrep
+		
+						CRepository* cenrep = NULL;
+  					TInt errr(KErrNone);
+	  				TRAP(errr, cenrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ));	  	
+	  				if(errr == KErrNone)
+	  				{
+    					errr = cenrep->Set( KNSmlDMSCOMOTargetRef, targetURI );    	
+    					delete cenrep;
+    					cenrep = NULL;
+    				}
+
             TInt err = counter.Set(KErrCancel);
             User::LeaveIfError(err);
             counter.Close();
@@ -2789,6 +2824,8 @@
     RDEBUG_2( "ApplicationManagementSession: DeactivateL id is %d", id );
     CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
     Server().Storage()->DeactivateL(compo);
+    
+    SetSCOMOTargetURI(compo.UserId());
     }
 
 // -------------------------------------------------------------------------------------------------------------------
@@ -2805,6 +2842,8 @@
     RDEBUG_2( "ApplicationManagementSession: ActivateL id is %d", id );
     CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
     Server().Storage()->ActivateL(compo);
+    
+    SetSCOMOTargetURI(compo.UserId());
     }
 
 // -------------------------------------------------------------------------------------------------------------------
@@ -2824,6 +2863,36 @@
     aMessage.Write( 1, compo.UserId() );
     }
 
+void CApplicationManagementSession::SetSCOMOTargetURI(const TDesC8& aURI) const
+    {
+    _LIT8( KAMSeparator8, "/" );
+    _LIT8( KAMStateValueNodeName, "State" );
+    TBuf8<256> targetStateURI(KDeployedState);
+    
+    targetStateURI.Append(aURI);
+    
+    targetStateURI.Append(KAMSeparator8);
+    targetStateURI.Append(KAMStateValueNodeName);
+            
+    CRepository* cenrep = NULL;
+    TInt errr(KErrNone);
+
+    TRAP(errr, cenrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ));
+
+    if(errr == KErrNone)
+    {
+    errr = cenrep->Set(KNSmlDMSCOMOTargetRef, targetStateURI);
+    }
+    
+    if(cenrep)
+        {
+        delete cenrep;
+        cenrep = NULL;
+        }
+    
+   
+    }
+
 // -------------------------------------------------------------------------------------------------------------------
 // CApplicationManagementSession::GetTemporaryInstFileL()
 // -------------------------------------------------------------------------------------------------------------------
@@ -2991,7 +3060,30 @@
     CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
     if (compo.State() == EDCSDelivered)
         {
-        Server().DoTheInstallL(compo) ;
+        TInt err(KErrNone);
+	  		TRAP(err, Server().DoTheInstallL(compo)) ;
+        TBuf8<256> targetURI;
+        TDeploymentComponentState state = compo.State();
+        if( state == EDCSDelivered)
+        	{
+        			targetURI.Append(KDeliveredState);
+              targetURI.Append(compo.UserId());
+          }
+          else if (state == EDCSActive|| state == EDCSInactive)
+          {
+          		targetURI.Append(KDeployedState);
+              targetURI.Append(compo.UserId());  
+        	} 
+        	
+        	//Set Targeturi to cenrep
+        	CRepository* cenrep = NULL;
+	  			TRAP(err, cenrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ));
+	  			if(err == KErrNone)
+	  			{		  				
+    				err = cenrep->Set( KNSmlDMSCOMOTargetRef, targetURI );    				
+    				delete cenrep;
+    				cenrep = NULL;
+    			} 
         }
     else
         {
@@ -3654,7 +3746,7 @@
         const RMessage2& aMessage) const
     {
     RDEBUG( "CApplicationManagementSession: StateChangeComponentIdsCountL" );
-                RPointerArray<TPreInstalledAppParams> preInstalledAppParams;
+               RPointerArray<TPreInstalledAppParams> preInstalledAppParams;
                 CAMPreInstallApp* preInstallApp = CAMPreInstallApp::NewL();
                 preInstallApp->GetPreInstalledAppsL(preInstalledAppParams);
                 TInt count = 0;