dcmofw/dcmoserver/src/dcmoserver.cpp
changeset 0 b497e44ab2fc
child 24 13d7c31c74e0
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  DCMO Server implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include <e32svr.h>
       
    19 #include <implementationproxy.h>
       
    20 #include <ecom.h>
       
    21 #include <e32base.h>
       
    22 #include <centralrepository.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>
       
    27 #include <f32file.h> 
       
    28 #include "dcmoclientserver.h"
       
    29 #include "dcmoconst.h"
       
    30 #include "dcmointerface.h"
       
    31 #include "dcmoserver.h"
       
    32 #include "dcmosession.h"
       
    33 #include "dcmogenericcontrol.h"
       
    34 #include "dcmodebug.h"
       
    35 
       
    36 _LIT( KdcmoResourceFileName, "z:dcmo.rsc" );	
       
    37 const TInt KBufferSize = 256;
       
    38 
       
    39 TInt CDCMOServer::iSessionCount = 0;
       
    40 // Standard server startup code
       
    41 // 
       
    42 static void StartServerL()
       
    43 	{
       
    44 	RDEBUG("DCMOServer: Starting server...");
       
    45 	
       
    46 	// EPOC and EKA 2 is easy, we just create a new server process. Simultaneous
       
    47 	// launching of two such processes should be detected when the second one
       
    48 	// attempts to create the server object, failing with KErrAlreadyExists.
       
    49 	// naming the server thread after the server helps to debug panics
       
    50 	User::LeaveIfError(User::RenameThread(KDCMOServerName));	
       
    51 	
       
    52 	// create and install the active scheduler
       
    53 	CActiveScheduler* s=new(ELeave) CActiveScheduler;
       
    54 	CleanupStack::PushL(s);
       
    55 	CActiveScheduler::Install(s);
       
    56 
       
    57 	// create the server (leave it on the cleanup stack)
       
    58 	CDCMOServer::NewLC();
       
    59 
       
    60 	// Initialisation complete, now signal the client
       
    61 	RProcess::Rendezvous(KErrNone);
       
    62 
       
    63 	// Ready to run
       
    64 	CActiveScheduler::Start();
       
    65 
       
    66 	// Cleanup the server and scheduler
       
    67 	CleanupStack::PopAndDestroy(2);
       
    68 	}
       
    69 
       
    70 // ----------------------------------------------------------------------------------------
       
    71 // Server process entry-point
       
    72 // ----------------------------------------------------------------------------------------
       
    73 TInt E32Main()
       
    74 	{
       
    75 	__UHEAP_MARK;
       
    76 	CTrapCleanup* cleanup=CTrapCleanup::New();
       
    77 	TInt r=KErrNoMemory;
       
    78 	if (cleanup)
       
    79 		{
       
    80 		TRAP(r,StartServerL());
       
    81 		delete cleanup;
       
    82 		}
       
    83 	__UHEAP_MARKEND;
       
    84 	return r;
       
    85 	}
       
    86 
       
    87 // ----------------------------------------------------------------------------------------
       
    88 // CDCMOServer::NewLC
       
    89 // ----------------------------------------------------------------------------------------
       
    90 CServer2* CDCMOServer::NewLC()
       
    91 {
       
    92 	RDEBUG("CDCMOServer::NewLC- begin");
       
    93 	CDCMOServer* self=new(ELeave) CDCMOServer;
       
    94 	CleanupStack::PushL(self);
       
    95 	self->ConstructL();	
       
    96 	RDEBUG("CDCMOServer::NewLC- end");
       
    97 	return self;
       
    98 }
       
    99 
       
   100 // ----------------------------------------------------------------------------------------
       
   101 // CDCMOServer::ConstructL
       
   102 // ----------------------------------------------------------------------------------------
       
   103 void CDCMOServer::ConstructL()
       
   104 	{
       
   105 	RDEBUG("CDCMOServer::ConstructL- begin");
       
   106 	StartL(KDCMOServerName);	
       
   107 	RDEBUG("CDCMOServer::ConstructL- end");
       
   108 	}
       
   109 
       
   110 // ----------------------------------------------------------------------------------------
       
   111 // CDCMOServer::CDCMOServer() 
       
   112 // ----------------------------------------------------------------------------------------
       
   113 
       
   114 CDCMOServer::CDCMOServer() : CServer2(EPriorityStandard, EUnsharableSessions) /*CServer2(0)*/
       
   115 	{	
       
   116 		iStarter = EFalse;
       
   117 		iNotifier = NULL;
       
   118 	}
       
   119 
       
   120 // ----------------------------------------------------------------------------------------
       
   121 // CDCMOServer::~CDCMOServer() 
       
   122 // ----------------------------------------------------------------------------------------
       
   123 CDCMOServer::~CDCMOServer()
       
   124 {	
       
   125 	RDEBUG("CDCMOServer::~CDCMOServer- begin");
       
   126   TInt count = idcmoArray.Count();  
       
   127   RDEBUG_2("CDCMOServer::~CDCMOServer; %d", count );
       
   128 	if(count)
       
   129 	{	
       
   130 		for(TInt i=0; i< count; i++)
       
   131 				delete idcmoArray[i].iCategoryName;
       
   132 		idcmoArray.Reset();
       
   133 		delete iNotifier;
       
   134 		iNotifier = NULL;	
       
   135 	}
       
   136 	else
       
   137 	{
       
   138 		//Kill the server
       
   139 		if( iSessionCount == 0)
       
   140 			CActiveScheduler::Stop();	
       
   141 	}
       
   142 	
       
   143 	REComSession::FinalClose();
       
   144 	RDEBUG("CDCMOServer::~CDCMOServer- end");
       
   145 }
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // CDCMOServer::DropSession()
       
   149 // -----------------------------------------------------------------------------
       
   150 
       
   151 void CDCMOServer::DropSession()
       
   152 	{
       
   153 		RDEBUG("CDCMOServer::DropSession- begin");
       
   154 		iSessionCount--;
       
   155 		if ( iStarter ) 
       
   156   	{
       
   157   		RDEBUG("CDCMOServer::DropSession(): Starter");
       
   158   		SetStarter( EFalse );
       
   159   		return;                 
       
   160   	}   
       
   161 		if( idcmoArray.Count() && ( iSessionCount == 0 ))
       
   162 		{
       
   163 			// A session is being destroyed		
       
   164 			TRAPD( err, DoFinalizeL());		
       
   165 			if ( !err )
       
   166 			{
       
   167 				RDEBUG_2("CDCMOServer::DropSession err =  %d", err );
       
   168 			}						
       
   169 		}		
       
   170 		RDEBUG("CDCMOServer::DropSession- end");
       
   171 	}
       
   172 
       
   173 // ----------------------------------------------------------------------------------------
       
   174 // CDCMOServer::NewSessionL
       
   175 // Create a new client session. This should really check the version number.
       
   176 // ----------------------------------------------------------------------------------------
       
   177 CSession2* CDCMOServer::NewSessionL(const TVersion& aVersion,const RMessage2&) const
       
   178 	{
       
   179 	RDEBUG("CDCMOServer::NewSessionL");
       
   180 
       
   181 	// check we're the right version
       
   182 	TVersion v(KDCMOServerMajorVersionNumber,
       
   183 	           KDCMOServerMinorVersionNumber,
       
   184 	           KDCMOServerBuildVersionNumber);
       
   185 	if (!User::QueryVersionSupported(v,aVersion))
       
   186 		{
       
   187 			RDEBUG("CDCMOServer::NewSessionL - KErrNotSupported");
       
   188 			User::Leave(KErrNotSupported);
       
   189 		}
       
   190 	if( iSessionCount > 0 )	
       
   191 	{
       
   192 		RDEBUG("CDCMOServer::NewSessionL - KErrServerBusy");
       
   193 		User::Leave(KErrServerBusy );		
       
   194 	}
       
   195 	else
       
   196 		 iSessionCount++;
       
   197 		 		
       
   198 	return new (ELeave) CDCMOSession(); 
       
   199 	}
       
   200 	
       
   201 void CleanupEComArray(TAny* aArray)
       
   202 	{
       
   203 	(static_cast<RImplInfoPtrArray*> (aArray))->ResetAndDestroy();
       
   204 	(static_cast<RImplInfoPtrArray*> (aArray))->Close();
       
   205 	}
       
   206 // ----------------------------------------------------------------------------------------
       
   207 // CDCMOServer::GetAdapterUidL
       
   208 // Gets the plug-in adapter implementation uid if it present.
       
   209 // ----------------------------------------------------------------------------------------
       
   210 TUid CDCMOServer::GetAdapterUidL(const TDesC& aCategory)
       
   211 {
       
   212 	RDEBUG("CDCMOServer::GetDCMOAdapterUidL(): begin");
       
   213 	
       
   214 	TUid retUid = {0x0};
       
   215 	
       
   216 	RImplInfoPtrArray infoArray;
       
   217 	// Note that a special cleanup function is required to reset and destroy
       
   218 	// all items in the array, and then close it.
       
   219 	TCleanupItem cleanup(CleanupEComArray, &infoArray);
       
   220 	CleanupStack::PushL(cleanup);
       
   221 	REComSession::ListImplementationsL(KDCMOInterfaceUid, infoArray);
       
   222 
       
   223 	// Loop through each info for each implementation			
       
   224 	TBuf8<KBufferSize> buf;            
       
   225 	for (TInt i=0; i< infoArray.Count(); i++)
       
   226 	{
       
   227 		buf = infoArray[i]->OpaqueData();
       
   228 		TBuf8<KBufferSize> category;
       
   229 		category.Copy(aCategory);
       
   230 		if(category.Find(infoArray[i]->OpaqueData())!= KErrNotFound)
       
   231 		{
       
   232 			retUid = infoArray[i]->ImplementationUid();
       
   233 			break;
       
   234 		}
       
   235 		buf.Zero();
       
   236 	}
       
   237 	CleanupStack::PopAndDestroy(); //cleanup
       
   238 	
       
   239 	RDEBUG("CDCMOServer::GetDCMOAdapterUidL(): end");
       
   240 	return retUid;
       
   241 }
       
   242 // ----------------------------------------------------------------------------------------
       
   243 // CDCMOServer::GetLocalCategoryL
       
   244 // Gets the cenrep key value of the plug-in adapter if it is available.
       
   245 // ----------------------------------------------------------------------------------------
       
   246 TInt CDCMOServer::GetLocalCategoryL(const TDesC& aCategory)
       
   247 {
       
   248 	RDEBUG("CDCMOServer::GetLocalCategoryL(): begin");
       
   249 	TInt ret(-1);	
       
   250 	
       
   251 	CRepository* centrep = NULL;
       
   252 	TInt err(KErrNone);
       
   253 	TRAP(err, centrep = CRepository::NewL( KCRUidDCMOServer ));
       
   254 	if(err != KErrNone)
       
   255 	{
       
   256 		RDEBUG("CDCMOServer::GetLocalCategoryL(): DCMO central repository does not exist");
       
   257 		return ret;
       
   258 	}
       
   259 	TUint32 centrepKey = 0;
       
   260 	TInt iControl(0);
       
   261 	TInt reterr = centrep->Get( centrepKey, iControl );	
       
   262 	if(reterr!= KErrNone)
       
   263 	{
       
   264 			RDEBUG("CDCMOServer::GetLocalCategoryL(): centrep Get error");
       
   265 			delete centrep;
       
   266 			centrep = NULL;
       
   267 	    return ret;
       
   268 	}
       
   269 	RDEBUG_2("CDCMOServer::GetLocalCategoryL local plug-in =  %d", iControl );
       
   270 	TBuf<30> buffer;
       
   271 	for(TInt i=0; i<iControl; i++)
       
   272 	{   
       
   273         centrepKey = KDCMOKeyMaxNumber*i + KDCMOPropertyNumber ;
       
   274         reterr = centrep->Get( centrepKey, buffer );
       
   275 	    	if(aCategory.Find(buffer)== KErrNone)
       
   276         {
       
   277         	ret = centrepKey-1;
       
   278         	break;
       
   279         }
       
   280 	}
       
   281 	delete centrep;
       
   282 	centrep = NULL;
       
   283 	RDEBUG("CDCMOServer::GetLocalCategoryL(): end");
       
   284 	return ret;
       
   285 }
       
   286 // ----------------------------------------------------------------------------------------
       
   287 // CDCMOServer::GetIntAttributeL
       
   288 // Gets the integer attribute value.
       
   289 // ----------------------------------------------------------------------------------------
       
   290 TDCMOStatus CDCMOServer::GetIntAttributeL(TDes& category, TDCMONode id, TInt& value)
       
   291 {
       
   292 	RDEBUG("CDCMOServer::GetIntAttributeL(): begin");
       
   293 	TDCMOStatus err(EDcmoFail);
       
   294 	TInt categotyNumber = GetLocalCategoryL(category);
       
   295 	if(categotyNumber != -1)
       
   296 	{
       
   297 			RDEBUG("CDCMOServer::GetIntAttributeL(): LocalCategory");
       
   298 			CDCMOGenericControl* iGenericControl = new(ELeave) CDCMOGenericControl;
       
   299 			err = iGenericControl->GetIntAttributeL(categotyNumber, id, value);
       
   300 			delete iGenericControl;
       
   301 			iGenericControl = NULL;
       
   302 	}
       
   303 	else
       
   304 	{
       
   305 		RDEBUG("CDCMOServer::GetIntAttributeL(): Plug-in Adapter");
       
   306 		TUid impluid = GetAdapterUidL(category);		
       
   307 		if(impluid.iUid)
       
   308 		{
       
   309 			CDCMOInterface::TDCMOInterfaceInitParams initParms;
       
   310 			initParms.uid = impluid;
       
   311 			initParms.descriptor = &category;
       
   312 			CDCMOInterface* ex = CDCMOInterface::NewL(initParms); //impluid);
       
   313 			CleanupStack::PushL(ex);
       
   314 			err = ex->GetDCMOPluginIntAttributeValueL(id,value);
       
   315 			CleanupStack::PopAndDestroy(); //ex 	
       
   316 		}
       
   317 	}
       
   318 	RDEBUG("CDCMOServer::GetIntAttributeL(): end");
       
   319 	return err;
       
   320 }
       
   321 // ----------------------------------------------------------------------------------------
       
   322 // CDCMOServer::GetStrAttributeL
       
   323 // Gets the string attribute value.
       
   324 // ----------------------------------------------------------------------------------------
       
   325 TDCMOStatus CDCMOServer::GetStrAttributeL(TDes& category, TDCMONode id, TDes& strValue) 
       
   326 {
       
   327 	RDEBUG("CDCMOServer::GetStrAttributeL(): begin");
       
   328 	TDCMOStatus err(EDcmoFail);
       
   329 	TInt categotyNumber = GetLocalCategoryL(category);
       
   330 	if(categotyNumber != -1)
       
   331 	{
       
   332 			RDEBUG("CDCMOServer::GetStrAttributeL(): LocalCategory");
       
   333 			CDCMOGenericControl* iGenericControl = new(ELeave) CDCMOGenericControl;
       
   334 			err = iGenericControl->GetStrAttributeL(categotyNumber, id, strValue);	
       
   335 			delete iGenericControl;
       
   336 			iGenericControl = NULL;
       
   337 	}
       
   338 	else
       
   339 	{
       
   340 		RDEBUG("CDCMOServer::GetStrAttributeL(): Plug-in Adapter");
       
   341 		TUid impluid = GetAdapterUidL(category);
       
   342 		if(impluid.iUid)
       
   343 		{
       
   344 			CDCMOInterface::TDCMOInterfaceInitParams initParms;
       
   345 		  initParms.uid = impluid;
       
   346 		  initParms.descriptor = &category;
       
   347 		  CDCMOInterface* ex = CDCMOInterface::NewL(initParms);			
       
   348 			CleanupStack::PushL(ex);
       
   349 			err = ex->GetDCMOPluginStrAttributeValueL(id,strValue); 
       
   350 			CleanupStack::PopAndDestroy(); //ex
       
   351 		}
       
   352 	}
       
   353 	RDEBUG("CDCMOServer::GetStrAttributeL(): end");
       
   354 	return err;
       
   355 }
       
   356 // ----------------------------------------------------------------------------------------
       
   357 // CDCMOServer::SetIntAttributeL
       
   358 // Sets the integer attribute value.
       
   359 // ----------------------------------------------------------------------------------------
       
   360 TDCMOStatus CDCMOServer::SetIntAttributeL(TDes& category, TDCMONode id, TInt value)
       
   361 {
       
   362 	RDEBUG("CDCMOServer::SetIntAttributeL(): begin");
       
   363 	TDCMOStatus err(EDcmoFail);
       
   364 	HBufC* stringHolder( NULL );
       
   365 	TInt categotyNumber = GetLocalCategoryL(category);
       
   366 	struct dcmoInfoList dcmoList;
       
   367 	if(categotyNumber != -1)
       
   368 	{
       
   369 			RDEBUG("CDCMOServer::SetIntAttributeL(): LocalCategory");
       
   370 			CDCMOGenericControl* iGenericControl = new(ELeave) CDCMOGenericControl;
       
   371 			err = iGenericControl->SetIntAttributeL(categotyNumber, id, value);	
       
   372 			TFileName myFileName;
       
   373   		TParse parseObj;
       
   374   		parseObj.Set( KdcmoResourceFileName(), &KDC_RESOURCE_FILES_DIR,NULL );
       
   375  			myFileName = parseObj.FullName();
       
   376  			CStringResourceReader* test = CStringResourceReader::NewL( myFileName );
       
   377 			TPtrC buf;
       
   378 			dcmoList.iUid = categotyNumber;
       
   379 			if(categotyNumber == 0)
       
   380 			    {			    
       
   381 			    buf.Set(test->ReadResourceString(R_DM_RUN_TIME_VAR_CAMERA));
       
   382 			    stringHolder = buf.AllocL() ; 
       
   383 			    } 
       
   384 			else
       
   385 			    {			   
       
   386 			    buf.Set(test->ReadResourceString(R_DM_RUN_TIME_VAR_FIRMWARE_UPDATE));
       
   387 			    stringHolder = buf.AllocL() ; 
       
   388 			    }			
       
   389      delete test;
       
   390      test = NULL;
       
   391   	 delete iGenericControl;
       
   392 		 iGenericControl = NULL;
       
   393 	}
       
   394 	else
       
   395 	{
       
   396 		RDEBUG("CDCMOServer::SetIntAttributeL(): Plug-in Adapter");
       
   397 		TUid impluid = GetAdapterUidL(category);
       
   398 		dcmoList.iUid = impluid.iUid;
       
   399 		if(impluid.iUid)
       
   400 		{
       
   401 			CDCMOInterface::TDCMOInterfaceInitParams initParms;
       
   402 		  initParms.uid = impluid;
       
   403 		  initParms.descriptor = &category;
       
   404 		  CDCMOInterface* ex = CDCMOInterface::NewL(initParms); 
       
   405 			CleanupStack::PushL(ex);
       
   406 			err = ex->SetDCMOPluginIntAttributeValueL(id,value);	
       
   407 			RDEBUG("CDCMOServer::SetIntAttributeL - SetDCMOPluginIntAttributeValueL(): end");				
       
   408 			ex->GetLocalizedNameL(stringHolder);
       
   409 			RDEBUG("CDCMOServer::SetIntAttributeL - GetLocalizedNameL(): end");				
       
   410 			CleanupStack::PopAndDestroy(); //ex 	
       
   411 
       
   412 		}
       
   413 	}
       
   414 	if ( iStarter )   			
       
   415    {
       
   416   		RDEBUG("CDCMOServer::SetIntAttributeL(): Starter");
       
   417   		SetStarter ( EFalse );
       
   418   		delete stringHolder;
       
   419 		stringHolder = NULL;
       
   420   		return err;                
       
   421    }   
       
   422 	if((err == EDcmoSuccess) && (id == EEnable) ) 
       
   423 	{
       
   424 		TInt arrayCount = idcmoArray.Count();
       
   425 		RDEBUG_2("CDCMOServer::SetIntAttributeL arrayCount = %d", arrayCount );
       
   426 		TBool insert = EFalse; 		
       
   427 		if( arrayCount > 0)
       
   428 		{
       
   429 			for(TInt i = 0; i< arrayCount ; i++)
       
   430 			{       	
       
   431       	if (idcmoArray[i].iUid == dcmoList.iUid)
       
   432       	{
       
   433       		idcmoArray[i].iStatus = (TBool) value;	
       
   434       		insert = ETrue;
       
   435       		break;
       
   436       	}
       
   437       }
       
   438     }
       
   439 		if ( !insert )
       
   440 		{
       
   441 			dcmoList.iCategoryName = stringHolder->AllocL();
       
   442 			dcmoList.iStatus = (TBool) value;		
       
   443 			idcmoArray.AppendL(dcmoList);
       
   444 			RDEBUG("CDCMOServer::SetIntAttributeL - dcmoList added ");		
       
   445 		}
       
   446 	}
       
   447 	delete stringHolder;
       
   448 	stringHolder = NULL;
       
   449 	RDEBUG("CDCMOServer::SetIntAttributeL(): end");
       
   450 	return err;
       
   451 }
       
   452 // ----------------------------------------------------------------------------------------
       
   453 // CDCMOServer::SetStrAttributeL
       
   454 // Sets the string attribute value.
       
   455 // ----------------------------------------------------------------------------------------
       
   456 TDCMOStatus CDCMOServer::SetStrAttributeL(TDes& category, TDCMONode id, const TDes& strValue)
       
   457 {
       
   458 	RDEBUG("CDCMOServer::SetStrAttributeL(): begin");
       
   459 	TUid impluid = GetAdapterUidL(category);
       
   460 	TDCMOStatus err(EDcmoFail);
       
   461 	if(impluid.iUid)
       
   462 	{
       
   463 		CDCMOInterface* ex = CDCMOInterface::NewL(impluid);
       
   464 		CleanupStack::PushL(ex);
       
   465 		err = ex->SetDCMOPluginStrAttributeValueL(id,strValue);
       
   466 		CleanupStack::PopAndDestroy(); //ex 
       
   467 	}
       
   468 	RDEBUG("CDCMOServer::SetStrAttributeL(): end");	
       
   469 	return err;
       
   470 }
       
   471 // ----------------------------------------------------------------------------------------
       
   472 // CDCMOServer::DoFinalizeL()
       
   473 // Calls when all the operations are done. Shows the notification
       
   474 // ----------------------------------------------------------------------------------------
       
   475 void CDCMOServer::DoFinalizeL()
       
   476 {
       
   477 	RDEBUG("CDCMOServer::DoFinalizeL(): begin");	   
       
   478 
       
   479 	HBufC* content  = HBufC::NewLC(KDCMOMaxStringSize);
       
   480   	TPtr   contentptr  = content->Des(); 
       
   481 	HBufC* enableContent  = HBufC::NewLC(KDCMOMaxStringSize);
       
   482 	TPtr   enableContentptr  = enableContent->Des(); 
       
   483 	HBufC* disableContent  = HBufC::NewLC(KDCMOMaxStringSize);
       
   484 	TPtr   disableContentptr  = disableContent->Des(); 
       
   485 
       
   486 	TBool enable ( EFalse );
       
   487 	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(); 
       
   493 	_LIT(KNewLine, "\n");
       
   494 		
       
   495 	if( arrayCount > 0)
       
   496 	{
       
   497 		RDEBUG_2("CDCMOServer::DoFinalizeL arrayCount= %d", arrayCount );
       
   498 		for(TInt i = 0; i< arrayCount ; i++)
       
   499 		{       	
       
   500       	if (idcmoArray[i].iStatus )
       
   501       	{
       
   502       		enableContentptr.Append(KNewLine());
       
   503       		enableContentptr.Append( idcmoArray[i].iCategoryName->Des() );
       
   504       		enable = ETrue;
       
   505       	}
       
   506       	else
       
   507       	{
       
   508       		disableContentptr.Append(KNewLine());
       
   509       		disableContentptr.Append( idcmoArray[i].iCategoryName->Des() );
       
   510       		disable = ETrue;
       
   511       	}	
       
   512 		}
       
   513 	  
       
   514   	CStringResourceReader* test = CStringResourceReader::NewL( myFileName );	  
       
   515 		if ( enable )
       
   516 		{
       
   517 			TPtrC buf;
       
   518 			buf.Set(test->ReadResourceString(R_DM_RUN_TIME_VAR_ENABLE)); 	    	
       
   519 			contentptr.Append(buf);
       
   520 	 		contentptr.Append(enableContentptr);
       
   521 		}
       
   522 		if ( disable )
       
   523 		{
       
   524 	 		TPtrC buf;
       
   525 	 		buf.Set(test->ReadResourceString(R_DM_RUN_TIME_VAR_DISABLE));
       
   526 	 		if( enable )
       
   527 	 			contentptr.Append(KNewLine());
       
   528 	 		contentptr.Append(buf);
       
   529 	 		contentptr.Append(disableContentptr);
       
   530 		}
       
   531 		delete test;
       
   532 		test = NULL;
       
   533 		
       
   534 		if( iNotifier )
       
   535 		{
       
   536 			iNotifier->Cancel();
       
   537 		}
       
   538 		else
       
   539 		{			
       
   540 			iNotifier = CDCMONotifierAob::NewL( );			
       
   541 		}
       
   542 		
       
   543 	  iNotifier->ShowNotifierL(contentptr);    
       
   544 	  CleanupStack::PopAndDestroy(3); //disableContent, enableContent, content
       
   545 	}	
       
   546 	RDEBUG("CDCMOServer::DoFinalizeL(): end");
       
   547 }
       
   548 // ----------------------------------------------------------------------------------------
       
   549 // CDCMOServer::SearchAdaptersL
       
   550 // Gets all the plug-in adapter names
       
   551 // ----------------------------------------------------------------------------------------
       
   552 void CDCMOServer::SearchAdaptersL(TDes& /* category */, TDes& aAdapterList)
       
   553 {
       
   554 	RDEBUG("CDCMOServer::SearchAdaptersL(): begin");
       
   555 	
       
   556 	CRepository* centrep = NULL;
       
   557 	TInt err(KErrNone);
       
   558 	TInt count(0);
       
   559 	TBool flag(EFalse);
       
   560 	TRAP(err, centrep = CRepository::NewL( KCRUidDCMOServer ));
       
   561 	if(err == KErrNone)
       
   562 	{
       
   563       TUint32 centrepKey = 0;	    
       
   564 	    TInt reterr = centrep->Get( centrepKey, count );  
       
   565 	    RDEBUG_2("CDCMOServer::SearchAdaptersL count= %d", count );  
       
   566 	    if(reterr == KErrNone)
       
   567 	    {       
       
   568           TBuf<KBufferSize> buffer;
       
   569 	        for(TInt i=0; i<count; i++)
       
   570 	        {   
       
   571               centrepKey = KDCMOKeyMaxNumber*i + KDCMOPropertyNumber ;
       
   572 	            reterr = centrep->Get( centrepKey, buffer );
       
   573 	            if( reterr== KErrNone )
       
   574 	            {   
       
   575                     if((count > 1) && flag)
       
   576                         aAdapterList.Append(_L(", ")); 
       
   577                     aAdapterList.Append(buffer); 
       
   578                     buffer.Zero(); 
       
   579                     flag = ETrue;
       
   580 	            }
       
   581 	        }
       
   582 	    } 
       
   583 	}
       
   584 	delete centrep;
       
   585 	centrep = NULL;
       
   586 	
       
   587 	RImplInfoPtrArray infoArray;
       
   588 	// Note that a special cleanup function is required to reset and destroy
       
   589 	// all items in the array, and then close it.
       
   590 	TCleanupItem cleanup(CleanupEComArray, &infoArray);
       
   591 	CleanupStack::PushL(cleanup);
       
   592 	REComSession::ListImplementationsL(KDCMOInterfaceUid, infoArray);
       
   593 
       
   594 	// Loop through each info for each implementation			
       
   595 	TBuf<KBufferSize> buf;   
       
   596 	count =  infoArray.Count();
       
   597 	RDEBUG_2("CDCMOServer::SearchAdaptersL plug-in count= %d", count );          
       
   598 	for (TInt i=0; i< count; i++)
       
   599 	{
       
   600 		if(( i != 0) || flag )
       
   601 			aAdapterList.Append(_L(", "));		
       
   602 		buf.Copy(infoArray[i]->OpaqueData());	
       
   603 		aAdapterList.Append(buf);
       
   604 		buf.Zero();		
       
   605 	}
       
   606 	CleanupStack::PopAndDestroy(); //cleanup
       
   607 	
       
   608 	RDEBUG("CDCMOServer::SearchAdaptersL(): end");	
       
   609 }
       
   610 
       
   611 // ----------------------------------------------------------------------------------------
       
   612 // CDCMOServer::SetStarter
       
   613 // Sets the iStarter value
       
   614 // ----------------------------------------------------------------------------------------
       
   615 void CDCMOServer::SetStarter(TBool aValue)
       
   616 {
       
   617 	RDEBUG("CDCMOServer::SetStarter(): begin");
       
   618 	iStarter = aValue;
       
   619 	RDEBUG("CDCMOServer::SetStarter(): end");
       
   620 }