Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 325469
Collapse All | Expand All

(-)a/gfx/src/psshared/nsCUPSShim.cpp (-6 lines)
Lines 83-96 nsCUPSShim::Init() Link Here
83
#endif
83
#endif
84
            PR_UnloadLibrary(mCupsLib);
84
            PR_UnloadLibrary(mCupsLib);
85
            mCupsLib = nsnull;
85
            mCupsLib = nsnull;
86
            return PR_FALSE;
86
            return PR_FALSE;
87
        }
87
        }
88
    }
88
    }
89
    return PR_TRUE;
89
    return PR_TRUE;
90
}
90
}
91
92
nsCUPSShim::~nsCUPSShim()
93
{
94
    if (mCupsLib)
95
        PR_UnloadLibrary(mCupsLib);
96
}
(-)a/gfx/src/psshared/nsCUPSShim.h (-1 lines)
Lines 81-97 typedef int (PR_CALLBACK *CupsAddOptionT Link Here
81
                                             int           num_options,
81
                                             int           num_options,
82
                                             cups_option_t **options);
82
                                             cups_option_t **options);
83
83
84
struct PRLibrary;
84
struct PRLibrary;
85
85
86
class NS_PSSHARED nsCUPSShim {
86
class NS_PSSHARED nsCUPSShim {
87
    public:
87
    public:
88
        nsCUPSShim() : mCupsLib(nsnull) { }
88
        nsCUPSShim() : mCupsLib(nsnull) { }
89
        ~nsCUPSShim();
90
89
91
        /**
90
        /**
92
         * Initialize this object. Attempt to load the CUPS shared
91
         * Initialize this object. Attempt to load the CUPS shared
93
         * library and find function pointers for the supported
92
         * library and find function pointers for the supported
94
         * functions (see below).
93
         * functions (see below).
95
         * @return PR_FALSE if the shared library could not be loaded, or if
94
         * @return PR_FALSE if the shared library could not be loaded, or if
96
         *                  any of the functions could not be found.
95
         *                  any of the functions could not be found.
97
         *         PR_TRUE  for successful initialization.
96
         *         PR_TRUE  for successful initialization.
(-)a/gfx/src/psshared/nsPSPrinters.cpp (-5 / +7 lines)
Lines 51-82 Link Here
51
#include "plstr.h"
51
#include "plstr.h"
52
52
53
#define NS_CUPS_PRINTER "CUPS/"
53
#define NS_CUPS_PRINTER "CUPS/"
54
#define NS_CUPS_PRINTER_LEN (sizeof(NS_CUPS_PRINTER) - 1)
54
#define NS_CUPS_PRINTER_LEN (sizeof(NS_CUPS_PRINTER) - 1)
55
55
56
/* dummy printer name for the gfx/src/ps driver */
56
/* dummy printer name for the gfx/src/ps driver */
57
#define NS_POSTSCRIPT_DRIVER_NAME "PostScript/"
57
#define NS_POSTSCRIPT_DRIVER_NAME "PostScript/"
58
58
59
nsCUPSShim gCupsShim;
60
59
/* Initialize the printer manager object */
61
/* Initialize the printer manager object */
60
nsresult
62
nsresult
61
nsPSPrinterList::Init()
63
nsPSPrinterList::Init()
62
{
64
{
63
    nsresult rv;
65
    nsresult rv;
64
66
65
    mPrefSvc = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
67
    mPrefSvc = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
66
    if (NS_SUCCEEDED(rv))
68
    if (NS_SUCCEEDED(rv))
67
        rv = mPrefSvc->GetBranch("print.", getter_AddRefs(mPref));
69
        rv = mPrefSvc->GetBranch("print.", getter_AddRefs(mPref));
68
    NS_ENSURE_SUCCESS(rv, NS_ERROR_NOT_INITIALIZED);
70
    NS_ENSURE_SUCCESS(rv, NS_ERROR_NOT_INITIALIZED);
69
71
70
    // Should we try cups?
72
    // Should we try cups?
71
    PRBool useCups = PR_TRUE;
73
    PRBool useCups = PR_TRUE;
72
    rv = mPref->GetBoolPref("postscript.cups.enabled", &useCups);
74
    rv = mPref->GetBoolPref("postscript.cups.enabled", &useCups);
73
    if (useCups)
75
    if (useCups && !gCupsShim.IsInitialized())
74
        mCups.Init();
76
        gCupsShim.Init();
75
    return NS_OK;
77
    return NS_OK;
76
}
78
}
77
79
78
80
79
/* Check whether the PostScript module has been disabled at runtime */
81
/* Check whether the PostScript module has been disabled at runtime */
80
PRBool
82
PRBool
81
nsPSPrinterList::Enabled()
83
nsPSPrinterList::Enabled()
82
{
84
{
Lines 94-128 nsPSPrinterList::Enabled() Link Here
94
/* Fetch a list of printers handled by the PostsScript module */
96
/* Fetch a list of printers handled by the PostsScript module */
95
void
97
void
96
nsPSPrinterList::GetPrinterList(nsTArray<nsCString>& aList)
98
nsPSPrinterList::GetPrinterList(nsTArray<nsCString>& aList)
97
{
99
{
98
    aList.Clear();
100
    aList.Clear();
99
101
100
    // Query CUPS for a printer list. The default printer goes to the
102
    // Query CUPS for a printer list. The default printer goes to the
101
    // head of the output list; others are appended.
103
    // head of the output list; others are appended.
102
    if (mCups.IsInitialized()) {
104
    if (gCupsShim.IsInitialized()) {
103
        cups_dest_t *dests;
105
        cups_dest_t *dests;
104
106
105
        int num_dests = (mCups.mCupsGetDests)(&dests);
107
        int num_dests = (gCupsShim.mCupsGetDests)(&dests);
106
        if (num_dests) {
108
        if (num_dests) {
107
            for (int i = 0; i < num_dests; i++) {
109
            for (int i = 0; i < num_dests; i++) {
108
                nsCAutoString fullName(NS_CUPS_PRINTER);
110
                nsCAutoString fullName(NS_CUPS_PRINTER);
109
                fullName.Append(dests[i].name);
111
                fullName.Append(dests[i].name);
110
                if (dests[i].instance != NULL) {
112
                if (dests[i].instance != NULL) {
111
                    fullName.Append("/");
113
                    fullName.Append("/");
112
                    fullName.Append(dests[i].instance);
114
                    fullName.Append(dests[i].instance);
113
                }
115
                }
114
                if (dests[i].is_default)
116
                if (dests[i].is_default)
115
                    aList.InsertElementAt(0, fullName);
117
                    aList.InsertElementAt(0, fullName);
116
                else
118
                else
117
                    aList.AppendElement(fullName);
119
                    aList.AppendElement(fullName);
118
            }
120
            }
119
        }
121
        }
120
        (mCups.mCupsFreeDests)(num_dests, dests);
122
        (gCupsShim.mCupsFreeDests)(num_dests, dests);
121
    }
123
    }
122
124
123
    // Build the "classic" list of printers -- those accessed by running
125
    // Build the "classic" list of printers -- those accessed by running
124
    // an opaque command. This list always contains a printer named "default".
126
    // an opaque command. This list always contains a printer named "default".
125
    // In addition, we look for either an environment variable
127
    // In addition, we look for either an environment variable
126
    // MOZILLA_POSTSCRIPT_PRINTER_LIST or a preference setting
128
    // MOZILLA_POSTSCRIPT_PRINTER_LIST or a preference setting
127
    // print.printer_list, which contains a space-separated list of printer
129
    // print.printer_list, which contains a space-separated list of printer
128
    // names.
130
    // names.
(-)a/gfx/src/psshared/nsPSPrinters.h (-2 lines)
Lines 37-53 Link Here
37
 * ***** END LICENSE BLOCK ***** */
37
 * ***** END LICENSE BLOCK ***** */
38
38
39
#ifndef nsPSPrinters_h___
39
#ifndef nsPSPrinters_h___
40
#define nsPSPrinters_h___
40
#define nsPSPrinters_h___
41
41
42
#include "nsString.h"
42
#include "nsString.h"
43
#include "nsTArray.h"
43
#include "nsTArray.h"
44
#include "prtypes.h"
44
#include "prtypes.h"
45
#include "nsCUPSShim.h"
46
#include "psSharedCore.h"
45
#include "psSharedCore.h"
47
46
48
class nsIPrefService;
47
class nsIPrefService;
49
class nsIPrefBranch;
48
class nsIPrefBranch;
50
class nsCUPSShim;
49
class nsCUPSShim;
51
50
52
class NS_PSSHARED nsPSPrinterList {
51
class NS_PSSHARED nsPSPrinterList {
53
    public:
52
    public:
Lines 91-102 class NS_PSSHARED nsPSPrinterList { Link Here
91
         *              the <type> portion as described for GetPrinterList().
90
         *              the <type> portion as described for GetPrinterList().
92
         * @return The PrinterType value for this name.
91
         * @return The PrinterType value for this name.
93
         */
92
         */
94
        static PrinterType GetPrinterType(const nsACString& aName);
93
        static PrinterType GetPrinterType(const nsACString& aName);
95
94
96
    private:
95
    private:
97
        nsCOMPtr<nsIPrefService> mPrefSvc;
96
        nsCOMPtr<nsIPrefService> mPrefSvc;
98
        nsCOMPtr<nsIPrefBranch> mPref;
97
        nsCOMPtr<nsIPrefBranch> mPref;
99
        nsCUPSShim mCups;
100
};
98
};
101
99
102
#endif /* nsPSPrinters_h___ */
100
#endif /* nsPSPrinters_h___ */

Return to bug 325469