commonappservices/alarmservertest/TestAlarmSrv/EASShdOpCodeAlarmAddWithNotification1_CStep.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 1997-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 // This file contains the functions to construct the Test Step and the 
       
    15 // Exec_SendReceiveL() function that connects to the server and makes IPC calls.
       
    16 // 
       
    17 //
       
    18 
       
    19 // Test Step header
       
    20 #include "EASShdOpCodeAlarmAddWithNotification1_CStep.h"
       
    21 
       
    22 // TO BE SAFE
       
    23 IMPORT_C TInt StartDialogThread();
       
    24 
       
    25 /** 
       
    26 Constructor called from the respective Suite.cpp from their "AddTestStep" function
       
    27 Each test step initialises it's own name
       
    28 */
       
    29 CEASShdOpCodeAlarmAddWithNotification1Step::CEASShdOpCodeAlarmAddWithNotification1Step()
       
    30 	{
       
    31 	// The server name and IPC number is obtained and all messages are checked Sync
       
    32 	iSrServerName		= _L("!AlarmServer");
       
    33 	iSrMessageType		= 2;
       
    34 	iSrMessageId		= 201;
       
    35 	iSrMessageMask		= 65536;
       
    36 	iServerPanic		= _L("ALARMSERVER");
       
    37 
       
    38 	TCapability cap[] = {ECapabilityWriteUserData, ECapability_Limit};
       
    39 	
       
    40 	TSecurityInfo info;
       
    41 	info.Set(RProcess());
       
    42 	TBool result = EFalse;
       
    43 	
       
    44 	TInt i;
       
    45 	for (i = 0; cap[i] != ECapability_Limit; i++) 
       
    46 		{
       
    47 		if (!(info.iCaps.HasCapability(cap[i])))
       
    48 			{
       
    49 			result=ETrue;
       
    50 			}
       
    51 		}
       
    52 		
       
    53 	iExpectRejection = result;
       
    54 	iStepCap = 65536;
       
    55 
       
    56 	// Get a unique thread name
       
    57 	iSrChildThread.Format(_L("ChildThread_%S_%d"),&iSrServerName,iSrMessageId);
       
    58 	}
       
    59 
       
    60 /**
       
    61 This function is called by the Child Thread
       
    62 1.	Create a session with the server
       
    63 2.	Test an SendReceive call
       
    64 3.	Informs the main thread about the status of the call using
       
    65 	a.	iSessionCreated, if the a connection is established
       
    66 	b.	iResultServer, holds the return value for connection 
       
    67 	c.	iResultSr, the return value of SendReceive	call
       
    68 */
       
    69 TInt CEASShdOpCodeAlarmAddWithNotification1Step::Exec_SendReceiveL()
       
    70 	{
       
    71 	iResultServer = CreateSession(iSrServerName,Version(),KAlarmServerAsynchronousSlotCount);
       
    72 
       
    73 	if (iResultServer!=KErrNone)
       
    74 		{
       
    75 		iResultServer=StartServer();
       
    76 		if (iResultServer!=KErrNone)
       
    77 			{
       
    78 			return(iResultServer);
       
    79 			}
       
    80 		iResultServer = CreateSession(iSrServerName,Version(),KAlarmServerAsynchronousSlotCount);
       
    81 		}
       
    82 	if(iResultServer == 0)
       
    83 		{
       
    84 		iSessionCreated = ETrue;
       
    85 		if(iSrMessageId >= 0)
       
    86 			{
       
    87 			// Build the parameters
       
    88 			TASShdAlarm alarm;
       
    89 			TRequestStatus status;
       
    90 			TDesC8 data(KNullDesC8);
       
    91 			TPtr8 package(NULL, 0, 0);
       
    92 			TIpcArgs args(&package, data.Length(), &data);
       
    93 			package.Set((TUint8*) &alarm, sizeof(TASShdAlarm), sizeof(TASShdAlarm));
       
    94 			alarm.Id() = KNullAlarmId;
       
    95 			
       
    96 			// Make the IPC call
       
    97 			SendReceive(iSrMessageId,args, status);
       
    98 			
       
    99 			// Wait for the notification
       
   100 			User::WaitForRequest(status);
       
   101 			
       
   102 			// Get the result
       
   103 			iResultSr =	status.Int();
       
   104 			}
       
   105 		}
       
   106 	return iResultServer;
       
   107 	}
       
   108