Tizen 2.1 base
[platform/upstream/hplip.git] / prnt / hpijs / services.h
1 /*****************************************************************************\
2     services.h : HP Inkjet Server
3
4     Copyright (c) 2001 - 2002, Hewlett-Packard Co.
5     All rights reserved.
6
7     Redistribution and use in source and binary forms, with or without
8     modification, are permitted provided that the following conditions
9     are met:
10     1. Redistributions of source code must retain the above copyright
11        notice, this list of conditions and the following disclaimer.
12     2. Redistributions in binary form must reproduce the above copyright
13        notice, this list of conditions and the following disclaimer in the
14        documentation and/or other materials provided with the distribution.
15     3. Neither the name of the Hewlett-Packard nor the names of its
16        contributors may be used to endorse or promote products derived
17        from this software without specific prior written permission.
18
19     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24     NOT LIMITED TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR
25     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27     STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
28     IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29     POSSIBILITY OF SUCH DAMAGE.
30 \*****************************************************************************/
31
32 #ifndef hpijs_services_INCLUDED
33 #define hpijs_services_INCLUDED
34
35 #include <stdio.h>
36 #include <math.h>
37
38 #define EVENT_PRINT_FAILED_MISSING_PLUGIN 502
39
40 #include "global_types.h"
41
42 APDK_USING_NAMESPACE
43
44 #define BUFFER_CHUNK_SIZE 1024 * 1024 * 2
45
46 class UXServices:public SystemServices
47 {
48 public:
49   UXServices ();
50   virtual ~ UXServices ();
51
52   DRIVER_ERROR BusyWait (DWORD msec);
53
54   DRIVER_ERROR ToDevice (const BYTE* pBuffer, DWORD* wCount);
55
56   DRIVER_ERROR FromDevice (BYTE* pReadBuff, DWORD * wReadCount)
57   {
58     return NO_ERROR;
59   }
60
61   DRIVER_ERROR ReadDeviceID (BYTE * strID, int iSize);
62   BOOL GetStatusInfo (BYTE * bStatReg);
63
64   DWORD GetSystemTickCount (void)
65   {
66     return 0;
67   }
68
69   /////////////////////////////////////////////////////////
70   BOOL YieldToSystem (void)
71   {
72     return 0;
73   }
74
75   BYTE GetRandomNumber ()
76   {
77     return rand ();
78   }
79
80   void DisplayPrinterStatus (DISPLAY_STATUS ePrinterStatus);
81
82   BYTE GetStatus ()
83   {
84     return 0;
85   }
86
87   DRIVER_ERROR GetDevID (BYTE * pDevIDString, int *iDevIDLength);
88
89   DRIVER_ERROR GetECPStatus (BYTE * pStatusString, int *pECPLength,
90                              int ECPChannel)
91   {
92     return NO_ERROR;
93   }
94
95 #ifdef HP_PRINTVIEW
96     int GetPJLHeaderBuffer (char **szPJLBuffer);
97 #endif
98
99   BOOL GetVerticalAlignmentValue(BYTE* cVertAlignVal);
100   BOOL GetVertAlignFromDevice();
101
102   BYTE *AllocMem (int iMemSize)
103   {
104     return (BYTE *) malloc (iMemSize);
105   }
106
107   void FreeMem (BYTE * pMem)
108   {
109     free (pMem);
110   }
111
112   float power (float x, float y)
113   {
114     return pow (x, y);
115   }
116
117   int ProcessRaster(char *raster, char *k_raster);
118   int InitDuplexBuffer();
119   int SendBackPage ();
120   int MapPaperSize(float width, float height);
121   void MapModel(const char *nam);
122   const char * GetDriverMessage(DRIVER_ERROR err);
123
124   void  ResetIOMode (BOOL bDevID, BOOL bStatus);
125
126   void InitSpeedMechBuffer ();
127   int  CopyData (const BYTE *pBuffer, DWORD iCount);
128   int  SendPreviousPage ();
129   void SendLastPage ();
130   BOOL IsSpeedMechEnabled ()
131   {
132       return m_bSpeedMechEnabled;
133   }
134   void EnableSpeedMech (BOOL bFlag)
135   {
136       m_bSpeedMechEnabled = bFlag;
137   }
138
139   BOOL BackPage;
140   int CurrentRaster;
141   BYTE **RastersOnPage;
142   BYTE **KRastersOnPage;
143
144   IjsPageHeader ph;
145
146   const float *Margin;
147   int Model;      /* selected device: -1=no, 1=yes */
148   int OutputPath;   /* open file descriptor */
149   QUALITY_MODE Quality;
150   MEDIATYPE MediaType;
151   COLORMODE ColorMode;
152   PEN_TYPE PenSet;
153   int MediaPosition;
154   float PaperWidth;    /* physical width in inches */
155   float PaperHeight;   /* physical height in inches */
156   int Duplex;
157   int Tumble;
158   int FullBleed;
159   int FirstRaster;
160   int KRGB;            /* 0=no, 1=yes */
161   int hpFD;          /* CUPS hp backend file descriptor. */
162   DISPLAY_STATUS DisplayStatus; /* current DisplayPrinterStatus */
163   int VertAlign;    /* for Crossbow/Spear */
164
165   PrintContext *pPC;
166   Job *pJob;
167   FILE    *outfp;
168   int     m_iLogLevel;
169
170 protected:
171   
172   // for internal use
173   virtual BYTE* AllocMem (int iMemSize, BOOL trackmemory)
174   { return AllocMem(iMemSize); }
175   
176   virtual void FreeMem (BYTE* pMem, BOOL trackmemory)
177   { FreeMem(pMem); }
178   BOOL  CanDoBiDi ();
179
180 private:
181     int    m_iPageCount;
182     BOOL   m_bSpeedMechEnabled;
183     int    m_iPclBufferSize;
184     int    m_iCurPclBufferPos;
185     BYTE   *m_pbyPclBuffer;
186 };
187
188 #endif        /* hpijs_services_INCLUDED */
189