syncmlfw/dm/hostserver/dmhostserverbase/inc/nsmldmhostserver.h
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Contains common part of server code. Dedicated DM HostServers 
       
    15 *				 (1-4) are inherited from this class.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __NSMLDMHOSTSERVER_H__
       
    21 #define __NSMLDMHOSTSERVER_H__
       
    22 
       
    23 // ------------------------------------------------------------------------------------------------
       
    24 // Includes
       
    25 // ------------------------------------------------------------------------------------------------
       
    26 #include <e32base.h>
       
    27 
       
    28 
       
    29 /**
       
    30 * Class CNSmlDMHostServer. Contains common part of server code. Dedicated DM HostServers 
       
    31 * (1-4) are inherited from this class
       
    32 *
       
    33 * @lib nsmldmhostserver.lib
       
    34 */
       
    35 
       
    36 class CNSmlDMHostServer : public CServer2
       
    37 	{
       
    38 public:
       
    39 	enum TNSmlDmHostServerPanic
       
    40     	{
       
    41     	ESvrCreateServer,
       
    42     	EMainSchedulerError
       
    43     	};
       
    44 	/**
       
    45 	* Destructor.
       
    46 	*/
       
    47 	IMPORT_C ~CNSmlDMHostServer();
       
    48 
       
    49 	/**
       
    50 	* Increments session count.
       
    51 	*/
       
    52 	void IncSessionCount();
       
    53 	
       
    54 	/**
       
    55 	* Decrements session count. When count reaches zero, stops active scheduler
       
    56 	*/	
       
    57 	void DecSessionCount();
       
    58 protected:
       
    59 	/**
       
    60 	* Constructor. Protected to prevent direct instantiation.
       
    61 	*/
       
    62     IMPORT_C CNSmlDMHostServer();
       
    63 
       
    64    	/**
       
    65 	* initializes server, calls aFunction
       
    66 	* @param aServerName. Server to initialize.
       
    67 	* @param aFunction. Function to call after initialization.
       
    68 	* @return TInt. Status code. KErrNone if method suceeded, system wide error otherwise.
       
    69 	*/    
       
    70     IMPORT_C static TInt InitHostServer ( const TDesC& aServerName, TThreadFunction aFunction );
       
    71 
       
    72    	/**
       
    73 	* calls NewSessionL.
       
    74 	* @param aVersion. Version for session.
       
    75 	* @param aMessage. Message associated with the request.
       
    76 	* @return CSession2*. The requested session object.
       
    77 	*/
       
    78     IMPORT_C CSession2* CallNewSessionL ( const TVersion& aVersion, const RMessage2& aMessage ) const;
       
    79 private:
       
    80 	/**
       
    81 	* returns session object.
       
    82 	* @param aVersion. Version for session.
       
    83 	* @param aMessage. Message associated with the request.
       
    84 	* @return CSession2*. The requested session object.
       
    85 	*/
       
    86     CSession2* NewSessionL ( const TVersion& aVersion, const RMessage2& aMessage ) const;
       
    87 	
       
    88 	/**
       
    89 	* starting point of a server thread, when in emulator.
       
    90 	* @param aStarted. parameter for a thread, contains function pointer to specialized server initialization.
       
    91 	* @return TInt. exit code from thread.
       
    92 	*/
       
    93     static TInt ThreadFunction ( TAny* aStarted );
       
    94 
       
    95 	/**
       
    96 	* Panics the server.
       
    97 	* @param aPanic. Panic code.
       
    98 	*/    
       
    99     static void PanicServer ( TNSmlDmHostServerPanic aPanic );
       
   100     
       
   101 	/**
       
   102 	* Server exe name.
       
   103 	* @return TPtrC. Server exe name concluded from the current thread name.
       
   104 	*/        
       
   105     static TPtrC ServerName();
       
   106 
       
   107 private:
       
   108 	TInt iSessionCount;
       
   109 	};
       
   110 
       
   111 #endif // __NSMLDMHOSTSERVER_H__