Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* ex: set tabstop=8 softtabstop=4 shiftwidth=4 expandtab: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef nsCUPSShim_h___ |
michael@0 | 8 | #define nsCUPSShim_h___ |
michael@0 | 9 | |
michael@0 | 10 | |
michael@0 | 11 | /* Various CUPS data types. We don't #include cups headers to avoid |
michael@0 | 12 | * requiring CUPS to be installed on the build host (and to avoid having |
michael@0 | 13 | * to test for CUPS in configure). |
michael@0 | 14 | */ |
michael@0 | 15 | typedef struct /**** Printer Options ****/ |
michael@0 | 16 | { |
michael@0 | 17 | char *name; /* Name of option */ |
michael@0 | 18 | char *value; /* Value of option */ |
michael@0 | 19 | } cups_option_t; |
michael@0 | 20 | |
michael@0 | 21 | typedef struct /**** Destination ****/ |
michael@0 | 22 | { |
michael@0 | 23 | char *name, /* Printer or class name */ |
michael@0 | 24 | *instance; /* Local instance name or nullptr */ |
michael@0 | 25 | int is_default; /* Is this printer the default? */ |
michael@0 | 26 | int num_options; /* Number of options */ |
michael@0 | 27 | cups_option_t *options; /* Options */ |
michael@0 | 28 | } cups_dest_t; |
michael@0 | 29 | |
michael@0 | 30 | typedef cups_dest_t* (*CupsGetDestType)(const char *printer, |
michael@0 | 31 | const char *instance, |
michael@0 | 32 | int num_dests, |
michael@0 | 33 | cups_dest_t *dests); |
michael@0 | 34 | typedef int (*CupsGetDestsType)(cups_dest_t **dests); |
michael@0 | 35 | typedef int (*CupsFreeDestsType)(int num_dests, |
michael@0 | 36 | cups_dest_t *dests); |
michael@0 | 37 | typedef int (*CupsPrintFileType)(const char *printer, |
michael@0 | 38 | const char *filename, |
michael@0 | 39 | const char *title, |
michael@0 | 40 | int num_options, |
michael@0 | 41 | cups_option_t *options); |
michael@0 | 42 | typedef int (*CupsTempFdType)(char *filename, |
michael@0 | 43 | int length); |
michael@0 | 44 | typedef int (*CupsAddOptionType)(const char *name, |
michael@0 | 45 | const char *value, |
michael@0 | 46 | int num_options, |
michael@0 | 47 | cups_option_t **options); |
michael@0 | 48 | |
michael@0 | 49 | struct PRLibrary; |
michael@0 | 50 | |
michael@0 | 51 | /* Note: this class relies on static initialization. */ |
michael@0 | 52 | class nsCUPSShim { |
michael@0 | 53 | public: |
michael@0 | 54 | /** |
michael@0 | 55 | * Initialize this object. Attempt to load the CUPS shared |
michael@0 | 56 | * library and find function pointers for the supported |
michael@0 | 57 | * functions (see below). |
michael@0 | 58 | * @return false if the shared library could not be loaded, or if |
michael@0 | 59 | * any of the functions could not be found. |
michael@0 | 60 | * true for successful initialization. |
michael@0 | 61 | */ |
michael@0 | 62 | bool Init(); |
michael@0 | 63 | |
michael@0 | 64 | /** |
michael@0 | 65 | * @return true if the object was initialized successfully. |
michael@0 | 66 | * false otherwise. |
michael@0 | 67 | */ |
michael@0 | 68 | bool IsInitialized() { return nullptr != mCupsLib; } |
michael@0 | 69 | |
michael@0 | 70 | /* Function pointers for supported functions. These are only |
michael@0 | 71 | * valid after successful initialization. |
michael@0 | 72 | */ |
michael@0 | 73 | CupsAddOptionType mCupsAddOption; |
michael@0 | 74 | CupsFreeDestsType mCupsFreeDests; |
michael@0 | 75 | CupsGetDestType mCupsGetDest; |
michael@0 | 76 | CupsGetDestsType mCupsGetDests; |
michael@0 | 77 | CupsPrintFileType mCupsPrintFile; |
michael@0 | 78 | CupsTempFdType mCupsTempFd; |
michael@0 | 79 | |
michael@0 | 80 | private: |
michael@0 | 81 | PRLibrary *mCupsLib; |
michael@0 | 82 | }; |
michael@0 | 83 | |
michael@0 | 84 | |
michael@0 | 85 | |
michael@0 | 86 | #endif /* nsCUPSShim_h___ */ |