Back to index

lightning-sunbird  0.9+nobinonly
xprintutil.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 #ifndef XPRINTUTIL_H
00003 #define XPRINTUTIL_H 1
00004 /* ***** BEGIN LICENSE BLOCK *****
00005  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00006  *
00007  * The contents of this file are subject to the Mozilla Public License Version
00008  * 1.1 (the "License"); you may not use this file except in compliance with
00009  * the License. You may obtain a copy of the License at
00010  * http://www.mozilla.org/MPL/
00011  *
00012  * Software distributed under the License is distributed on an "AS IS" basis,
00013  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00014  * for the specific language governing rights and limitations under the
00015  * License.
00016  *
00017  * The Original Code is the X11 print system utilities library.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>.
00021  * Portions created by the Initial Developer are Copyright (C) 2001
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 /* Force ANSI C prototypes from X11 headers */
00041 #ifndef FUNCPROTO 
00042 #define FUNCPROTO 15
00043 #endif /* !FUNCPROTO */
00044 
00045 #include <X11/Xlibint.h>
00046 #include <X11/extensions/Print.h>
00047 #include <X11/Intrinsic.h>
00048 
00049 /* I don't know how to make this "better" yet... ;-( */
00050 #ifdef USE_MOZILLA_TYPES
00051 #include <prtypes.h>
00052 #include <prmem.h>
00053 #include <prthread.h>
00054 #define XPU_USE_NSPR 1
00055 /*
00056  * Disabled for now - Threaded codepath does not work properly always.
00057  * See bug 134570 ("Print-to-file not working with threaded XprintUtil")
00058  * #define XPU_USE_THREADS 1
00059  */
00060 #endif /* USE_MOZILLA_TYPES */
00061 
00062 #ifdef DEBUG
00063 /* trace function calls */
00064 #define XPU_TRACE(EX)  (puts(#EX),EX)
00065 /* trace function calls in child */
00066 #define XPU_TRACE_CHILD(EX)  (puts("child: " #EX),EX)
00067 /* execute function EX only in debug mode */
00068 #define XPU_DEBUG_ONLY(EX)  (EX)
00069 #else
00070 #define XPU_TRACE(EX) (EX)
00071 #define XPU_TRACE_CHILD(EX) (EX)
00072 #define XPU_DEBUG_ONLY(EX)
00073 #endif /* DEBUG */
00074 
00075 /* debug/logging: replace NULLptrs with "<NULL>" string */
00076 #define XPU_NULLXSTR(s) (((s)!=NULL)?(s):("<NULL>"))
00077 
00078 /*
00079  * Struct for XpuGetMediumSourceSizeList(), XpuFreeMediumSourceSizeList(),
00080  * XpuSetDocMediumSourceSize(), XpuSetPageMediumSourceSize(),
00081  * XpuFindMediumSourceSizeBy*()
00082  */
00083 typedef struct {
00084   const char *tray_name;
00085   const char *medium_name;
00086   int         mbool;
00087   float       ma1; 
00088   float       ma2; 
00089   float       ma3; 
00090   float       ma4;
00091 } XpuMediumSourceSizeRec, *XpuMediumSourceSizeList;
00092 
00093 /*
00094  * Struct for XpuGetResolutionList(), XpuFreeResolutionList(),
00095  * XpuGetResolution(), XpuSetPageResolution(), XpuSetDocResolution(),
00096  * XpuFindResolutionByName()
00097  */
00098 typedef struct {
00099   const char *name;
00100   long        x_dpi;
00101   long        y_dpi;
00102 } XpuResolutionRec, *XpuResolutionList;
00103 
00104 /*
00105  * Struct for XpuGetOrientationList(), XpuFreeOrientationList(),
00106  * XpuFindOrientationBy*(), XpuSetPageResolution(), 
00107  * XpuSetDocOrientation()
00108  */
00109 typedef struct {
00110   const char *orientation;
00111 } XpuOrientationRec, *XpuOrientationList;
00112 
00113 /*
00114  * Struct for XpuGetPlexList(), XpuFreePlexList(), XpuFindPlexBy*(),
00115  * XpuSetDocPlex(), XpuSetPagePlex()
00116  */
00117 typedef struct {
00118   const char *plex;
00119 } XpuPlexRec, *XpuPlexList;
00120 
00121 /*
00122  * Struct for XpuGetColorspaceList(), XpuFreeColorspaceList()
00123  */
00124 typedef struct
00125 {
00126   const char  *name;
00127   XVisualInfo  visualinfo;
00128 } XpuColorspaceRec, *XpuColorspaceList;
00129 
00130 /* XPUATTRIBUTESUPPORTED_*:
00131  * Flags which indicate whether it is allowed to set/change a specific attribute
00132  */
00133 typedef long XpuSupportedFlags;
00134 /* Job attributes */
00135 #define XPUATTRIBUTESUPPORTED_JOB_NAME                     (1L<<0)
00136 #define XPUATTRIBUTESUPPORTED_JOB_OWNER                    (1L<<1)
00137 #define XPUATTRIBUTESUPPORTED_NOTIFICATION_PROFILE         (1L<<2)
00138 /* Document/Page attributes */
00139 #define XPUATTRIBUTESUPPORTED_COPY_COUNT                   (1L<<3)
00140 #define XPUATTRIBUTESUPPORTED_DOCUMENT_FORMAT              (1L<<4)
00141 #define XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION          (1L<<5)
00142 #define XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION   (1L<<6)
00143 #define XPUATTRIBUTESUPPORTED_DEFAULT_INPUT_TRAY           (1L<<7)
00144 #define XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM               (1L<<8)
00145 #define XPUATTRIBUTESUPPORTED_PLEX                         (1L<<9)
00146 #define XPUATTRIBUTESUPPORTED_LISTFONTS_MODES              (1L<<10)
00147 
00148 /* prototypes */
00149 _XFUNCPROTOBEGIN
00150 
00151 int XpuCheckExtension( Display *pdpy );
00152 
00153 /* Create/destroy connection to printer */
00154 Bool XpuXprintServersAvailable( void );
00155 int XpuGetPrinter( const char *printername, Display **pdpyptr, XPContext *pcontextptr );
00156 void XpuClosePrinterDisplay(Display *pdpy, XPContext pcontext);
00157 
00158 /* Misc. functions */
00159 void XpuSetOneAttribute( Display *pdpy, XPContext pcontext, 
00160                          XPAttributes type, const char *attribute_name, const char *value, XPAttrReplacement replacement_rule );
00161 void XpuSetOneLongAttribute( Display *pdpy, XPContext pcontext, 
00162                          XPAttributes type, const char *attribute_name, long value, XPAttrReplacement replacement_rule );
00163 int XpuCheckSupported( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name, const char *query );
00164 int XpuSetJobTitle( Display *pdpy, XPContext pcontext, const char *title );
00165 int XpuGetOneLongAttribute( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name, long *result );
00166 #ifdef DEBUG
00167 void dumpXpAttributes( Display *pdpy, XPContext pcontext );
00168 #endif /* DEBUG */
00169 void XpuWaitForPrintNotify( Display *pdpy, int xp_event_base, int detail );
00170 
00171 /* Get list of printers */
00172 XPPrinterList XpuGetPrinterList( const char *printer, int *res_list_count );
00173 void XpuFreePrinterList( XPPrinterList list );
00174 
00175 /* Set number of document copies */
00176 int XpuSetDocumentCopies( Display *pdpy, XPContext pcontext, long num_copies );
00177 
00178 /* Get/Set/Query supported mediums (paper sizes) */
00179 XpuMediumSourceSizeList XpuGetMediumSourceSizeList( Display *pdpy, XPContext pcontext, int *numEntriesPtr );
00180 void XpuFreeMediumSourceSizeList( XpuMediumSourceSizeList list );
00181 int XpuSetDocMediumSourceSize( Display *pdpy, XPContext pcontext, XpuMediumSourceSizeRec *medium_spec );
00182 int XpuSetPageMediumSourceSize( Display *pdpy, XPContext pcontext, XpuMediumSourceSizeRec *medium_spec );
00183 XpuMediumSourceSizeRec *
00184 XpuFindMediumSourceSizeBySize( XpuMediumSourceSizeList mlist, int mlist_count,
00185                                float page_width_mm, float page_height_mm, float tolerance );
00186 XpuMediumSourceSizeRec *
00187 XpuFindMediumSourceSizeByBounds( XpuMediumSourceSizeList mlist, int mlist_count, 
00188                                  float m1, float m2, float m3, float m4, float tolerance );
00189 XpuMediumSourceSizeRec *
00190 XpuFindMediumSourceSizeByName( XpuMediumSourceSizeList mlist, int mlist_count, 
00191                                const char *tray_name, const char *medium_name );
00192 
00193 /* Get/Set resolution */
00194 XpuResolutionList XpuGetResolutionList( Display *pdpy, XPContext pcontext, int *numEntriesPtr );
00195 void XpuFreeResolutionList( XpuResolutionList list );
00196 Bool XpuGetResolution( Display *pdpy, XPContext pcontext, long *x_dpi, long *y_dpi );
00197 Bool XpuSetPageResolution( Display *pdpy, XPContext pcontext, XpuResolutionRec * );
00198 Bool XpuSetDocResolution( Display *pdpy, XPContext pcontext, XpuResolutionRec * );
00199 XpuResolutionRec *XpuFindResolutionByName( XpuResolutionList list, int list_count, const char *resolution_name);
00200 
00201 /* Get/Set orientation */
00202 XpuOrientationList XpuGetOrientationList( Display *pdpy, XPContext pcontext, int *numEntriesPtr );
00203 void XpuFreeOrientationList( XpuOrientationList list );
00204 XpuOrientationRec *
00205 XpuFindOrientationByName( XpuOrientationList list, int list_count, const char *orientation );
00206 int XpuSetDocOrientation( Display *pdpy, XPContext pcontext, XpuOrientationRec *rec );
00207 int XpuSetPageOrientation( Display *pdpy, XPContext pcontext, XpuOrientationRec *rec );
00208 
00209 /* Get/set plex modes */
00210 XpuPlexList XpuGetPlexList( Display *pdpy, XPContext pcontext, int *numEntriesPtr );
00211 void XpuFreePlexList( XpuPlexList list );
00212 XpuPlexRec *XpuFindPlexByName( XpuPlexList list, int list_count, const char *plex );
00213 int XpuSetDocPlex( Display *pdpy, XPContext pcontext, XpuPlexRec *rec );
00214 int XpuSetPagePlex( Display *pdpy, XPContext pcontext, XpuPlexRec *rec );
00215 
00216 /* Set/get usage of fonts */
00217 Bool XpuGetEnableFontDownload( Display *pdpy, XPContext pcontext );
00218 int XpuSetEnableFontDownload( Display *pdpy, XPContext pcontext, Bool enableFontDownload );
00219 
00220 /* Get per-printer colorspace information */
00221 XpuColorspaceList XpuGetColorspaceList( Display *pdpy, XPContext pcontext, int *numEntriesPtr );
00222 void XpuFreeColorspaceList( XpuColorspaceList list );
00223 XpuColorspaceRec *XpuFindColorspaceByName( XpuColorspaceList list, int list_count, const char *colorspace );
00224 
00225 /* Start job to printer (spooler) or file */
00226 void XpuStartJobToSpooler(Display *pdpy);
00227 void *XpuStartJobToFile( Display *pdpy, XPContext pcontext, const char *filename );
00228 XPGetDocStatus XpuWaitForPrintFileChild( void *handle );
00229 
00230 /* Get flags which indicate whether it is allowed to set/change a specific attribute */
00231 XpuSupportedFlags XpuGetSupportedJobAttributes(Display *pdpy, XPContext pcontext);
00232 XpuSupportedFlags XpuGetSupportedDocAttributes(Display *pdpy, XPContext pcontext);
00233 XpuSupportedFlags XpuGetSupportedPageAttributes(Display *pdpy, XPContext pcontext);
00234 
00235 /* Encode/decode resource strings */
00236 char *XpuResourceEncode( const char *str );
00237 char *XpuResourceDecode( const char *str );
00238 void XpuResourceFreeString( char *s );
00239 
00240 /* COMPOUND_TEXT <----> local encoding string converters */
00241 const char *XpuXmbToCompoundText(Display *dpy, const char *xmbtext);
00242 void XpuFreeCompundTextString( const char *s );
00243 const char *XpuCompoundTextToXmb(Display *dpy, const char *ct);
00244 void XpuFreeXmbString( const char *s );
00245 
00246 
00247 _XFUNCPROTOEND
00248 
00249 #define XpuGetJobAttributes( pdpy, pcontext )     XpGetAttributes( (pdpy), (pcontext), XPJobAttr )
00250 #define XpuGetDocAttributes( pdpy, pcontext )     XpGetAttributes( (pdpy), (pcontext), XPDocAttr )
00251 #define XpuGetPageAttributes( pdpy, pcontext )    XpGetAttributes( (pdpy), (pcontext), XPPageAttr )
00252 #define XpuGetPrinterAttributes( pdpy, pcontext ) XpGetAttributes( (pdpy), (pcontext), XPPrinterAttr )
00253 #define XpuGetServerAttributes( pdpy, pcontext )  XpGetAttributes( (pdpy), (pcontext), XPServerAttr )
00254 
00255 #endif /* !XPRINTUTIL_H */
00256 /* EOF. */