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 
23 #include <printerinfomanager.hxx>
24 #include <osl/thread.h>
25 #include <osl/mutex.hxx>
26 
27 namespace psp
28 {
29 
30 class PPDParser;
31 
32 struct FPtrHash
33 {
34  size_t operator()(const FILE* pPtr) const
35  { return reinterpret_cast<size_t>(pPtr); }
36 };
37 
39 {
40  std::unordered_map< FILE*, OString, FPtrHash > m_aSpoolFiles;
41  int m_nDests;
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 
60  CUPSManager();
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);
68 public:
69  static void runDestThread(void* pMgr);
70 
71  static CUPSManager* tryLoadCUPS();
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: */
OString threadedCupsGetPPD(const char *pPrinter)
void * m_pDests
Definition: cupsmgr.hxx:42
virtual void setupJobContextData(JobData &rData) override
const PPDParser * createCUPSParser(const OUString &rPrinter)
wraps cupsGetPPD, so unlink after use !
static void getOptionsFromDocumentSetup(const JobData &rJob, bool bBanner, int &rNumOptions, void **rOptions)
virtual bool checkPrintersChanged(bool bWait) override
check if the printer configuration has changed
virtual ~CUPSManager() override
virtual FILE * startSpool(const OUString &rPrinterName, bool bQuickCommand) override
static CUPSManager * tryLoadCUPS()
size_t operator()(const FILE *pPtr) const
Definition: cupsmgr.hxx:34
virtual bool endSpool(const OUString &rPrinterName, const OUString &rJobTitle, FILE *pFile, const JobData &rDocumentJobData, bool bBanner, const OUString &rFaxNumber) override
std::unordered_map< OUString, PPDContext > m_aDefaultContexts
Definition: cupsmgr.hxx:46
oslThread m_aDestThread
Definition: cupsmgr.hxx:55
osl::Mutex m_aCUPSMutex
Definition: cupsmgr.hxx:54
std::unordered_map< FILE *, OString, FPtrHash > m_aSpoolFiles
Definition: cupsmgr.hxx:40
std::unordered_map< OUString, int > m_aCUPSDestMap
Definition: cupsmgr.hxx:44
virtual void initialize() override
bool m_bPPDThreadRunning
Definition: cupsmgr.hxx:58
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
OString m_aUser
Definition: cupsmgr.hxx:48
const char * authenticateUser()
osl::Mutex m_aGetPPDMutex
Definition: cupsmgr.hxx:57
static void runDestThread(void *pMgr)