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