multimediacommsengine/tsrc/testdriver/testclient/watcher/src/CTcWatcherServer.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 __CTCWATCHERSERVER_H__
       
    19 #define __CTCWATCHERSERVER_H__
       
    20 
       
    21 //  INCLUDES
       
    22 #include <e32base.h>
       
    23 #include "MTcDeathObserver.h"
       
    24 
       
    25 // FORWARD DECLARATIONS
       
    26 class CTcAppLauncher;
       
    27 
       
    28 //  CLASS DEFINITION
       
    29 /**
       
    30  * CTcWatcher is the main server class responsible for starting
       
    31  * and running the server process/thread.
       
    32  */
       
    33 class CTcWatcherServer
       
    34 #ifdef __IPC_V2_PRESENT__
       
    35    : public CServer2,
       
    36 #else
       
    37    : public CServer,
       
    38 #endif
       
    39  	  public MTcDeathObserver
       
    40     {
       
    41     public: // Constructors and destructor
       
    42 
       
    43 		/**
       
    44 		 * Static constructor, leaves pointer to cleanup-stack
       
    45 		 *
       
    46 		 * @return An initialised instance of this class.
       
    47 		 */
       
    48 		static CTcWatcherServer* NewLC();
       
    49 
       
    50 		/// Destructor
       
    51 		~CTcWatcherServer();
       
    52 
       
    53     private: // Constructors
       
    54 
       
    55 		/// Default constructor
       
    56         CTcWatcherServer();
       
    57 
       
    58 		/// 2nd phase constructor
       
    59         void ConstructL();
       
    60 
       
    61 	private: // From CActive
       
    62 
       
    63 		TInt RunError( TInt aError );
       
    64 
       
    65 	private: // From CServer
       
    66 
       
    67 #ifdef __IPC_V2_PRESENT__
       
    68 	    CSession2* NewSessionL( const TVersion& aVersion,
       
    69 	    						const RMessage2& aMessage ) const;
       
    70 #else
       
    71 	    CSharableSession* NewSessionL( const TVersion& aVersion ) const;
       
    72 #endif
       
    73 
       
    74    public: // from MTcDeathObserver
       
    75 
       
    76 		void Died( const TDesC& aAppName, TBool aDismissDialog );
       
    77 
       
    78 	public: // New methods
       
    79 
       
    80 		/**
       
    81 		 * Server entry point method (Thread entry point!)
       
    82 		 * Starts the server up. Creates a cleanupstack and activescheduler
       
    83 		 *
       
    84 		 * @param aParam Thread arguments. Not used.
       
    85 		 */
       
    86 		static TInt ThreadMain( TAny* aParam );
       
    87 
       
    88 		/// Called by a session when it is created. Increments iSessionCount
       
    89 		void SessionAdded();
       
    90 
       
    91 		/// Called by a session when it is destroyed. Decrements iSessionCount.
       
    92 		/// Stops the ActiveScheduler if there are no more sessions.
       
    93 		void SessionRemoved();
       
    94 
       
    95 		/// Shutdown timer callback function
       
    96 		static TInt Shutdown( TAny* aPtr );
       
    97 
       
    98 		/// Called by ThreadMain, starts and initialises the server.
       
    99 		/// This function will block for the lifetime of the server.
       
   100 		static void InitServerL();
       
   101 
       
   102 	private: // Data
       
   103 
       
   104 		/// Number of active sessions.
       
   105 		TInt iSessionCount;
       
   106 
       
   107 		/// Server shutdown timer. Owned.
       
   108 		CDeltaTimer* iShutdownTimer;
       
   109 
       
   110 		/// Server shutdown timer entry item. Owned.
       
   111 		TDeltaTimerEntry iShutdownTimerEntry;
       
   112 
       
   113 		/// Array of application launchers. Owned.
       
   114 		CArrayPtrFlat< CTcAppLauncher > iLaunchers;
       
   115 
       
   116     };
       
   117 
       
   118 #endif // __CTCWATCHERSERVER_H__