contentmgmt/referencedrmagent/tcaf/source/cafserver.cpp
changeset 15 da2ae96f639b
child 19 cd501b96611d
equal deleted inserted replaced
10:afc583cfa176 15:da2ae96f639b
       
     1 /*
       
     2 * Copyright (c) 2002-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 * Example file/test code to demonstrate how to develop a TestExecute Server
       
    16 * Developers should take this project as a template and substitute their own
       
    17 * code at the __EDIT_ME__ tags
       
    18 * for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to be started
       
    19 * in the process of the client. The client initialises the server by calling the
       
    20 * one and only ordinal.
       
    21 *
       
    22 */
       
    23 
       
    24 
       
    25 #include "cafserver.h"
       
    26 #include "cafstep.h"
       
    27 #include "bitsetstep.h"
       
    28 #include "Consumerstep.h"
       
    29 #include "contentstep.h"
       
    30 #include "RecognizerStep.h"
       
    31 #include "ManagerStep.h"
       
    32 #include "RightsManagerStep.h"
       
    33 #include "SupplierStep.h"
       
    34 #include "oomstep.h"
       
    35 #include "CafUtilsStep.h"
       
    36 #include "CleanupStep.h"
       
    37 
       
    38 
       
    39 CCAFServer* CCAFServer::NewL()
       
    40 	{
       
    41 	CCAFServer * server = new (ELeave) CCAFServer();
       
    42 	CleanupStack::PushL(server);
       
    43 	User::LeaveIfError(server->iFs.Connect());
       
    44 
       
    45 	// Make the file session sharable
       
    46 	User::LeaveIfError(server->iFs.ShareProtected());
       
    47 
       
    48 	// CServer base class call	
       
    49 	RProcess handle = RProcess();
       
    50 	TParsePtrC serverName(handle.FileName());
       
    51 	server->StartL(serverName.Name());
       
    52 
       
    53 	CleanupStack::Pop(server);
       
    54 	return server;
       
    55 	}
       
    56 
       
    57 // EKA2 much simpler
       
    58 // Just an E32Main and a MainL()
       
    59 LOCAL_C void MainL()
       
    60 /*
       
    61  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    62  */
       
    63 	{
       
    64 	// Leave the hooks in for platform security
       
    65 #if (defined __DATA_CAGING__)
       
    66 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    67 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    68 #endif
       
    69 	CActiveScheduler* sched=NULL;
       
    70 	sched=new(ELeave) CActiveScheduler;
       
    71 	CActiveScheduler::Install(sched);
       
    72 	// __EDIT_ME__ Your server name
       
    73 	CCAFServer* server = NULL;
       
    74 	// Create the CTestServer derived server
       
    75 	// __EDIT_ME__ Your server name
       
    76 	TRAPD(err,server = CCAFServer::NewL());
       
    77 	if(!err)
       
    78 		{
       
    79 		// Sync with the client and enter the active scheduler
       
    80 		RProcess::Rendezvous(KErrNone);
       
    81 		sched->Start();
       
    82 		}
       
    83 	delete server;
       
    84 	delete sched;
       
    85 	}
       
    86 
       
    87 GLDEF_C TInt E32Main()
       
    88 /*
       
    89  * return standard error code on exit
       
    90  */
       
    91 	{
       
    92 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    93 	if(cleanup == NULL)
       
    94 		{
       
    95 		return KErrNoMemory;
       
    96 		}
       
    97 	TRAP_IGNORE(MainL());
       
    98 	delete cleanup;
       
    99 	return KErrNone;
       
   100     }
       
   101 
       
   102 // Create a thread in the calling process
       
   103 // Emulator typhoon and earlier
       
   104 
       
   105 CTestStep* CCAFServer::CreateTestStep(const TDesC& aStepName)
       
   106 /*
       
   107  * return a CTestStep derived instance
       
   108  * Implementation of CTestServer pure virtual
       
   109  */
       
   110 	{
       
   111 	CTestStep* testStep = NULL;
       
   112 	// They are created "just in time" when the worker thread is created
       
   113 	if(aStepName == KCAFSizeStep)
       
   114 		testStep = new CCAFSizeStep(*this);
       
   115 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   116 	else if(aStepName == KCAFSizeStep64)
       
   117 		testStep = new CCAFSizeStep64(*this);
       
   118 	else if(aStepName == KCAFSeekReadStep64)
       
   119 		testStep = new CCAFSeekReadStep64(*this);
       
   120 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   121 	else if(aStepName == KCAFSeekReadStep)
       
   122 		testStep = new CCAFSeekReadStep(*this);
       
   123 	else if(aStepName == KBasicBitsetStep)
       
   124 		testStep = new CBasicBitsetStep();
       
   125 	else if(aStepName == KBitsetListStep)
       
   126 		testStep = new CBitsetListStep();
       
   127 	else if(aStepName == KBitsetEqualityStep)
       
   128 		testStep = new CBitsetEqualityStep();
       
   129 	else if(aStepName == KBitsetCopyStep)
       
   130 		testStep = new CBitsetCopyStep();
       
   131 	else if(aStepName == KBitsetSerialiseStep)
       
   132 		testStep = new CBitsetSerialiseStep();
       
   133 	else if(aStepName == KBitsetPanicStep)
       
   134 		testStep = new CBitsetPanicStep();
       
   135 	else if(aStepName == KCAFMultiThreadCDataStep)
       
   136 		testStep = new CCAFMultiThreadCDataStep(*this);
       
   137 	else if(aStepName == KCAFShareModeStep)
       
   138 		testStep = new CCAFShareModeStep(*this);
       
   139 	else if(aStepName == KCAFMimeTypeCDataStep)
       
   140 		testStep = new CCAFMimeTypeCDataStep(*this);
       
   141 	else if(aStepName == KCAFRecognizeStep)
       
   142 		testStep = new CCAFRecognizeStep(*this);
       
   143 	else if(aStepName == KCAFRecognizerSpeedStep)
       
   144 		testStep = new CCAFRecognizerSpeedStep(*this);
       
   145 	else if(aStepName == KCAFBufferSizeStep)
       
   146 		testStep = new CCAFBufferSizeStep(*this);
       
   147 	else if(aStepName == KCAFDeleteStep)
       
   148 		testStep = new CCAFDeleteStep(*this);
       
   149 	else if(aStepName == KCAFCopyFileStep)
       
   150 		testStep = new CCAFCopyFileStep(*this);
       
   151 	else if(aStepName == KCAFRenameFileStep)
       
   152 		testStep = new CCAFRenameFileStep(*this);
       
   153 	else if(aStepName == KCAFMkDirStep)
       
   154 		testStep = new CCAFMkDirStep(*this);
       
   155 	else if(aStepName == KCAFMkDirAllStep)
       
   156 		testStep = new CCAFMkDirAllStep(*this);
       
   157 	else if(aStepName == KCAFRmDirStep)
       
   158 		testStep = new CCAFRmDirStep(*this);
       
   159 	else if(aStepName == KCAFGetDirStep)
       
   160 		testStep = new CCAFGetDirStep(*this);
       
   161 	else if(aStepName == KCAFManagerNotifyStep)
       
   162 		testStep = new CCAFManagerNotifyStep(*this);
       
   163 	else if(aStepName == KCAFManagerSetPropertyStep)
       
   164 		testStep = new CCAFManagerSetPropertyStep(*this);
       
   165 	else if(aStepName == KCAFManagerDisplayInfoStep)
       
   166 		testStep = new CCAFManagerDisplayInfoStep(*this);
       
   167 	else if(aStepName == KCAFManagerListAgentsStep)
       
   168 		testStep = new CCAFManagerListAgentsStep(*this);
       
   169 	else if(aStepName == KCAFManagerAgentSpecificStep)
       
   170 		testStep = new CCAFManagerAgentSpecificStep(*this);
       
   171 	else if(aStepName == KCAFManagerDisplayConfigStep)
       
   172 		testStep = new CCAFManagerDisplayConfigStep(*this);
       
   173 	else if(aStepName == KCAFManagerAttributeStep)
       
   174 		testStep = new CCAFManagerAttributeStep(*this);
       
   175 	else if(aStepName == KCAFManagerAttributeSetStep)
       
   176 		testStep = new CCAFManagerAttributeSetStep(*this);
       
   177 	else if(aStepName == KCAFManagerStringAttributeStep)
       
   178 		testStep = new CCAFManagerStringAttributeStep(*this);
       
   179 	else if(aStepName == KCAFManagerStringAttributeSetStep)
       
   180 		testStep = new CCAFManagerStringAttributeSetStep(*this);
       
   181 	else if(aStepName == KCAFRightsManagerStep)
       
   182 		testStep = new CCAFRightsManagerStep(*this);
       
   183 	else if(aStepName == KCAFRightsManagerListStep)
       
   184 		testStep = new CCAFRightsManagerListStep(*this);
       
   185 	else if(aStepName == KCAFAttributesStep)
       
   186 		testStep = new CCAFAttributesStep(*this);
       
   187 	else if(aStepName == KCAFStringAttributesStep)
       
   188 		testStep = new CCAFStringAttributesStep(*this);
       
   189 	else if(aStepName == KCAFApparcStep)
       
   190 		testStep = new CCAFApparcStep(*this);
       
   191 	else if(aStepName == KCAFSupplierStep)
       
   192 		testStep = new CCafSupplierStep(*this);
       
   193 	else if(aStepName == KCAFSupplierAsyncStep)
       
   194 		testStep = new CCafSupplierAsyncStep(*this);
       
   195 	else if(aStepName == KCAFClientOutputSupplierStep)
       
   196 		testStep = new CCafClientOutputSupplierStep(*this);
       
   197 	else if(aStepName == KCAFSupplierSerializeStep)
       
   198 		testStep = new CCAFSupplierSerializeStep(*this);
       
   199 	else if(aStepName == KCAFContentAttributeStep)
       
   200 		testStep = new CCAFContentAttributeStep(*this);
       
   201 	else if(aStepName == KCAFContentAttributeSetStep)
       
   202 		testStep = new CCAFContentAttributeSetStep(*this);
       
   203 	else if(aStepName == KCAFContentStringAttributeStep)
       
   204 		testStep = new CCAFContentStringAttributeStep(*this);
       
   205 	else if(aStepName == KCAFContentStringAttributeSetStep)
       
   206 		testStep = new CCAFContentStringAttributeSetStep(*this);	
       
   207 	else if(aStepName == KCAFContentNotifyStep)
       
   208 		testStep = new CCAFContentNotifyStep(*this);	
       
   209 	else if(aStepName == KCAFContentSetPropertyStep)
       
   210 		testStep = new CCAFContentSetPropertyStep(*this);	
       
   211 	else if(aStepName == KCAFContentDisplayInfoStep)
       
   212 		testStep = new CCAFContentDisplayInfoStep(*this);	
       
   213 	else if(aStepName == KCAFContentAgentSpecificStep)
       
   214 		testStep = new CCAFContentAgentSpecificStep(*this);	
       
   215 	else if(aStepName == KCAFContentRequestRightsStep)
       
   216 		testStep = new CCAFContentRequestRightsStep(*this);	
       
   217 	else if(aStepName == KCAFContentEmbeddedObjectsStep)
       
   218 		testStep = new CCAFContentEmbeddedObjectsStep(*this);	
       
   219 	else if(aStepName == KCAFContentEmbeddedObjectTypeStep)
       
   220 		testStep = new CCAFContentEmbeddedObjectTypeStep(*this);	
       
   221 	else if(aStepName == KCAFContentSearchStep)
       
   222 		testStep = new CCAFContentSearchStep(*this);	
       
   223 	else if(aStepName == KCAFContentContainerStep)
       
   224 		testStep = new CCAFContentContainerStep(*this);	
       
   225 	else if(aStepName == KCAFDataAttributeStep)
       
   226 		testStep = new CCAFDataAttributeStep(*this);
       
   227 	else if(aStepName == KCAFDataAttributeSetStep)
       
   228 		testStep = new CCAFDataAttributeSetStep(*this);
       
   229 	else if(aStepName == KCAFDataStringAttributeStep)
       
   230 		testStep = new CCAFDataStringAttributeStep(*this);
       
   231 	else if(aStepName == KCAFDataStringAttributeSetStep)
       
   232 		testStep = new CCAFDataStringAttributeSetStep(*this);	
       
   233 	else if(aStepName == KCAFOomStep)
       
   234 		testStep = new CCafOomStep(*this);
       
   235 	else if(aStepName == KCAFHandleSizeStep)
       
   236 		testStep = new CCAFHandleSizeStep(*this);
       
   237 	else if(aStepName == KCAFHandleSeekReadStep)
       
   238 		testStep = new CCAFHandleSeekReadStep(*this);
       
   239 	else if(aStepName == KCAFHandleMultiThreadCDataStep)
       
   240 		testStep = new CCAFHandleMultiThreadCDataStep(*this);	
       
   241 	else if(aStepName == KCAFContentIteratorStep)
       
   242 		testStep = new CCAFContentIteratorStep(*this);	
       
   243 	else if(aStepName == KCAFCDirStreamStep)
       
   244 		testStep = new CCafCDirStreamStep(*this);	
       
   245 	else if(aStepName == KCAFRAttributeSetStreamStep)
       
   246 		testStep = new CCafRAttributeSetStreamStep(*this);	
       
   247 	else if(aStepName == KCAFRStringAttributeSetStreamStep)
       
   248 		testStep = new CCafRStringAttributeSetStreamStep(*this);	
       
   249 	else if(aStepName == KCAFSupplierOutputFileStreamStep)
       
   250 		testStep = new CCafSupplierOutputFileStreamStep(*this);	
       
   251 	else if(aStepName == KCAFMetaDataArrayStep)
       
   252 		testStep = new CCafMetaDataArrayStep(*this);	
       
   253 	else if(aStepName == KCAFEmbeddedObjectStep)
       
   254 		testStep = new CCafEmbeddedObjectStep(*this);	
       
   255 	else if(aStepName == KCAFVirtualPathStep)
       
   256 		testStep = new CCafVirtualPathStep(*this);	
       
   257 	else if(aStepName == KCAFRightsInfoStep)
       
   258 		testStep = new CCafRightsInfoStep(*this);	
       
   259 	else if(aStepName == KCAFStreamablePtrArrayStep)
       
   260 		testStep = new CCafStreamablePtrArrayStep(*this);
       
   261 #ifndef SYMBIAN_DISABLE_UPWARD_DEPENDENCY
       
   262 	else if(aStepName == KCAFHTTPRequestHeadersStep)
       
   263 		testStep = new CCAFHTTPRequestHeadersStep(*this);
       
   264 #endif
       
   265 	else if(aStepName == KCAFExecuteIntentStep)
       
   266 		testStep = new CCAFExecuteIntentStep(*this);			
       
   267 	else if(aStepName == KCAF_DEF077443_Step)
       
   268 		testStep = new CCAF_DEF077443_Step(*this);
       
   269 	else if(aStepName == KCAFTestCleanupStep)
       
   270 		testStep = new CCAFTestCleanupStep(*this);
       
   271 	else if(aStepName == KCAFDRMFileOpenPerformanceStep)
       
   272 		testStep = new CCAFDRMFileOpenPerformanceTest(*this);
       
   273 	else if(aStepName == KCAFManagerDisplayInfoByFileHandleStep)
       
   274 		testStep = new CCAFManagerDisplayInfoByFileHandleStep(*this);
       
   275 	else if(aStepName == KCAFManagerAttributeByFileHandleStep)
       
   276 		testStep = new CCAFManagerAttributeByFileHandleStep(*this);
       
   277 	else if(aStepName == KCAFManagerAttributeSetByFileHandleStep)
       
   278 		testStep = new CCAFManagerAttributeSetByFileHandleStep(*this);
       
   279 	else if(aStepName == KCAFManagerStringAttributeByFileHandleStep)
       
   280 		testStep = new CCAFManagerStringAttributeByFileHandleStep(*this);
       
   281 	else if(aStepName == KCAFManagerStringAttributeSetByFileHandleStep)
       
   282 		testStep = new CCAFManagerStringAttributeSetByFileHandleStep(*this);
       
   283 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
       
   284     else if(aStepName == KCAFHelperStep)     
       
   285         testStep = new CCafHelperStep();     
       
   286     else if(aStepName == KWmdrmCAFContentStep)     
       
   287         testStep = new CWmdrmCAFContentStep();     
       
   288     else if(aStepName == KWmdrmCAFDataStep)     
       
   289         testStep = new CWmdrmCAFDataStep();     
       
   290     else if(aStepName == KWmdrmCAFReadStep)     
       
   291         testStep = new CWmdrmCAFReadStep();     
       
   292 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT 
       
   293 	
       
   294 	return testStep;
       
   295 	}
       
   296