bump product version to 7.2.5.1
[LibreOffice.git] / vcl / inc / unx / cupsmgr.hxx
blob9fd15393870515079608ca72d23743382e5b7f20
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_INC_UNX_CUPSMGR_HXX
21 #define INCLUDED_VCL_INC_UNX_CUPSMGR_HXX
23 #include <printerinfomanager.hxx>
24 #include <osl/thread.h>
25 #include <osl/mutex.hxx>
27 namespace psp
30 class PPDParser;
32 struct FPtrHash
34 size_t operator()(const FILE* pPtr) const
35 { return reinterpret_cast<size_t>(pPtr); }
38 class CUPSManager : public PrinterInfoManager
40 std::unordered_map< FILE*, OString, FPtrHash > m_aSpoolFiles;
41 int m_nDests;
42 void* m_pDests;
43 bool m_bNewDests;
44 std::unordered_map< OUString, int > m_aCUPSDestMap;
46 std::unordered_map< OUString, PPDContext > m_aDefaultContexts;
48 OString m_aUser;
49 /** this is a security risk, but the CUPS API demands
50 to deliver a pointer to a static buffer containing
51 the password, so this cannot be helped*/
52 OString m_aPassword;
54 osl::Mutex m_aCUPSMutex;
55 oslThread m_aDestThread;
57 osl::Mutex m_aGetPPDMutex;
58 bool m_bPPDThreadRunning;
60 CUPSManager();
61 virtual ~CUPSManager() override;
63 virtual void initialize() override;
65 static void getOptionsFromDocumentSetup( const JobData& rJob, bool bBanner, int& rNumOptions, void** rOptions );
66 void runDests();
67 OString threadedCupsGetPPD(const char* pPrinter);
68 public:
69 static void runDestThread(void* pMgr);
71 static CUPSManager* tryLoadCUPS();
73 /// wraps cupsGetPPD, so unlink after use !
74 const PPDParser* createCUPSParser( const OUString& rPrinter );
76 const char* authenticateUser();
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;
82 /// check if the printer configuration has changed
83 virtual bool checkPrintersChanged( bool bWait ) override;
86 } // namespace psp
88 #endif
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */