messagingfw/msgtestfw/TestActions/Email/Common/src/CMtfTestActionStopAllSocketConnections.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2004-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 // __ACTION_INFO_BEGIN__ 
       
    15 // [Action Name]
       
    16 // StopAllSocketConnections
       
    17 // [Action Parameters]
       
    18 // none
       
    19 // [Action Description]
       
    20 // Stops all connections at the socket server level
       
    21 // [APIs Used]
       
    22 // none
       
    23 // __ACTION_INFO_END__
       
    24 // 
       
    25 //
       
    26 
       
    27 /**
       
    28  @file
       
    29 */
       
    30 
       
    31 #include <es_sock.h>
       
    32 #include "CMtfTestActionStopAllSocketConnections.h"
       
    33 #include "CMtfTestCase.h"
       
    34 #include "CMtfTestActionParameters.h"
       
    35 
       
    36 CMtfTestAction* CMtfTestActionStopAllSocketConnections::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    37 	{
       
    38 	CMtfTestActionStopAllSocketConnections* self = new (ELeave) CMtfTestActionStopAllSocketConnections(aTestCase);
       
    39 	CleanupStack::PushL(self);
       
    40 	self->ConstructL(aActionParameters);
       
    41 	CleanupStack::Pop();
       
    42 	return self;
       
    43 	}
       
    44 	
       
    45 
       
    46 CMtfTestActionStopAllSocketConnections::CMtfTestActionStopAllSocketConnections(CMtfTestCase& aTestCase)
       
    47 	: CMtfSynchronousTestAction(aTestCase)
       
    48 	{
       
    49 	}
       
    50 
       
    51 
       
    52 CMtfTestActionStopAllSocketConnections::~CMtfTestActionStopAllSocketConnections()
       
    53 	{
       
    54 	}
       
    55 	
       
    56 
       
    57 void CMtfTestActionStopAllSocketConnections::ExecuteActionL()
       
    58 	{
       
    59 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionStopAllSocketConnections);
       
    60 	RSocketServ socketServer;
       
    61 	User::LeaveIfError( socketServer.Connect() );
       
    62 	CleanupClosePushL(socketServer);
       
    63 
       
    64 	RConnection conn;
       
    65 	User::LeaveIfError( conn.Open(socketServer) );
       
    66 	CleanupClosePushL(conn);
       
    67 
       
    68 /* ??? */
       
    69 	// Terminate all currently active connections.
       
    70 	// (notifies all clients with KErrConnectionTerminated)
       
    71 	User::LeaveIfError( conn.Stop(RConnection::EStopAuthoritative) );
       
    72 
       
    73 /* OR
       
    74 
       
    75 	TConnectionInfo connInfo
       
    76 	TPckg<TConnectionInfo> connInfoPckg(connInfo);
       
    77 
       
    78 	// Find out how many active connections there are
       
    79 	TUint count;
       
    80 	User::LeaveIfError( conn.EnumerateConnections(count) );
       
    81 	while(count > 0)
       
    82 		{
       
    83 		// Get the connection info of the first active connection...
       
    84 		User::LeaveIfError( conn.GetConnectionInfo(0, connInfoPckg) );
       
    85 		// ...so we can attach to it...
       
    86 		User::LeaveIfError( conn.Attach(connInfoPckg, RConnection::EAttachTypeNormal) );
       
    87 		// ...and then kill it! (all clients notifed with KErrConnectionTerminated)
       
    88 		User::LeaveIfError( conn.Stop(RConnection::EStopAuthoritative) );
       
    89 
       
    90 		// See if there are any more.
       
    91 		User::LeaveIfError( conn.EnumerateConnections(count) );
       
    92 		}
       
    93 
       
    94 ??? END */
       
    95 	CleanupStack::PopAndDestroy(&conn);
       
    96 	CleanupStack::PopAndDestroy(&socketServer);
       
    97 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionStopAllSocketConnections);
       
    98 	TestCase().ActionCompletedL(*this);
       
    99 	}
       
   100