1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <printerinfomanager.hxx>
23 #include <osl/thread.h>
24 #include <osl/mutex.hxx>
35 size_t operator()(const FILE* pPtr
) const
36 { return reinterpret_cast<size_t>(pPtr
); }
39 class CUPSManager final
: public PrinterInfoManager
41 std::unordered_map
< FILE*, OString
, FPtrHash
> m_aSpoolFiles
;
43 cups_dest_s
* m_pDests
;
45 std::unordered_map
< OUString
, int > m_aCUPSDestMap
;
47 std::unordered_map
< OUString
, PPDContext
> m_aDefaultContexts
;
50 /** this is a security risk, but the CUPS API demands
51 to deliver a pointer to a static buffer containing
52 the password, so this cannot be helped*/
55 osl::Mutex m_aCUPSMutex
;
56 oslThread m_aDestThread
;
58 osl::Mutex m_aGetPPDMutex
;
59 bool m_bPPDThreadRunning
;
62 virtual ~CUPSManager() override
;
64 virtual void initialize() override
;
66 static void getOptionsFromDocumentSetup( const JobData
& rJob
, bool bBanner
, int& rNumOptions
, void** rOptions
);
68 OString
threadedCupsGetPPD(const char* pPrinter
);
70 static void runDestThread(void* pMgr
);
72 static CUPSManager
* tryLoadCUPS();
74 /// wraps cupsGetPPD, so unlink after use !
75 const PPDParser
* createCUPSParser( const OUString
& rPrinter
);
77 const char* authenticateUser();
79 virtual FILE* startSpool( const OUString
& rPrinterName
, bool bQuickCommand
) override
;
80 virtual bool endSpool( const OUString
& rPrinterName
, const OUString
& rJobTitle
, FILE* pFile
, const JobData
& rDocumentJobData
, bool bBanner
, const OUString
& rFaxNumber
) override
;
81 virtual void setupJobContextData( JobData
& rData
) override
;
83 /// check if the printer configuration has changed
84 virtual bool checkPrintersChanged( bool bWait
) override
;
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */