LibreOffice Module vcl (master) 1
cupsmgr.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_VCL_INC_UNX_CUPSMGR_HXX
21#define INCLUDED_VCL_INC_UNX_CUPSMGR_HXX
22
24#include <osl/thread.h>
25#include <osl/mutex.hxx>
26
27namespace psp
28{
29
30class PPDParser;
31
33{
34 size_t operator()(const FILE* pPtr) const
35 { return reinterpret_cast<size_t>(pPtr); }
36};
37
38class CUPSManager final : public PrinterInfoManager
39{
40 std::unordered_map< FILE*, OString, FPtrHash > m_aSpoolFiles;
42 void* m_pDests;
44 std::unordered_map< OUString, int > m_aCUPSDestMap;
45
46 std::unordered_map< OUString, PPDContext > m_aDefaultContexts;
47
48 OString m_aUser;
52 OString m_aPassword;
53
54 osl::Mutex m_aCUPSMutex;
55 oslThread m_aDestThread;
56
57 osl::Mutex m_aGetPPDMutex;
59
61 virtual ~CUPSManager() override;
62
63 virtual void initialize() override;
64
65 static void getOptionsFromDocumentSetup( const JobData& rJob, bool bBanner, int& rNumOptions, void** rOptions );
66 void runDests();
67 OString threadedCupsGetPPD(const char* pPrinter);
68public:
69 static void runDestThread(void* pMgr);
70
72
74 const PPDParser* createCUPSParser( const OUString& rPrinter );
75
76 const char* authenticateUser();
77
78 virtual FILE* startSpool( const OUString& rPrinterName, bool bQuickCommand ) override;
79 virtual bool endSpool( const OUString& rPrinterName, const OUString& rJobTitle, FILE* pFile, const JobData& rDocumentJobData, bool bBanner, const OUString& rFaxNumber ) override;
80 virtual void setupJobContextData( JobData& rData ) override;
81
83 virtual bool checkPrintersChanged( bool bWait ) override;
84};
85
86} // namespace psp
87
88#endif
89
90/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unordered_map< FILE *, OString, FPtrHash > m_aSpoolFiles
Definition: cupsmgr.hxx:40
static void getOptionsFromDocumentSetup(const JobData &rJob, bool bBanner, int &rNumOptions, void **rOptions)
std::unordered_map< OUString, int > m_aCUPSDestMap
Definition: cupsmgr.hxx:44
virtual ~CUPSManager() override
virtual FILE * startSpool(const OUString &rPrinterName, bool bQuickCommand) override
OString threadedCupsGetPPD(const char *pPrinter)
static void runDestThread(void *pMgr)
osl::Mutex m_aCUPSMutex
Definition: cupsmgr.hxx:54
virtual bool endSpool(const OUString &rPrinterName, const OUString &rJobTitle, FILE *pFile, const JobData &rDocumentJobData, bool bBanner, const OUString &rFaxNumber) override
void * m_pDests
Definition: cupsmgr.hxx:42
bool m_bPPDThreadRunning
Definition: cupsmgr.hxx:58
const PPDParser * createCUPSParser(const OUString &rPrinter)
wraps cupsGetPPD, so unlink after use !
static CUPSManager * tryLoadCUPS()
virtual bool checkPrintersChanged(bool bWait) override
check if the printer configuration has changed
osl::Mutex m_aGetPPDMutex
Definition: cupsmgr.hxx:57
virtual void initialize() override
OString m_aUser
Definition: cupsmgr.hxx:48
const char * authenticateUser()
oslThread m_aDestThread
Definition: cupsmgr.hxx:55
std::unordered_map< OUString, PPDContext > m_aDefaultContexts
Definition: cupsmgr.hxx:46
virtual void setupJobContextData(JobData &rData) override
OString m_aPassword
this is a security risk, but the CUPS API demands to deliver a pointer to a static buffer containing ...
Definition: cupsmgr.hxx:52
size_t operator()(const FILE *pPtr) const
Definition: cupsmgr.hxx:34