dcmofw/dcmoserver/src/dcmoserver.cpp
branchGCC_SURGE
changeset 53 b3a7d8e28262
parent 44 39aa16f3fdc2
child 73 ae69c2e8bc34
equal deleted inserted replaced
39:ac7f88fb2797 53:b3a7d8e28262
    19 #include <implementationproxy.h>
    19 #include <implementationproxy.h>
    20 #include <ecom.h>
    20 #include <ecom.h>
    21 #include <e32base.h>
    21 #include <e32base.h>
    22 #include <centralrepository.h>
    22 #include <centralrepository.h>
    23 #include <stringresourcereader.h> 
    23 #include <stringresourcereader.h> 
    24 #include <dcmo.rsg> // Resource to be read header
       
    25 #include <AknGlobalMsgQuery.h>
       
    26 #include <data_caging_path_literals.hrh>
    24 #include <data_caging_path_literals.hrh>
    27 #include <f32file.h> 
    25 #include <f32file.h> 
       
    26 #include <hbtextresolversymbian.h>
    28 #include "dcmoclientserver.h"
    27 #include "dcmoclientserver.h"
    29 #include "dcmoconst.h"
    28 #include "dcmoconst.h"
    30 #include "dcmointerface.h"
    29 #include "dcmointerface.h"
    31 #include "dcmoserver.h"
    30 #include "dcmoserver.h"
    32 #include "dcmosession.h"
    31 #include "dcmosession.h"
    33 #include "dcmogenericcontrol.h"
    32 #include "dcmogenericcontrol.h"
    34 #include "dcmodebug.h"
    33 #include "dcmodebug.h"
    35 
    34 
    36 _LIT( KdcmoResourceFileName, "z:dcmo.rsc" );	
    35 
       
    36 _LIT( KdcmoResourceFileName, "deviceupdates_" );	
       
    37 _LIT( KdcmoResourceFilePath, "z:/resource/qt/translations/" );	
    37 const TInt KBufferSize = 256;
    38 const TInt KBufferSize = 256;
    38 
    39 
    39 TInt CDCMOServer::iSessionCount = 0;
    40 TInt CDCMOServer::iSessionCount = 0;
    40 // Standard server startup code
    41 // Standard server startup code
    41 // 
    42 // 
   112 // ----------------------------------------------------------------------------------------
   113 // ----------------------------------------------------------------------------------------
   113 
   114 
   114 CDCMOServer::CDCMOServer() : CServer2(EPriorityStandard, EUnsharableSessions) /*CServer2(0)*/
   115 CDCMOServer::CDCMOServer() : CServer2(EPriorityStandard, EUnsharableSessions) /*CServer2(0)*/
   115 	{	
   116 	{	
   116 		iStarter = EFalse;
   117 		iStarter = EFalse;
   117 		iNotifier = NULL;
   118 		iMessageBox = NULL;
   118 	}
   119 	}
   119 
   120 
   120 // ----------------------------------------------------------------------------------------
   121 // ----------------------------------------------------------------------------------------
   121 // CDCMOServer::~CDCMOServer() 
   122 // CDCMOServer::~CDCMOServer() 
   122 // ----------------------------------------------------------------------------------------
   123 // ----------------------------------------------------------------------------------------
   128 	if(count)
   129 	if(count)
   129 	{	
   130 	{	
   130 		for(TInt i=0; i< count; i++)
   131 		for(TInt i=0; i< count; i++)
   131 				delete idcmoArray[i].iCategoryName;
   132 				delete idcmoArray[i].iCategoryName;
   132 		idcmoArray.Reset();
   133 		idcmoArray.Reset();
   133 		delete iNotifier;
   134 		delete iMessageBox;
   134 		iNotifier = NULL;	
   135 		iMessageBox = NULL;	
   135 	}
   136 	}
   136 	else
   137 	else
   137 	{
   138 	{
   138 		//Kill the server
   139 		//Kill the server
   139 		if( iSessionCount == 0)
   140 		if( iSessionCount == 0)
   155 		if ( iStarter ) 
   156 		if ( iStarter ) 
   156   	{
   157   	{
   157   		RDEBUG("CDCMOServer::DropSession(): Starter");
   158   		RDEBUG("CDCMOServer::DropSession(): Starter");
   158   		SetStarter( EFalse );
   159   		SetStarter( EFalse );
   159   		return;                 
   160   		return;                 
   160   	}   
   161   	} 
       
   162   	if(CDCMOMessageBox::IsMsgBoxClosed())
       
   163   	{
       
   164   		CleanDcmoArray();
       
   165   	}  
   161 		if( idcmoArray.Count() && ( iSessionCount == 0 ))
   166 		if( idcmoArray.Count() && ( iSessionCount == 0 ))
   162 		{
   167 		{
   163 			// A session is being destroyed		
   168 			// A session is being destroyed		
   164 			TRAPD( err, DoFinalizeL());		
   169 			TRAPD( err, DoFinalizeL());		
   165 			if ( !err )
   170 			if ( !err )
   367 	if(categotyNumber != -1)
   372 	if(categotyNumber != -1)
   368 	{
   373 	{
   369 			RDEBUG("CDCMOServer::SetIntAttributeL(): LocalCategory");
   374 			RDEBUG("CDCMOServer::SetIntAttributeL(): LocalCategory");
   370 			CDCMOGenericControl* iGenericControl = new(ELeave) CDCMOGenericControl;
   375 			CDCMOGenericControl* iGenericControl = new(ELeave) CDCMOGenericControl;
   371 			err = iGenericControl->SetIntAttributeL(categotyNumber, id, value);	
   376 			err = iGenericControl->SetIntAttributeL(categotyNumber, id, value);	
   372 			TFileName myFileName;
   377 			
   373   		TParse parseObj;
   378 			TBool result = HbTextResolverSymbian::Init(KdcmoResourceFileName, KdcmoResourceFilePath );					
   374   		parseObj.Set( KdcmoResourceFileName(), &KDC_RESOURCE_FILES_DIR,NULL );
   379 
   375  			myFileName = parseObj.FullName();
       
   376  			CStringResourceReader* test = CStringResourceReader::NewL( myFileName );
       
   377 			TPtrC buf;
   380 			TPtrC buf;
   378 			dcmoList.iUid = categotyNumber;
   381 			dcmoList.iUid = categotyNumber;
   379 			if(categotyNumber == 0)
   382 			if(categotyNumber == 0)
   380 			    {			    
   383 			    {
   381 			    buf.Set(test->ReadResourceString(R_DM_RUN_TIME_VAR_CAMERA));
   384 					_LIT(KTextCamera, "txt_device_update_info_camera");
   382 			    stringHolder = buf.AllocL() ; 
   385 					stringHolder = HbTextResolverSymbian::LoadL(KTextCamera);
   383 			    } 
   386 			    } 
   384 			else
   387 			else
   385 			    {			   
   388 			    {	
   386 			    buf.Set(test->ReadResourceString(R_DM_RUN_TIME_VAR_FIRMWARE_UPDATE));
   389 					_LIT(KTextFOTA, "txt_device_update_info_firmware_update");
   387 			    stringHolder = buf.AllocL() ; 
   390 					stringHolder = HbTextResolverSymbian::LoadL(KTextFOTA);
   388 			    }			
   391 			    }		
   389      delete test;
       
   390      test = NULL;
       
   391   	 delete iGenericControl;
   392   	 delete iGenericControl;
   392 		 iGenericControl = NULL;
   393 		 iGenericControl = NULL;
   393 	}
   394 	}
   394 	else
   395 	else
   395 	{
   396 	{
   414 	if ( iStarter )   			
   415 	if ( iStarter )   			
   415    {
   416    {
   416   		RDEBUG("CDCMOServer::SetIntAttributeL(): Starter");
   417   		RDEBUG("CDCMOServer::SetIntAttributeL(): Starter");
   417   		SetStarter ( EFalse );
   418   		SetStarter ( EFalse );
   418   		delete stringHolder;
   419   		delete stringHolder;
   419 		stringHolder = NULL;
   420 			stringHolder = NULL;
   420   		return err;                
   421   		return err;                
   421    }   
   422    }   
   422 	if((err == EDcmoSuccess) && (id == EEnable) ) 
   423 	if((err == EDcmoSuccess) && (id == EEnable) ) 
   423 	{
   424 	{
   424 		TInt arrayCount = idcmoArray.Count();
   425 		TInt arrayCount = idcmoArray.Count();
   475 void CDCMOServer::DoFinalizeL()
   476 void CDCMOServer::DoFinalizeL()
   476 {
   477 {
   477 	RDEBUG("CDCMOServer::DoFinalizeL(): begin");	   
   478 	RDEBUG("CDCMOServer::DoFinalizeL(): begin");	   
   478 
   479 
   479 	HBufC* content  = HBufC::NewLC(KDCMOMaxStringSize);
   480 	HBufC* content  = HBufC::NewLC(KDCMOMaxStringSize);
   480   	TPtr   contentptr  = content->Des(); 
   481   TPtr   contentptr  = content->Des(); 
   481 	HBufC* enableContent  = HBufC::NewLC(KDCMOMaxStringSize);
   482 	HBufC* enableContent  = HBufC::NewLC(KDCMOMaxStringSize);
   482 	TPtr   enableContentptr  = enableContent->Des(); 
   483 	TPtr   enableContentptr  = enableContent->Des(); 
   483 	HBufC* disableContent  = HBufC::NewLC(KDCMOMaxStringSize);
   484 	HBufC* disableContent  = HBufC::NewLC(KDCMOMaxStringSize);
   484 	TPtr   disableContentptr  = disableContent->Des(); 
   485 	TPtr   disableContentptr  = disableContent->Des(); 
   485 
   486 
   486 	TBool enable ( EFalse );
   487 	TBool enable ( EFalse );
   487 	TBool disable ( EFalse );
   488 	TBool disable ( EFalse );
   488 	TFileName myFileName;
       
   489   TParse parseObj;
       
   490   parseObj.Set( KdcmoResourceFileName(), &KDC_RESOURCE_FILES_DIR,NULL );
       
   491   myFileName = parseObj.FullName();
       
   492 	TInt arrayCount = idcmoArray.Count(); 
   489 	TInt arrayCount = idcmoArray.Count(); 
   493 	_LIT(KNewLine, "\n");
   490 	_LIT(KNewLine, "\n");
   494 		
   491 		
   495 	if( arrayCount > 0)
   492 	if( arrayCount > 0)
   496 	{
   493 	{
   507       	{
   504       	{
   508       		disableContentptr.Append(KNewLine());
   505       		disableContentptr.Append(KNewLine());
   509       		disableContentptr.Append( idcmoArray[i].iCategoryName->Des() );
   506       		disableContentptr.Append( idcmoArray[i].iCategoryName->Des() );
   510       		disable = ETrue;
   507       		disable = ETrue;
   511       	}	
   508       	}	
   512 		}
   509 		}	  
   513 	  
   510   
   514   	CStringResourceReader* test = CStringResourceReader::NewL( myFileName );	  
   511 		TBool result = HbTextResolverSymbian::Init(KdcmoResourceFileName, KdcmoResourceFilePath );
   515 		if ( enable )
   512 		if ( enable )
   516 		{
   513 		{
   517 			TPtrC buf;
   514 			_LIT(KTextEnabled, "txt_device_update_title_enabled_by_the_system_admi");
   518 			buf.Set(test->ReadResourceString(R_DM_RUN_TIME_VAR_ENABLE)); 	    	
   515 			HBufC* buf = HbTextResolverSymbian::LoadL(KTextEnabled);
   519 			contentptr.Append(buf);
   516 			contentptr.Append(buf->Des());
   520 	 		contentptr.Append(enableContentptr);
   517 	 		contentptr.Append(enableContentptr);
       
   518 	 		delete buf;
   521 		}
   519 		}
   522 		if ( disable )
   520 		if ( disable )
   523 		{
   521 		{
   524 	 		TPtrC buf;
   522 	 		_LIT(KTextDisabled, "txt_device_update_title_disabled_by_the_system_adm");
   525 	 		buf.Set(test->ReadResourceString(R_DM_RUN_TIME_VAR_DISABLE));
   523 			HBufC* buf = HbTextResolverSymbian::LoadL(KTextDisabled);
   526 	 		if( enable )
   524 	 		if( enable )
   527 	 			contentptr.Append(KNewLine());
   525 	 			contentptr.Append(KNewLine());	 		
   528 	 		contentptr.Append(buf);
   526 			contentptr.Append(buf->Des());
   529 	 		contentptr.Append(disableContentptr);
   527 	 		contentptr.Append(disableContentptr);
   530 		}
   528 	 		delete buf;
   531 		delete test;
   529 		}
   532 		test = NULL;
   530 	
   533 		
   531 		if( !iMessageBox )
   534 		if( iNotifier )
   532 		{		
   535 		{
   533 			iMessageBox = CDCMOMessageBox::NewL();					
   536 			iNotifier->Cancel();
   534 		}
   537 		}
   535 		iMessageBox->ShowMessageL(contentptr);
   538 		else
   536 
   539 		{			
       
   540 			iNotifier = CDCMONotifierAob::NewL( );			
       
   541 		}
       
   542 		
       
   543 	  iNotifier->ShowNotifierL(contentptr);    
       
   544 	  CleanupStack::PopAndDestroy(3); //disableContent, enableContent, content
   537 	  CleanupStack::PopAndDestroy(3); //disableContent, enableContent, content
   545 	}	
   538 	}	
   546 	RDEBUG("CDCMOServer::DoFinalizeL(): end");
   539 	RDEBUG("CDCMOServer::DoFinalizeL(): end");
   547 }
   540 }
   548 // ----------------------------------------------------------------------------------------
   541 // ----------------------------------------------------------------------------------------
   616 {
   609 {
   617 	RDEBUG("CDCMOServer::SetStarter(): begin");
   610 	RDEBUG("CDCMOServer::SetStarter(): begin");
   618 	iStarter = aValue;
   611 	iStarter = aValue;
   619 	RDEBUG("CDCMOServer::SetStarter(): end");
   612 	RDEBUG("CDCMOServer::SetStarter(): end");
   620 }
   613 }
       
   614 
       
   615 // ----------------------------------------------------------------------------------------
       
   616 // CDCMOServer::CleanDcmoArray
       
   617 // Sets the iStarter value
       
   618 // ----------------------------------------------------------------------------------------
       
   619 void CDCMOServer::CleanDcmoArray()
       
   620 {
       
   621 	RDEBUG("CDCMOServer::CleanDcmoArray(): begin");
       
   622 	TInt count = idcmoArray.Count();  
       
   623   RDEBUG_2("CDCMOServer::CleanDcmoArray; %d", count );
       
   624 	if(count)
       
   625 	{	
       
   626 		for(TInt i=0; i< count; i++)
       
   627 				delete idcmoArray[i].iCategoryName;
       
   628 		idcmoArray.Reset();
       
   629 	}
       
   630 	CDCMOMessageBox::SetMsgBoxStatus(EFalse);
       
   631 	RDEBUG("CDCMOServer::CleanDcmoArray(): end");
       
   632 }