installationservices/swi/test/tuiscriptadaptors/tswisserver.cpp
changeset 0 ba25891c3a9e
child 19 7ca52d38f8c3
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2004-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 the License "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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <c32comm.h>
       
    21 
       
    22 #if defined (__WINS__)
       
    23 #define PDD_NAME		_L("ECDRV")
       
    24 #else
       
    25 #define PDD_NAME		_L("EUART1")
       
    26 #define PDD2_NAME		_L("EUART2")
       
    27 #define PDD3_NAME		_L("EUART3")
       
    28 #define PDD4_NAME		_L("EUART4")
       
    29 #endif
       
    30 
       
    31 #define LDD_NAME		_L("ECOMM")
       
    32 
       
    33 /**
       
    34  * @file
       
    35  *
       
    36  * SWIS test server implementation
       
    37  */
       
    38 
       
    39 #include "tswisserver.h"
       
    40 #include "tswisstep.h"
       
    41 #include "tswisasyncstep.h"
       
    42 #include "forceremove.h"
       
    43 #include "filldrive.h"
       
    44 #include "runningappsteps.h"
       
    45 #include "swifileutilitysteps.h"
       
    46 
       
    47 _LIT(KServerName, "tuiscriptadaptors");
       
    48 
       
    49 /**
       
    50  * Called inside the MainL() function to create and start the CTestServer 
       
    51  * derived server.
       
    52  * @return Instance of the test server
       
    53  */
       
    54 CSwisTestServer* CSwisTestServer::NewL()
       
    55 	{
       
    56 	CSwisTestServer *server = new(ELeave) CSwisTestServer();
       
    57 	CleanupStack::PushL(server);
       
    58 	server->ConstructL(KServerName);
       
    59 	CleanupStack::Pop(server);
       
    60 	return server;
       
    61 	}
       
    62 
       
    63 static void InitCommsL()
       
    64     {
       
    65     TInt ret = User::LoadPhysicalDevice(PDD_NAME);
       
    66     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    67 
       
    68 #ifndef __WINS__
       
    69     ret = User::LoadPhysicalDevice(PDD2_NAME);
       
    70     ret = User::LoadPhysicalDevice(PDD3_NAME);
       
    71     ret = User::LoadPhysicalDevice(PDD4_NAME);
       
    72 #endif
       
    73 
       
    74     ret = User::LoadLogicalDevice(LDD_NAME);
       
    75     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    76     ret = StartC32();
       
    77     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    78     }
       
    79 
       
    80 LOCAL_C void MainL()
       
    81 	{
       
    82 	// Leave the hooks in for platform security
       
    83 #if (defined __DATA_CAGING__)
       
    84 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    85 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    86 #endif
       
    87 	InitCommsL();
       
    88 	
       
    89 	CActiveScheduler* sched=NULL;
       
    90 	sched=new(ELeave) CActiveScheduler;
       
    91 	CActiveScheduler::Install(sched);
       
    92 	CSwisTestServer* server = NULL;
       
    93 	// Create the CTestServer derived server
       
    94 	TRAPD(err, server = CSwisTestServer::NewL());
       
    95 	if(!err)
       
    96 		{
       
    97 		// Sync with the client and enter the active scheduler
       
    98 		RProcess::Rendezvous(KErrNone);
       
    99 		sched->Start();
       
   100 		}
       
   101 	delete server;
       
   102 	delete sched;
       
   103 	}
       
   104 
       
   105 /**
       
   106  * Server entry point
       
   107  * @return Standard Epoc error code on exit
       
   108  */
       
   109 GLDEF_C TInt E32Main()
       
   110 	{
       
   111 	__UHEAP_MARK;
       
   112 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   113 	if(cleanup == NULL)
       
   114 		{
       
   115 		return KErrNoMemory;
       
   116 		}
       
   117 	TRAP_IGNORE(MainL());
       
   118 	delete cleanup;
       
   119 	__UHEAP_MARKEND;
       
   120 	return KErrNone;
       
   121 	}
       
   122 
       
   123 /**
       
   124  * Implementation of CTestServer pure virtual
       
   125  * @return A CTestStep derived instance
       
   126  */
       
   127 CTestStep* CSwisTestServer::CreateTestStep(const TDesC& aStepName)
       
   128 	{
       
   129 	CTestStep* testStep = NULL;
       
   130 
       
   131 	// This server creates just one step but create as many as you want
       
   132 	// They are created "just in time" when the worker thread is created
       
   133 	// install steps
       
   134 	if (aStepName == KSwisInstallStep)	// Install with file name
       
   135 		testStep = new CSwisInstallStep(CSwisInstallStep::EUseFileName);
       
   136 	else if (aStepName == KSwisInstallFHStep)	// Install with file handle
       
   137 		testStep = new CSwisInstallStep(CSwisInstallStep::EUseFileHandle);
       
   138 	else if (aStepName == KSwisInstallMemStep)	// Install with CDesDataProvider
       
   139 		testStep = new CSwisInstallStep(CSwisInstallStep::EUseMemory); 
       
   140 		// The EUseMemory Install Step is obsolete (24/02/2005) Substituted by the new Capabilities Tests
       
   141 	else if (aStepName == KSwisInstallCAFStep)	// Install with CCafDataProvider
       
   142 		testStep = new CSwisInstallStep(CSwisInstallStep::EUseCAF);
       
   143 	else if (aStepName == KSwisInstallOpenFileStep)	// Install with previously opened file
       
   144 		testStep = new CSwisInstallStep(CSwisInstallStep::EUseOpenFileName);
       
   145 	else if (aStepName == KSwisCheckedInstallStep) // Install with file name, but don't automatically expect sucess
       
   146 		testStep = new CSwisInstallStep(CSwisInstallStep::ECheckExitValue);
       
   147 	// uninstall steps
       
   148 // Install, Cancel testing	
       
   149 	else if (aStepName == KSwisInstallCancelStep)	// Install with file name
       
   150 		testStep = new CSwisInstallStep(CSwisInstallStep::EUseFileName, ETrue);
       
   151 	else if (aStepName == KSwisInstallFHCancelStep)	// Install with file handle
       
   152 		testStep = new CSwisInstallStep(CSwisInstallStep::EUseFileHandle, ETrue);
       
   153 	else if (aStepName == KSwisInstallMemCancelStep)	// Install with CDesDataProvider
       
   154 		testStep = new CSwisInstallStep(CSwisInstallStep::EUseMemory, ETrue);
       
   155 	else if (aStepName == KSwisInstallCAFCancelStep)	// Install with CCafDataProvider
       
   156 		testStep = new CSwisInstallStep(CSwisInstallStep::EUseCAF, ETrue);
       
   157 // Uninstall
       
   158 	else if (aStepName == KSwisUninstallStep)
       
   159 		testStep = new CSwisUninstallStep(CSwisUninstallStep::EByUid);
       
   160 	else if (aStepName == KSwisUninstallAugStep)
       
   161 		testStep = new CSwisUninstallStep(CSwisUninstallStep::EByPackage);
       
   162 // Uninstall, Cancel testing
       
   163 	else if (aStepName == KSwisUninstallCancelStep)
       
   164 		testStep = new CSwisUninstallStep(CSwisUninstallStep::EByUid, ETrue);
       
   165 	else if (aStepName == KSwisUninstallAugCancelStep)
       
   166 		testStep = new CSwisUninstallStep(CSwisUninstallStep::EByPackage, ETrue);
       
   167 // Async Install/Uninstall	
       
   168 	else if (aStepName == KSwisInstallAsyncStep) 
       
   169 			testStep = new CSwisAsyncInstallStep(CSwisAsyncInstallStep::EUseFileName);
       
   170 	else if (aStepName == KSwisInstallAsyncFHStep) 
       
   171 			testStep = new CSwisAsyncInstallStep(CSwisAsyncInstallStep::EUseFileHandle);
       
   172 	else if (aStepName == KSwisInstallAsyncCAFStep) 
       
   173 			testStep = new CSwisAsyncInstallStep(CSwisAsyncInstallStep::EUseCAF);
       
   174 	else if (aStepName == KSwisInstallAsyncCancelStep) 
       
   175 			testStep = new CSwisAsyncInstallStep(CSwisAsyncInstallStep::EUseFileName, Swi::Test::ECancelTimerFromStart);
       
   176 	else if (aStepName == KSwisInstallAsyncCancelAfterDialogsStep) 
       
   177 			testStep = new CSwisAsyncInstallStep(CSwisAsyncInstallStep::EUseFileName, Swi::Test::ECancelAfterDialog);
       
   178 	else if (aStepName == KSwisUninstallAsyncStep) 
       
   179 			testStep = new CSwisAsyncUninstallStep(CSwisAsyncUninstallStep::EByUid);
       
   180 	else if (aStepName == KSwisUninstallAsyncCancelStep) 
       
   181 			testStep = new CSwisAsyncUninstallStep(CSwisAsyncUninstallStep::EByUid, Swi::Test::ECancelTimerFromStart);
       
   182 	else if (aStepName == KSwisUninstallAsyncCancelAfterDialogsStep) 
       
   183 			testStep = new CSwisAsyncUninstallStep(CSwisAsyncUninstallStep::EByUid, Swi::Test::ECancelAfterDialog);
       
   184     else if (aStepName == KTrustStatus)
       
   185 	    	testStep = new CTrustStatusStep();
       
   186     else if (aStepName == KPirCheck)
       
   187 		    testStep = new CPostInstallRevocationCheckStep();
       
   188 // Support step for ROM stub PU testing
       
   189 	else if (aStepName == KSwisForceRemove)
       
   190 			testStep = new CForceRemove();
       
   191 // Support step to fill drive for tests of insufficient space
       
   192 	else if (aStepName == KSwisFillDrive)
       
   193 			testStep = new CFillDrive();
       
   194 // Support step to shut down app left running by testrun step
       
   195 	else if (aStepName == KSwisShutdownApp)
       
   196 			testStep = new CShutdownApp();
       
   197 // Support step to check if process is running
       
   198 	else if (aStepName == KSwisFindRunningExe)
       
   199 			testStep = new CFindRunningExe();
       
   200 // Support step for MMC operations
       
   201 	else if (aStepName == KSwisMmcFormatStep)	// MMC operations
       
   202 		testStep = new CSwisMmcStep(CSwisMmcStep::EFormat);
       
   203 	else if (aStepName == KSwisMmcMountStep)	// MMC operations
       
   204 		testStep = new CSwisMmcStep(CSwisMmcStep::EMount);
       
   205 	else if (aStepName == KSwisMmcUnMountStep)	// MMC operations
       
   206 		testStep = new CSwisMmcStep(CSwisMmcStep::EUnMount);
       
   207 	else if (aStepName == KSwisMmcCopyFiles)	// MMC operations
       
   208 		testStep = new CSwisMmcStep(CSwisMmcStep::ECopyFiles);
       
   209 	else if (aStepName == KSwisMmcCheckFiles)	// MMC operations
       
   210 		testStep = new CSwisMmcStep(CSwisMmcStep::ECheckFiles);
       
   211 	else if (aStepName == KSwisMmcResetTags)	// MMC operations
       
   212 		testStep = new CSwisMmcStep(CSwisMmcStep::EResetTags);
       
   213 	else if (aStepName == KSwisMmcDeleteFiles)	// MMC operations
       
   214  		testStep = new CSwisMmcStep(CSwisMmcStep::EDeleteFiles);
       
   215 	else if (aStepName == KSwisMmcGetNumFilesFiles)	// MMC operations
       
   216  		testStep = new CSwisMmcStep(CSwisMmcStep::EGetNumFiles);
       
   217 	else if (aStepName == KAskRegistry)    // Ask the Registry for App	
       
   218 		testStep = new CSwisMmcStep(CSwisMmcStep::EAskReg);
       
   219 	else if (aStepName == KSetClearReadOnly)    // Set or clear read only bit	
       
   220 		testStep = new CSwisMmcStep(CSwisMmcStep::ESetClearReadOnly);
       
   221 	else if (aStepName == KQuerySidViaApparcPlugin)
       
   222 		testStep = new CSwisMmcStep(CSwisMmcStep::EQuerySidViaApparcPlugin);
       
   223 	else if (aStepName == KEnsureSwisNotRunningStep)
       
   224 		testStep = new CEnsureSwisNotRunning;
       
   225 	else if (aStepName == KSwiCopyFilesStep)
       
   226 		testStep = new CSwiCopyFilesStep();
       
   227 	else if (aStepName == KSwiDeleteFilesStep)
       
   228 		testStep = new CSwiDeleteFilesStep();
       
   229 // Support step for removal and listing of uninstalled application
       
   230 	else if (aStepName == KSwisListUninstallPkgsStep)	// Listing Uninstalled Pkgs
       
   231 		testStep = new CSwisUninstallPkgsStep(CSwisUninstallPkgsStep::EListPkgs);
       
   232 	else if (aStepName == KSwisRemoveUninstallPkgsStep)	// Removing Uninstalled apps
       
   233 		testStep = new CSwisUninstallPkgsStep(CSwisUninstallPkgsStep::ERemovePkgs);
       
   234 	else if (aStepName == KSwisGetPackageDetails)	// Get Package Details
       
   235 		testStep = new CSwisUninstallPkgsStep(CSwisUninstallPkgsStep::EPkgDetails);
       
   236 	#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   237 	else if (aStepName == KCheckSCRFieldStep)	// Check the SCR components' 'Origin Verified', 'Known Revoked', 'DRM Ptotected' field values.
       
   238 		testStep = new CCheckScrFieldStep();
       
   239 	else if (aStepName == KCheckSCRCompPropertyStep)	// Check the SCR component property value.
       
   240 		testStep = new CCheckScrCompPropertyStep();
       
   241 	#endif
       
   242 
       
   243 	return testStep;
       
   244 
       
   245 	}