DirectPrint/DirectPrintServer/inc/directprintserver.h
changeset 19 2275db202402
parent 11 613a5ff70823
equal deleted inserted replaced
2:acc370d7f2f6 19:2275db202402
       
     1 /*
       
     2 * Copyright (c) 2010 Kanrikogaku Kenkyusho, Ltd.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "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 * Kanrikogaku Kenkyusho, Ltd. - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // Protection against nested includes
       
    20 #ifndef CDIRECTPRINTSERVER_H
       
    21 #define CDIRECTPRINTSERVER_H
       
    22 
       
    23 // System include files
       
    24 #include <e32base.h>
       
    25 #include <fbs.h>
       
    26 
       
    27 class CDirectPrintBody;
       
    28 
       
    29 // ----------------------------------------------------------------------------------------
       
    30 // Server's policy here
       
    31 // ----------------------------------------------------------------------------------------
       
    32 
       
    33 // Total number of ranges
       
    34 const TUint KDirectPrintRangeCount = 2;
       
    35 
       
    36 // Definition of the ranges of IPC numbers
       
    37 const TInt KDirectPrintRanges[KDirectPrintRangeCount] = 
       
    38     {
       
    39     0,	// implemented 0-38
       
    40     41 	// non implemented function end of range check ; ENotSupported        
       
    41     }; 
       
    42 
       
    43 // Policy to implement for each of the above ranges        
       
    44 const TUint8 KDirectPrintElementsIndex[KDirectPrintRangeCount] = 
       
    45     {
       
    46     CPolicyServer::EAlwaysPass,		// applies to 0th range        
       
    47     CPolicyServer::ENotSupported  	// applies to 1st range (out of range IPC)
       
    48     };
       
    49 
       
    50 // Package all the above together into a policy
       
    51 const CPolicyServer::TPolicy KDirectPrintPolicy =
       
    52     {
       
    53     CPolicyServer::EAlwaysPass, 	// specifies all connect attempts should pass
       
    54     KDirectPrintRangeCount,			// number of ranges                                   
       
    55     KDirectPrintRanges,				// ranges array
       
    56     KDirectPrintElementsIndex,		// elements<->ranges index
       
    57     NULL,							// array of elements
       
    58     };
       
    59 class CDirectPrintServer : public CPolicyServer
       
    60 	{
       
    61 	public:
       
    62 
       
    63 		/**
       
    64 		 *	2-phase constructor
       
    65 		 *
       
    66 		 *	@return new object. The object is left on the cleanup stack
       
    67 		 */
       
    68 		static CDirectPrintServer* NewLC();
       
    69 		
       
    70 		/**
       
    71 		 *	Destructor
       
    72 		 */
       
    73 		~CDirectPrintServer();
       
    74 		
       
    75 		/**
       
    76 		 *	Increase session counter
       
    77 		 */
       
    78 		void AddSession();
       
    79 		
       
    80 		/**
       
    81 		 *	Decrease session counter. If the counter is decreased to 0, the
       
    82 		 *	server is shut down
       
    83 		 */
       
    84 		void RemoveSession();
       
    85 		
       
    86 		/**
       
    87 		 *	Session count getter
       
    88 		 *
       
    89 		 *	@return session count
       
    90 		 */
       
    91 		TInt SessionCount() const;
       
    92 		
       
    93 		/**
       
    94 		 *	Reserve printing engine to the session
       
    95 		 *
       
    96 		 *	@param aSession session that claims the printing engine
       
    97 		 *	@return error code
       
    98 		 */
       
    99 		TInt ReserveEngine( const CSession2* aSession );
       
   100 		
       
   101 		/**
       
   102 		 *	Release printing engine by the session
       
   103 		 *
       
   104 		 *	@param aSession session that wants to release the printing engine
       
   105 		 *	@return error code
       
   106 		 */
       
   107 		TInt ReleaseEngine( const CSession2* aSession );
       
   108 		
       
   109 		/**
       
   110 		 *	Printing engine getter
       
   111 		 *
       
   112 		 *	@return printing engine
       
   113 		 */
       
   114 		CDirectPrintBody& Engine() const;
       
   115 
       
   116 	private:
       
   117 		
       
   118 		TInt RunError( TInt aError );
       
   119 		CDirectPrintServer();
       
   120 		void ConstructL();		
       
   121 		CSession2* NewSessionL( const TVersion& aVersion, const RMessage2& aMessage ) const;		
       
   122 
       
   123 	private:
       
   124 
       
   125 		TInt iConnsCount;
       
   126 		
       
   127 		const CSession2* iEngineHolder;
       
   128 		
       
   129 		CDirectPrintBody* iEngine;
       
   130 				
       
   131 		RFbsSession iFbs;
       
   132 	};
       
   133 
       
   134 
       
   135 #endif // CDIRECTPRINTSERVER_H
       
   136 
       
   137 //  End of File