1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/gtk/nsCUPSShim.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,86 @@ 1.4 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* ex: set tabstop=8 softtabstop=4 shiftwidth=4 expandtab: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef nsCUPSShim_h___ 1.11 +#define nsCUPSShim_h___ 1.12 + 1.13 + 1.14 +/* Various CUPS data types. We don't #include cups headers to avoid 1.15 + * requiring CUPS to be installed on the build host (and to avoid having 1.16 + * to test for CUPS in configure). 1.17 + */ 1.18 +typedef struct /**** Printer Options ****/ 1.19 +{ 1.20 + char *name; /* Name of option */ 1.21 + char *value; /* Value of option */ 1.22 +} cups_option_t; 1.23 + 1.24 +typedef struct /**** Destination ****/ 1.25 +{ 1.26 + char *name, /* Printer or class name */ 1.27 + *instance; /* Local instance name or nullptr */ 1.28 + int is_default; /* Is this printer the default? */ 1.29 + int num_options; /* Number of options */ 1.30 + cups_option_t *options; /* Options */ 1.31 +} cups_dest_t; 1.32 + 1.33 +typedef cups_dest_t* (*CupsGetDestType)(const char *printer, 1.34 + const char *instance, 1.35 + int num_dests, 1.36 + cups_dest_t *dests); 1.37 +typedef int (*CupsGetDestsType)(cups_dest_t **dests); 1.38 +typedef int (*CupsFreeDestsType)(int num_dests, 1.39 + cups_dest_t *dests); 1.40 +typedef int (*CupsPrintFileType)(const char *printer, 1.41 + const char *filename, 1.42 + const char *title, 1.43 + int num_options, 1.44 + cups_option_t *options); 1.45 +typedef int (*CupsTempFdType)(char *filename, 1.46 + int length); 1.47 +typedef int (*CupsAddOptionType)(const char *name, 1.48 + const char *value, 1.49 + int num_options, 1.50 + cups_option_t **options); 1.51 + 1.52 +struct PRLibrary; 1.53 + 1.54 +/* Note: this class relies on static initialization. */ 1.55 +class nsCUPSShim { 1.56 + public: 1.57 + /** 1.58 + * Initialize this object. Attempt to load the CUPS shared 1.59 + * library and find function pointers for the supported 1.60 + * functions (see below). 1.61 + * @return false if the shared library could not be loaded, or if 1.62 + * any of the functions could not be found. 1.63 + * true for successful initialization. 1.64 + */ 1.65 + bool Init(); 1.66 + 1.67 + /** 1.68 + * @return true if the object was initialized successfully. 1.69 + * false otherwise. 1.70 + */ 1.71 + bool IsInitialized() { return nullptr != mCupsLib; } 1.72 + 1.73 + /* Function pointers for supported functions. These are only 1.74 + * valid after successful initialization. 1.75 + */ 1.76 + CupsAddOptionType mCupsAddOption; 1.77 + CupsFreeDestsType mCupsFreeDests; 1.78 + CupsGetDestType mCupsGetDest; 1.79 + CupsGetDestsType mCupsGetDests; 1.80 + CupsPrintFileType mCupsPrintFile; 1.81 + CupsTempFdType mCupsTempFd; 1.82 + 1.83 + private: 1.84 + PRLibrary *mCupsLib; 1.85 +}; 1.86 + 1.87 + 1.88 + 1.89 +#endif /* nsCUPSShim_h___ */