tzservices/tzserver/test/Integration/src/DstIntServer.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "DstIntServer.h"
       
    17 
       
    18 #include "SetAndCheckLocation.h"
       
    19 #include "ConvertTime.h"
       
    20 #include "ImportVcal.h"
       
    21 #include "Performance.h"
       
    22 #include "DSTUpdate.h"
       
    23 #include "UTCOffset.h"
       
    24 #include "AutoUpdateNotification.h"
       
    25 #include "UTCAlarm.h"
       
    26 #include "IsDaylightSavingOn.h"
       
    27 #include "TestTZServer.h"
       
    28 #include "SetTz.h"
       
    29 #include "SetSysTime.h"
       
    30 #include "ServerMsgSender.h"
       
    31 #include "BackupRestore.h"
       
    32 #include "TimeZoneOffsetCheck.h"
       
    33 #include "NextDSTChange.h"
       
    34 #include "SubscribeNextDSTChange.h"
       
    35 #include "UnknownZoneTime.h"
       
    36 
       
    37 #define UNUSED_VAR(a) a = a
       
    38 
       
    39 // The name of this server 
       
    40 _LIT(KServerName,"DstIntServer");
       
    41 
       
    42 #ifdef __WINS__
       
    43 _LIT(KConsoleAlarmAlertServerImg,"ConsoleAlarmAlertServer");
       
    44 const TUid KServerUid2={0x1000008D};
       
    45 const TUid KServerUid3={0x101F502A};
       
    46 const TUidType serverUid(KNullUid,KServerUid2,KServerUid3);
       
    47 #endif
       
    48 
       
    49 
       
    50 CDstIntServer* CDstIntServer::NewL()
       
    51 /**
       
    52  * @return - Instance of the test server
       
    53  * Called inside the MainL() function to create and start the
       
    54  * CTestServer derived server.
       
    55  */
       
    56 	{
       
    57 	CDstIntServer * server = new (ELeave) CDstIntServer();
       
    58 	CleanupStack::PushL(server);
       
    59 	
       
    60 	// Either use a StartL or ConstructL, the latter will permit
       
    61 	// Server Logging.
       
    62 
       
    63 	//server->StartL(KServerName); 
       
    64 	server-> ConstructL(KServerName);
       
    65 	CleanupStack::Pop(server);
       
    66 	return server;
       
    67 	}
       
    68 
       
    69 // EKA2 much simpler
       
    70 // Just an E32Main and a MainL()
       
    71 LOCAL_C void MainL()
       
    72 /**
       
    73  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    74  */
       
    75 	{
       
    76 	// Leave the hooks in for platform security
       
    77 #if (defined __DATA_CAGING__)
       
    78 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    79 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    80 #endif
       
    81 	CActiveScheduler* sched=NULL;
       
    82 	sched=new(ELeave) CActiveScheduler;
       
    83 	CActiveScheduler::Install(sched);
       
    84 	CDstIntServer* server = NULL;
       
    85 	// Create the CTestServer derived server
       
    86 	TRAPD(err,server = CDstIntServer::NewL());
       
    87 	if(!err)
       
    88 		{
       
    89 		// Sync with the client and enter the active scheduler
       
    90 		RProcess::Rendezvous(KErrNone);
       
    91 		
       
    92 		#ifdef __WINS__
       
    93 		// Start the Alarm Server
       
    94 		RProcess alarmServer;
       
    95 		TInt err = alarmServer.Create(KConsoleAlarmAlertServerImg, KNullDesC, serverUid);
       
    96 		TRequestStatus stat;
       
    97 		alarmServer.Rendezvous(stat);
       
    98 		if (stat != KRequestPending)
       
    99 			{
       
   100 			alarmServer.Kill(0);
       
   101 			}
       
   102 		else
       
   103 			{
       
   104 			alarmServer.Resume();
       
   105 			}
       
   106 			
       
   107 		User::WaitForRequest(stat);
       
   108 		TInt result = stat.Int();
       
   109 		if(result != KErrNone && result != KErrAlreadyExists)
       
   110 			{
       
   111 			User::LeaveIfError(result);	
       
   112 			}
       
   113 
       
   114 		#endif
       
   115 		
       
   116 		sched->Start();
       
   117 		}
       
   118 	delete server;
       
   119 	delete sched;
       
   120 	}
       
   121 
       
   122 // Only a DLL on emulator for typhoon and earlier
       
   123 
       
   124 GLDEF_C TInt E32Main()
       
   125 /**
       
   126  * @return - Standard Epoc error code on exit
       
   127  */
       
   128 	{
       
   129 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   130 	if(cleanup == NULL)
       
   131 		{
       
   132 		return KErrNoMemory;
       
   133 		}
       
   134 	TRAP_IGNORE(MainL());
       
   135 
       
   136 	delete cleanup;
       
   137 	return KErrNone;
       
   138     }
       
   139 
       
   140 // Create a thread in the calling process
       
   141 // Emulator typhoon and earlier
       
   142 
       
   143 
       
   144 CTestStep* CDstIntServer::CreateTestStep(const TDesC& aStepName)
       
   145 /**
       
   146  * @return - A CTestStep derived instance
       
   147  * Implementation of CTestServer pure virtual
       
   148  */
       
   149 
       
   150 /**
       
   151  * This method is not permitted to leave, so we don't use new(ELeave) and instead use the
       
   152  * standard implementation of new.  This returns NULL if sufficient memory cannot be
       
   153  * allocated, and the return from this method will then be NULL. The alternative would be
       
   154  * to panic at this point.
       
   155  */
       
   156 	{
       
   157 	CTestStep* testStep = NULL;
       
   158 
       
   159 	if(aStepName == KSetAndCheckLocation)
       
   160 	    {
       
   161 		testStep = new CSetAndCheckLocation();
       
   162 	    }
       
   163 	else if(aStepName == KConvertTime)
       
   164 	    {
       
   165 		testStep = new CConvertTime();
       
   166 	    }
       
   167 	else if(aStepName == KConvertTimeViaServer)
       
   168 	    {
       
   169 		testStep = new CConvertTimeViaServer();
       
   170 	    }
       
   171 	else if(aStepName == KImportVCal)
       
   172 	    {
       
   173 		testStep = new CImportVCal();
       
   174 	    }
       
   175 	else if(aStepName == KPerformance)
       
   176 	    {
       
   177 		testStep = new CPerformance();
       
   178 	    }
       
   179 	else if(aStepName == KDSTUpdate)
       
   180 	    {
       
   181 		testStep = new CDSTUpdate();
       
   182 	    }
       
   183 	else if(aStepName == KUTCOffset)
       
   184 	    {
       
   185 		testStep = new CUTCOffset();
       
   186 	    }
       
   187 	else if(aStepName == KAutoUpdateNotification)
       
   188 	    {
       
   189 		testStep = new CAutoUpdateNotification();	    
       
   190 	    }
       
   191 	else if(aStepName == KUTCAlarm)
       
   192 	    {
       
   193 		testStep = new CUTCAlarm();
       
   194 	    }
       
   195 	else if(aStepName == KIsDaylightSavingOn)
       
   196 	    {
       
   197 		testStep = new CIsDaylightSavingOn();
       
   198 	    }
       
   199 	else if (aStepName == KServerMsgSenderStep)
       
   200 	    {
       
   201 		testStep = new CServerMsgSenderTestStep;
       
   202 	    }
       
   203 	else if(aStepName == KBackupRestoreTestStepName)
       
   204 	    {
       
   205 		testStep = new CBackupRestoreTestStep;
       
   206 		}
       
   207 	else if(aStepName == KUnknownZone)
       
   208 	    {
       
   209 		testStep = new CUnknownZoneTest();
       
   210         }
       
   211 	else if(aStepName == KTestTZServer)
       
   212 		{
       
   213 		testStep = new CTestTZServer();
       
   214 		}
       
   215 	else if(aStepName == KSetTz)
       
   216 		{
       
   217 		testStep = new CSetTz();
       
   218 		}
       
   219 	else if(aStepName == KSetSysTime)
       
   220 		{
       
   221 		testStep = new CSetSysTime();
       
   222 		}
       
   223 	else if(aStepName == KTimeZoneOffsetCheckStep)
       
   224 		{
       
   225 		testStep = new CTimeZoneOffsetCheck();	
       
   226 		}
       
   227 	else if(aStepName == KNextDSTChange)
       
   228 		{
       
   229 		testStep = CNextDSTChange::NewL();
       
   230 		}
       
   231 	else if(aStepName == KSubscribeNextDSTChange)
       
   232 		{
       
   233 		testStep = CSubscribeNextDSTChange::NewL();
       
   234 		}
       
   235 	else if(aStepName == KUnknownZoneTime)
       
   236 		{
       
   237 		testStep = CUnknownZoneTime::NewL();
       
   238 		}
       
   239 	return testStep;
       
   240 	}