multimediacommsengine/tsrc/testdriver/testclient/watcher/inc/RTcWatcher.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2004 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 "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:  See class definition below.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __RTCWATCHER_H__
       
    19 #define __RTCWATCHER_H__
       
    20 
       
    21 //	INCLUDES
       
    22 #include <e32base.h>
       
    23 
       
    24 //	CLASS DEFINITION
       
    25 /**
       
    26  * RTcWatcher implements the client-side endpoint of a Watcher
       
    27  * client-server session. A connected client must call Ping()
       
    28  * at intervals shorter than aTimeout specified in Connect().
       
    29  * Failing to do that will result in the application specified
       
    30  * in Connect() being terminated and restarted.
       
    31  */
       
    32 class RTcWatcher
       
    33 	: public RSessionBase
       
    34 	{
       
    35 	public: // Constructors and destructor
       
    36 
       
    37 		/// Default constructor
       
    38 		IMPORT_C RTcWatcher();
       
    39 
       
    40 	public: // from RHandleBase
       
    41 
       
    42 		/// Closes the connection to the server.
       
    43 		/// Stops watching for this client.
       
    44 		IMPORT_C void Close();
       
    45 
       
    46 	public:	// New methods
       
    47 
       
    48 		/**
       
    49 		 * Establishes a connection to the Watcher server.
       
    50 		 * The server is automatically started if it was not already
       
    51 		 * up and running.
       
    52 		 *
       
    53 		 * Start watching for this client. The client is killed if it does
       
    54 		 * not report in every aTimeout seconds. The client is restarted
       
    55 		 * if it dies by itself or gets killed by the timeout.
       
    56 		 *
       
    57 		 * @param aAppName Application name and full path, for restarting.
       
    58 		 * @param aTimeout Kill timeout.
       
    59 		 * @return KErrNone if operation was successful, otherwise
       
    60 		 *		   one of the standard system-wide error codes.
       
    61 		 */
       
    62 		IMPORT_C TInt Connect( const TDesC& aAppName, TInt aTimeout );
       
    63 
       
    64 		/// To be called a couple of times within the aTimeout
       
    65 		/// Failing to do that will result in client death.
       
    66 		IMPORT_C TInt Ping();
       
    67 
       
    68 		/// @return Server version number.
       
    69 		IMPORT_C TVersion Version() const;
       
    70 
       
    71 	private: // New methods
       
    72 
       
    73 		/// Starts the server process.
       
    74 		void StartServerL();
       
    75 
       
    76 		/// @return ETrue if the server is already/still running
       
    77 		TBool IsServerStarted() const;
       
    78 
       
    79 	private: // Data
       
    80 
       
    81 		/// ETrue if there is an open connection, EFalse otherwise.
       
    82 		TBool iIsConnected;
       
    83 
       
    84     };
       
    85 
       
    86 #endif  // __RTCWATCHER_H__